@scriptc/compiler 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +162 -19
  2. package/dist/backend/cc.d.ts +8 -0
  3. package/dist/backend/cc.js +12 -0
  4. package/dist/backend/cc.js.map +1 -1
  5. package/dist/backend/emission/emit-exprs.js +146 -16
  6. package/dist/backend/emission/emit-exprs.js.map +1 -1
  7. package/dist/backend/llvm/emitter.js +54 -7
  8. package/dist/backend/llvm/emitter.js.map +1 -1
  9. package/dist/frontend/lowering/crypto-tables.d.ts +7 -0
  10. package/dist/frontend/lowering/crypto-tables.js +139 -0
  11. package/dist/frontend/lowering/crypto-tables.js.map +1 -0
  12. package/dist/frontend/lowering/lower-builtins.d.ts +38 -20
  13. package/dist/frontend/lowering/lower-builtins.js +111 -39
  14. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  15. package/dist/frontend/lowering/lower-calls.js +8 -0
  16. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  17. package/dist/frontend/lowering/lower-classes.js +10 -2
  18. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  19. package/dist/frontend/lowering/lower-exprs.js +69 -7
  20. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  21. package/dist/frontend/lowering/lower-modules.js +1 -1
  22. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  23. package/dist/frontend/lowering/lower-server.d.ts +21 -0
  24. package/dist/frontend/lowering/lower-server.js +294 -23
  25. package/dist/frontend/lowering/lower-server.js.map +1 -1
  26. package/dist/frontend/lowering/lower-stmts.js +4 -4
  27. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  28. package/dist/frontend/lowering/lower-stream.js +1 -1
  29. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  30. package/dist/frontend/lowering/lowerer.d.ts +21 -3
  31. package/dist/frontend/lowering/lowerer.js +48 -8
  32. package/dist/frontend/lowering/lowerer.js.map +1 -1
  33. package/dist/frontend/lowering/surfaces.d.ts +6 -0
  34. package/dist/frontend/lowering/surfaces.js +76 -0
  35. package/dist/frontend/lowering/surfaces.js.map +1 -1
  36. package/dist/frontend/types.js +12 -0
  37. package/dist/frontend/types.js.map +1 -1
  38. package/dist/index.js +6 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/ir/nodes.d.ts +103 -9
  41. package/dist/ir/nodes.js +56 -1
  42. package/dist/ir/nodes.js.map +1 -1
  43. package/dist/ir/validate.js +55 -4
  44. package/dist/ir/validate.js.map +1 -1
  45. package/package.json +2 -2
  46. package/surface-manifest.json +286 -1
