@scriptc/compiler 0.0.8 → 0.0.9

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 (66) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +13 -0
  2. package/dist/backend/cc.js +14 -0
  3. package/dist/backend/cc.js.map +1 -1
  4. package/dist/backend/emission/emit-exprs.js +108 -5
  5. package/dist/backend/emission/emit-exprs.js.map +1 -1
  6. package/dist/backend/emission/emit-types.d.ts +3 -0
  7. package/dist/backend/emission/emit-types.js +12 -0
  8. package/dist/backend/emission/emit-types.js.map +1 -1
  9. package/dist/backend/emission/emit-walkers.d.ts +7 -5
  10. package/dist/backend/emission/emit-walkers.js +23 -10
  11. package/dist/backend/emission/emit-walkers.js.map +1 -1
  12. package/dist/backend/emission/emitter.d.ts +1 -1
  13. package/dist/backend/emission/emitter.js +30 -9
  14. package/dist/backend/emission/emitter.js.map +1 -1
  15. package/dist/backend/llvm/emitter.js +206 -11
  16. package/dist/backend/llvm/emitter.js.map +1 -1
  17. package/dist/diagnostics/diagnostic.d.ts +55 -10
  18. package/dist/diagnostics/diagnostic.js +82 -20
  19. package/dist/diagnostics/diagnostic.js.map +1 -1
  20. package/dist/frontend/lowering/lower-assert.js +16 -0
  21. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  22. package/dist/frontend/lowering/lower-builtins.d.ts +11 -0
  23. package/dist/frontend/lowering/lower-builtins.js +111 -3
  24. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  25. package/dist/frontend/lowering/lower-calls.d.ts +30 -11
  26. package/dist/frontend/lowering/lower-calls.js +418 -8
  27. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  28. package/dist/frontend/lowering/lower-classes.js +27 -1
  29. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  30. package/dist/frontend/lowering/lower-containers.d.ts +4 -2
  31. package/dist/frontend/lowering/lower-containers.js +193 -43
  32. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  33. package/dist/frontend/lowering/lower-emitter.js +54 -0
  34. package/dist/frontend/lowering/lower-emitter.js.map +1 -1
  35. package/dist/frontend/lowering/lower-exprs.js +52 -7
  36. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  37. package/dist/frontend/lowering/lower-stmts.js +445 -13
  38. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  39. package/dist/frontend/lowering/lower-stream.js +28 -2
  40. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  41. package/dist/frontend/lowering/lowerer.d.ts +66 -14
  42. package/dist/frontend/lowering/lowerer.js +273 -28
  43. package/dist/frontend/lowering/lowerer.js.map +1 -1
  44. package/dist/frontend/lowering/surfaces.js +20 -3
  45. package/dist/frontend/lowering/surfaces.js.map +1 -1
  46. package/dist/frontend/npm-static-rewrite.d.ts +7 -2
  47. package/dist/frontend/npm-static-rewrite.js +566 -138
  48. package/dist/frontend/npm-static-rewrite.js.map +1 -1
  49. package/dist/frontend/npm-static.js +11 -2
  50. package/dist/frontend/npm-static.js.map +1 -1
  51. package/dist/frontend/program.js +5 -5
  52. package/dist/frontend/program.js.map +1 -1
  53. package/dist/frontend/shared.d.ts +6 -1
  54. package/dist/frontend/shared.js +46 -1
  55. package/dist/frontend/shared.js.map +1 -1
  56. package/dist/frontend/types.js +4 -2
  57. package/dist/frontend/types.js.map +1 -1
  58. package/dist/index.js +150 -25
  59. package/dist/index.js.map +1 -1
  60. package/dist/ir/nodes.d.ts +131 -7
  61. package/dist/ir/nodes.js +41 -3
  62. package/dist/ir/nodes.js.map +1 -1
  63. package/dist/ir/validate.js +58 -8
  64. package/dist/ir/validate.js.map +1 -1
  65. package/package.json +2 -2
  66. package/surface-manifest.json +10 -3
@@ -180,6 +180,8 @@ export const LIB_FN_SIGS = {
180
180
  "regexp.escape": { argTypes: [STRING], result: STRING },
181
181
  "num.toExponential": { argTypes: [F64], result: STRING },
182
182
  "num.toFixed0": { argTypes: [F64], result: STRING },
183
+ "num.sameValue": { argTypes: [F64, F64], result: BOOL },
184
+ "intl.numFormatEnUs": { argTypes: [F64], result: STRING },
183
185
  "sym.new": { argTypes: [STRING], result: SYMBOL_T },
184
186
  "sym.newAnon": { argTypes: [], result: SYMBOL_T },
185
187
  "sym.for": { argTypes: [STRING], result: SYMBOL_T },
@@ -636,6 +638,16 @@ export const LIB_FN_SIGS = {
636
638
  "buffer.byteLenStr": { argTypes: [STRING, STRING], result: F64 },
637
639
  "buffer.isEncoding": { argTypes: [STRING], result: BOOL },
638
640
  "buffer.concatLen": { argTypes: [arrayOf(BYTES_U8), F64], result: BYTES_U8 },
641
+ // The checked-dynamic compare/equals validators (Node's argument
642
+ // ladders over DOM-boxed invalid-input probes).
643
+ "buffer.compareChk": { argTypes: [DYN, DYN], result: F64 },
644
+ "bytes.equalsChk": { argTypes: [BYTES_U8, DYN], result: BOOL },
645
+ "bytes.compareChk": { argTypes: [BYTES_U8, DYN, DYN, DYN, DYN, DYN], result: F64 },
646
+ "buffer.newStringFail": { argTypes: [DYN], result: BYTES_U8 },
647
+ "fs.toUnixTimestamp": { argTypes: [DYN], result: F64 },
648
+ "error.argTypeThrow": { argTypes: [STRING, STRING, DYN], result: VOID },
649
+ "emitter.setMaxChk": { argTypes: [null, DYN], result: VOID },
650
+ "emitter.setDefaultMaxChk": { argTypes: [DYN, STRING], result: VOID },
639
651
  "fs.readFileSyncBytes": { argTypes: [STRING], result: BYTES_U8 },
640
652
  "fs.writeFileSyncBytes": { argTypes: [STRING, BYTES_U8], result: VOID },
641
653
  "fsp.readFileBytes": { argTypes: [STRING], result: { kind: "promise", inner: BYTES_U8 } },
@@ -681,6 +693,8 @@ export const LIB_FN_SIGS = {
681
693
  // error.new's result and the receiver slots are builtin-error classes —
682
694
  // program-dependent object types, checked in the libCall case.
683
695
  "error.new": { argTypes: [STRING], result: VOID },
696
+ "error.nodeThrow": { argTypes: [F64, STRING, STRING], result: VOID },
697
+ "dyn.toStringCoerce": { argTypes: [DYN], result: STRING },
684
698
  // Always throws; the result is the READ's declared type (a typed dummy
685
699
  // the unwind abandons) — the libCall case skips the result check.
686
700
  "global.undefRead": { argTypes: [STRING], result: VOID },
@@ -768,6 +782,8 @@ export const LIB_FN_SIGS = {
768
782
  "stream.finishedDyn": { argTypes: [null, DYN], result: VOID },
769
783
  "stream.pipeline": { argTypes: [F64], result: VOID },
770
784
  "stream.pipelineDyn": { argTypes: [F64], result: VOID },
785
+ "sp.finished": { argTypes: [null], result: { kind: "promise", inner: VOID } },
786
+ "sp.pipeline": { argTypes: [F64], result: { kind: "promise", inner: VOID } },
771
787
  "readable.newDyn": { argTypes: [DYN], result: VOID },
772
788
  "writable.newDyn": { argTypes: [DYN], result: VOID },
773
789
  "duplex.newDyn": { argTypes: [DYN], result: VOID },
@@ -2059,12 +2075,21 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
2059
2075
  ? { argTypes: [STRING, F64, F64, F64], minArgs: 4, result: F64 }
2060
2076
  : e.method === "dataViewNew"
2061
2077
  ? { argTypes: [F64, F64], minArgs: 0, result: BYTES_U8 }
2062
- : {
2063
- // dvGet*: the 8-bit getters take no littleEndian.
2064
- argTypes: e.method === "dvGetUint8" || e.method === "dvGetInt8" ? [F64] : [F64, BOOL],
2065
- minArgs: 1,
2066
- result: F64,
2067
- });
2078
+ : e.method.startsWith("dvSet")
2079
+ ? {
2080
+ // dvSet*: [offset, value], the 8-bit setters take no littleEndian.
2081
+ argTypes: e.method === "dvSetUint8" || e.method === "dvSetInt8"
2082
+ ? [F64, F64]
2083
+ : [F64, F64, BOOL],
2084
+ minArgs: 2,
2085
+ result: VOID,
2086
+ }
2087
+ : {
2088
+ // dvGet*: the 8-bit getters take no littleEndian.
2089
+ argTypes: e.method === "dvGetUint8" || e.method === "dvGetInt8" ? [F64] : [F64, BOOL],
2090
+ minArgs: 1,
2091
+ result: F64,
2092
+ });
2068
2093
  if (e.args.length < sig.minArgs || e.args.length > sig.argTypes.length) {
2069
2094
  err(`bytesIntrinsic ${e.method}: ${e.args.length} args`, e.loc);
2070
2095
  }
@@ -2777,6 +2802,21 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
2777
2802
  if (a.type.kind !== "dyn")
2778
2803
  err(`dynCall argument of kind ${a.type.kind} (must be dyn)`, e.loc);
2779
2804
  }
2805
+ // The runtime-arity form: spread entries point into args (their
2806
+ // dyn values flatten at the call), strictly increasing.
2807
+ if (e.spreads !== undefined) {
2808
+ if (e.spreads.length === 0)
2809
+ err("dynCall spreads must be non-empty when present", e.loc);
2810
+ let prev = -1;
2811
+ for (const s of e.spreads) {
2812
+ if (!Number.isInteger(s.arg) || s.arg < 0 || s.arg >= e.args.length) {
2813
+ err(`dynCall spread index ${s.arg} out of range`, e.loc);
2814
+ }
2815
+ if (s.arg <= prev)
2816
+ err("dynCall spread indices must be strictly increasing", e.loc);
2817
+ prev = s.arg;
2818
+ }
2819
+ }
2780
2820
  break;
2781
2821
  }