@@ -226,6 +226,11 @@ const LIB_FN_SYMS = {
226
226
  "text.decode": "scr_text_decode",
227
227
  "zlib.deflateSync": "scr_zlib_deflate",
228
228
  "zlib.inflateSync": "scr_zlib_inflate",
229
+ // The CA-store unit. get/set throw (an unknown type name, a
230
+ // certificate-free set) and take the generic path's pending check.
231
+ "tlsca.root": "scr_tls_ca_root",
232
+ "tlsca.get": "scr_tls_ca_get",
233
+ "tlsca.set": "scr_tls_ca_set_default",
229
234
  "crypto.randomBytes": "scr_crypto_random_bytes",
230
235
  "crypto.randomBytesToString": "scr_crypto_random_string",
231
236
  "crypto.randomUUID": "scr_crypto_random_uuid",
@@ -350,6 +355,7 @@ const LIB_FN_SYMS = {
350
355
  "dyn.iterPack": "scr_dyn_iter_pack",
351
356
  "dyn.arrLen": "scr_dyn_arr_len",
352
357
  "dyn.arrAt": "scr_dyn_arr_at",
358
+ "dyn.hasKey": "scr_dyn_has_key",
353
359
  "dyn.defineProps": "scr_dyn_define_props",
354
360
  "dyn.typeof": "scr_dyn_typeof",
355
361
  "dyn.toString": "scr_dyn_to_string_method",
@@ -446,6 +452,12 @@ const LIB_FN_SYMS = {
446
452
  "net.sockSetEncoding": "scr_net_sock_set_encoding",
447
453
  "net.sockSetTimeout": "scr_net_sock_set_timeout",
448
454
  "net.sockUnshift": "scr_net_sock_unshift_bytes",
455
+ "net.sockPause": "scr_net_sock_pause",
456
+ "net.sockResume": "scr_net_sock_resume",
457
+ "net.sockSetNoDelay": "scr_net_sock_set_nodelay",
458
+ "net.sockDestroySoon": "scr_net_sock_destroy_soon",
459
+ "net.sockBytesWritten": "scr_net_sock_bytes_written",
460
+ "net.sockReadable": "scr_net_sock_readable",
449
461
  "net.sockPipeRes": "scr_http_sock_pipe_res",
450
462
  "net.serverEmitConnection": "scr_net_server_emit_connection",
451
463
  "net.getAutoSelTimeout": "scr_net_get_autosel_timeout",
@@ -492,6 +504,7 @@ const LIB_FN_SYMS = {
492
504
  "http.clientDestroy": "scr_http_client_destroy",
493
505
  "http.clientDestroyed": "scr_http_client_destroyed",
494
506
  "http2.streamUndefCall": "scr_http2_stream_undef_call",
507
+ "http.agentNew": "scr_http_agent_new",
495
508
  // The island surface (--dynamic): eval/import bridge catchably (the
496
509
  // may-throw seed's pending check); importDyn answers an engine promise
497
510
  // and never throws itself. insp.jsval throws on composite island
@@ -556,6 +569,9 @@ const LIB_FN_SYMS = {
556
569
  "process.offWarning": "scr_process_off_warning",
557
570
  "process.emitWarning": "scr_process_emit_warning",
558
571
  "process.onUnhandledRejection": "scr_process_on_unhandled_rejection",
572
+ "process.offUnhandledRejection": "scr_process_off_unhandled_rejection",
573
+ "process.onRejectionHandled": "scr_process_on_rejection_handled",
574
+ "process.offRejectionHandled": "scr_process_off_rejection_handled",
559
575
  // The await lowering's loop hop and the dyn await (both park the
560
576
  // current fiber — USES_TIMERS_LIB_FNS marks the loop live).
561
577
  "async.hop": "scr_await_hop",
@@ -632,13 +648,15 @@ const USES_TIMERS_LIB_FNS = new Set([
632
648
  "fs.existsChk",
633
649
  "http.createServer", "http.createServerEmpty",
634
650
  "http.request", "http.requestCb", "http.requestUrl", "http.requestUrlCb",
651
+ "https.requestUrl", "https.requestUrlCb",
635
652
  "http.requestConn", "http.requestConnCb",
653
+ "http.agentNew", "http.requestAgent", "http.requestAgentCb",
636
654
  // The dyn-async slice (emit-exprs.ts's markings): fiber parks, the
637
655
  // microtask/immediate mints, the tracing-promise reaction fiber, and
638
656
  // the loop-end unhandled-rejection report.
639
657
  "async.hop", "async.awaitDyn",
640
658
  "dc.tcTracePromise",
641
- "process.onUnhandledRejection",
659
+ "process.onUnhandledRejection", "process.onRejectionHandled",
642
660
  "timers.queueMicrotaskDyn", "timers.setImmediateFnValue", "timers.immediatePromise",
643
661
  ]);
644
662
  /** ScrBytesElem (scr_runtime.h): U8, U32, F32, I32. */
@@ -4199,8 +4217,21 @@ class LlEmitter {
4199
4217
  const lj = B.newLabel("ord.j");
4200
4218
  B.condBr(truthy, lt, lf);
4201
4219
  B.startBlock(lt);
4202
- B.line(`store ${ty} ${this.unionExtract(l.name, e.type)}, ptr ${slot}`);
4203
- this.releaseValue(l.name, e.left.type);
4220
+ if (e.retag !== undefined) {
4221
+ // Retagged shape: the whole box goes to the union→union helper,
4222
+ // which CONSUMES it (callees own their params) — no release on
4223
+ // this side. The store precedes the pending check so an unwind
4224
+ // leaves only the NULL dummy behind, in a slot nothing reads.
4225
+ const t = B.tmp();
4226
+ B.line(`${t} = call ${ty} @${this.callTarget(e.retag)}(${this.llType(e.left.type)} ${l.name})`);
4227
+ B.line(`store ${ty} ${t}, ptr ${slot}`);
4228
+ if (this.mayThrow.has(e.retag))
4229
+ this.emitPendingCheck();
4230
+ }
4231
+ else {
4232
+ B.line(`store ${ty} ${this.unionExtract(l.name, e.type)}, ptr ${slot}`);
4233
+ this.releaseValue(l.name, e.left.type);
4234
+ }
4204
4235
  B.br(lj);
4205
4236
  B.startBlock(lf);
4206
4237
  this.releaseValue(l.name, e.left.type);
@@ -10598,9 +10629,16 @@ class LlEmitter {
10598
10629
  B.line(`call void @${entry}(ptr ${args[0].name}, ptr ${args[1].name}, ptr @${adapter}, i1 ${args[2].name})`);
10599
10630
  return { name: "", type: e.type };
10600
10631
  }
10601
- if (e.fn === "http.request" || e.fn === "http.requestCb" || e.fn === "http.requestUrl" || e.fn === "http.requestUrlCb") {
10602
- const isUrl = e.fn.startsWith("http.requestUrl");
10603
- const cbIdx = isUrl ? 3 : 7;
10632
+ if (e.fn === "http.request" || e.fn === "http.requestCb" || e.fn === "http.requestUrl" || e.fn === "http.requestUrlCb" ||
10633
+ e.fn === "http.requestAgent" || e.fn === "http.requestAgentCb" ||
10634
+ e.fn === "https.requestUrl" || e.fn === "https.requestUrlCb") {
10635
+ // The https URL row is the http one with the TLS entry point — same
10636
+ // three arguments, same response-callback adapter. (The https
10637
+ // OPTIONS forms are a separate, wider row and are not here yet.)
10638
+ const isTls = e.fn.startsWith("https.");
10639
+ const isUrl = isTls || e.fn.startsWith("http.requestUrl");
10640
+ const isAgent = e.fn.startsWith("http.requestAgent");
10641
+ const cbIdx = isUrl ? 3 : isAgent ? 8 : 7;
10604
10642
  const hasCb = e.fn.endsWith("Cb");
10605
10643
  const args = e.args.map((a) => this.emitExpr(a));
10606
10644
  let cb = "null";
@@ -10617,7 +10655,9 @@ class LlEmitter {
10617
10655
  }
10618
10656
  const head = args.slice(0, cbIdx);
10619
10657
  const decls = head.map((a) => (this.llType(a.type) === "i1" ? "i1 zeroext" : this.llType(a.type)));
10620
- const entry = isUrl ? "scr_http_request_url" : "scr_http_request";
10658
+ const entry = isTls ? "scr_https_request_url"
10659
+ : isUrl ? "scr_http_request_url"
10660
+ : isAgent ? "scr_http_request_agent" : "scr_http_request";
10621
10661
  this.declare(`declare ptr @${entry}(${[...decls, "ptr", "ptr"].join(", ")})`);
10622
10662
  const t = B.tmp();
10623
10663
  B.line(`${t} = call ptr @${entry}(${[...head.map((a) => `${this.llType(a.type)} ${a.name}`), `ptr ${cb}`, `ptr ${adapter}`].join(", ")})`);
@@ -10652,6 +10692,13 @@ class LlEmitter {
10652
10692
  B.line(`call void @scr_http_res_on_finish(ptr ${args[0].name}, ptr ${args[1].name})`);
10653
10693
  return { name: "", type: e.type };
10654
10694
  }
10695
+ if (e.fn === "net.sockOnFinish") {
10696
+ const args = e.args.map((a) => this.emitExpr(a));
10697
+ this.moveTemp(args[1]);
10698
+ this.declare(`declare void @scr_net_sock_on_finish(ptr, ptr)`);
10699
+ B.line(`call void @scr_net_sock_on_finish(ptr ${args[0].name}, ptr ${args[1].name})`);
10700
+ return { name: "", type: e.type };
10701
+ }
10655
10702
  if (e.fn === "island.castFail") {
10656
10703
  // The deferred boundary failure: the island value was evaluated
10657
10704
  // (its side effects are real), the throw is unconditional