2782
2822
  case "dynInvoke": {
@@ -3184,6 +3224,7 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
3184
3224
  e.fn === "duplex.initDyn" || e.fn === "transform.initDyn" ||
3185
3225
  e.fn === "passthrough.initDyn" ||
3186
3226
  e.fn === "stream.pipeline" || e.fn === "stream.pipelineDyn" ||
3227
+ e.fn === "sp.pipeline" ||
3187
3228
  e.fn === "writable.write" ||
3188
3229
  e.fn === "writable.writeStr" || e.fn === "writable.writeU" ||
3189
3230
  e.fn === "writable.end" ||
@@ -3834,6 +3875,11 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
3834
3875
  // of the undefined global mapped to (never materialized).
3835
3876
  break;
3836
3877
  }
3878
+ if (e.fn === "error.nodeThrow" || e.fn === "error.argTypeThrow") {
3879
+ // Always throws — the result type is the replaced expression's
3880
+ // own (never materialized; the global.undefRead pattern).
3881
+ break;
3882
+ }
3837
3883
  if (e.fn === "error.new") {
3838
3884
  // Which builtin the runtime constructs is named by the result type.
3839
3885
  if (!isBuiltinErrorObject(e.type)) {
@@ -4048,6 +4094,7 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
4048
4094
  break;
4049
4095
  }
4050
4096
  if (e.fn.startsWith("emitter.") && e.fn !== "emitter.setDefaultMax" &&
4097
+ e.fn !== "emitter.setDefaultMaxChk" &&
4051
4098
  e.fn !== "emitter.getDefaultMax" && e.fn !== "emitter.checkListener") {
4052
4099
  // Receiver: an emitter-hierarchy object (the %EventEmitter class
4053
4100
  // itself, or a class whose base chain reaches it). emitter.new
@@ -4077,7 +4124,8 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
4077
4124
  if (e.fn === "emitter.on" || e.fn === "emitter.off" ||
4078
4125
  e.fn === "emitter.onDyn" || e.fn === "emitter.offDyn" ||
4079
4126
  e.fn === "emitter.onData" || e.fn === "emitter.onDataDyn" ||
4080
- e.fn === "emitter.removeAll" || e.fn === "emitter.setMax") {
4127
+ e.fn === "emitter.removeAll" || e.fn === "emitter.setMax" ||
4128
+ e.fn === "emitter.setMaxChk") {
4081
4129
  if (!typeEquals(e.type, e.args[0].type)) {
4082
4130
  err(`libCall ${e.fn} must return its receiver's type (the chaining 'this')`, e.loc);
4083
4131
  }
@@ -4418,7 +4466,8 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
4418
4466
  if (e.type.kind !== jsOpResultKind(e.op)) {
4419
4467
  err(`jsOp ${e.op} must be ${jsOpResultKind(e.op)}, got ${e.type.kind}`, e.loc);
4420
4468
  }
4421
- const named = e.op === "getProp" || e.op === "setProp" || e.op === "callMethod" || e.op === "optCallMethod" || e.op === "globalGet";
4469
+ const named = e.op === "getProp" || e.op === "setProp" || e.op === "callMethod" || e.op === "optCallMethod" || e.op === "globalGet" ||
4470
+ e.op === "callSpread"; // the spread expression's source spelling (V8's nullish text spells it)
4422
4471
  if (named !== (e.name !== undefined)) {
4423
4472
  err(`jsOp ${e.op} ${named ? "requires" : "forbids"} a name`, e.loc);
4424
4473
  }
@@ -4428,6 +4477,7 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
4428
4477
  neg: 1, plus: 1, truthy: 1, not: 1, typeof: 1, toStr: 1,
4429
4478
  getProp: 1, setProp: 2, getIdx: 2, setIdx: 3, globalGet: 0,
4430
4479
  undefLit: 0, nullLit: 0, iterNew: 1, defineGetter: 3, objSpread: 2,
4480
+ callSpread: 3, // callee + pre array + spread source
4431
4481
  callMethod: null, optCallMethod: null, callFn: null, construct: null, // receiver/callee + any number of args
4432
4482
  objLit: null, arrLit: null, tplStrings: null, // variable length (objLit: key/value pairs; tplStrings: n cooked + n raw)
4433
4483
  };