@scriptc/compiler 0.1.2 → 0.1.4

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 (206) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +258 -64
  2. package/dist/backend/c/async.d.ts +30 -0
  3. package/dist/backend/c/async.js +224 -0
  4. package/dist/backend/c/async.js.map +1 -1
  5. package/dist/backend/c/c-emitter.d.ts +13 -0
  6. package/dist/backend/c/c-emitter.js +28 -9
  7. package/dist/backend/c/c-emitter.js.map +1 -1
  8. package/dist/backend/c/exprs.d.ts +8 -1
  9. package/dist/backend/c/exprs.js +445 -60
  10. package/dist/backend/c/exprs.js.map +1 -1
  11. package/dist/backend/c/shapes.js +15 -13
  12. package/dist/backend/c/shapes.js.map +1 -1
  13. package/dist/backend/c/types.d.ts +4 -0
  14. package/dist/backend/c/types.js +20 -1
  15. package/dist/backend/c/types.js.map +1 -1
  16. package/dist/backend/c/types.test.js +8 -1
  17. package/dist/backend/c/types.test.js.map +1 -1
  18. package/dist/backend/c/walkers.js +32 -11
  19. package/dist/backend/c/walkers.js.map +1 -1
  20. package/dist/backend/json-literal.d.ts +7 -0
  21. package/dist/backend/json-literal.js +17 -0
  22. package/dist/backend/json-literal.js.map +1 -0
  23. package/dist/backend/json-literal.test.d.ts +1 -0
  24. package/dist/backend/json-literal.test.js +17 -0
  25. package/dist/backend/json-literal.test.js.map +1 -0
  26. package/dist/backend/link-plan.d.ts +2 -1
  27. package/dist/backend/link-plan.js +6 -1
  28. package/dist/backend/link-plan.js.map +1 -1
  29. package/dist/backend/llvm/classes.js +8 -7
  30. package/dist/backend/llvm/classes.js.map +1 -1
  31. package/dist/backend/llvm/common.d.ts +4 -0
  32. package/dist/backend/llvm/common.js +6 -0
  33. package/dist/backend/llvm/common.js.map +1 -1
  34. package/dist/backend/llvm/common.test.d.ts +1 -0
  35. package/dist/backend/llvm/common.test.js +9 -0
  36. package/dist/backend/llvm/common.test.js.map +1 -0
  37. package/dist/backend/llvm/dyn.d.ts +4 -0
  38. package/dist/backend/llvm/dyn.js +24 -13
  39. package/dist/backend/llvm/dyn.js.map +1 -1
  40. package/dist/backend/llvm/emitter.js +54 -12
  41. package/dist/backend/llvm/emitter.js.map +1 -1
  42. package/dist/backend/llvm/expr-bytes.d.ts +1 -1
  43. package/dist/backend/llvm/expr-bytes.js +8 -8
  44. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  45. package/dist/backend/llvm/expr-callbacks.d.ts +9 -0
  46. package/dist/backend/llvm/expr-callbacks.js +125 -0
  47. package/dist/backend/llvm/expr-callbacks.js.map +1 -1
  48. package/dist/backend/llvm/expr-context.d.ts +18 -2
  49. package/dist/backend/llvm/expr-dispatch.js +1 -0
  50. package/dist/backend/llvm/expr-dispatch.js.map +1 -1
  51. package/dist/backend/llvm/expr-dynamic.js +9 -0
  52. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  53. package/dist/backend/llvm/expr-primitives.d.ts +1 -1
  54. package/dist/backend/llvm/expr-primitives.js +38 -9
  55. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  56. package/dist/backend/llvm/expr-primitives.test.d.ts +1 -0
  57. package/dist/backend/llvm/expr-primitives.test.js +38 -0
  58. package/dist/backend/llvm/expr-primitives.test.js.map +1 -0
  59. package/dist/backend/llvm/expr-records.js +3 -3
  60. package/dist/backend/llvm/expr-records.js.map +1 -1
  61. package/dist/backend/llvm/expr-stream-bridges.js +2 -1
  62. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  63. package/dist/backend/llvm/expr-stream-callbacks.d.ts +6 -0
  64. package/dist/backend/llvm/expr-stream-callbacks.js +122 -0
  65. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  66. package/dist/backend/llvm/lib-dispatch.js +22 -0
  67. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  68. package/dist/backend/llvm/lib-filesystem.js +68 -10
  69. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  70. package/dist/backend/llvm/lib-network.js +18 -2
  71. package/dist/backend/llvm/lib-network.js.map +1 -1
  72. package/dist/backend/llvm/lib-process.js +206 -11
  73. package/dist/backend/llvm/lib-process.js.map +1 -1
  74. package/dist/backend/llvm/lib-shared.js +82 -0
  75. package/dist/backend/llvm/lib-shared.js.map +1 -1
  76. package/dist/backend/llvm/lib-stream.js +23 -0
  77. package/dist/backend/llvm/lib-stream.js.map +1 -1
  78. package/dist/backend/llvm/shapes.js +10 -8
  79. package/dist/backend/llvm/shapes.js.map +1 -1
  80. package/dist/backend/llvm/walkers.js +7 -5
  81. package/dist/backend/llvm/walkers.js.map +1 -1
  82. package/dist/backend/native-link-info.d.ts +2 -1
  83. package/dist/backend/native-link-info.js +4 -0
  84. package/dist/backend/native-link-info.js.map +1 -1
  85. package/dist/backend/native-link-info.test.js +24 -1
  86. package/dist/backend/native-link-info.test.js.map +1 -1
  87. package/dist/backend/native-toolchain.d.ts +11 -6
  88. package/dist/backend/native-toolchain.js +30 -13
  89. package/dist/backend/native-toolchain.js.map +1 -1
  90. package/dist/backend/native-toolchain.test.js +36 -1
  91. package/dist/backend/native-toolchain.test.js.map +1 -1
  92. package/dist/backend/runtime-pack-targets.test.js +1 -1
  93. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  94. package/dist/backend/runtime-pack.test.js +29 -10
  95. package/dist/backend/runtime-pack.test.js.map +1 -1
  96. package/dist/backend/targets.d.ts +9 -0
  97. package/dist/backend/targets.js +22 -0
  98. package/dist/backend/targets.js.map +1 -1
  99. package/dist/backend/targets.test.js +13 -1
  100. package/dist/backend/targets.test.js.map +1 -1
  101. package/dist/coverage/surface-manifest.js +9 -0
  102. package/dist/coverage/surface-manifest.js.map +1 -1
  103. package/dist/diagnostics/diagnostic.js +4 -4
  104. package/dist/diagnostics/diagnostic.js.map +1 -1
  105. package/dist/executable/executable-cache.d.ts +3 -0
  106. package/dist/executable/executable-cache.js +4 -0
  107. package/dist/executable/executable-cache.js.map +1 -1
  108. package/dist/executable/executable-cache.test.js +1 -0
  109. package/dist/executable/executable-cache.test.js.map +1 -1
  110. package/dist/frontend/fork-target.d.ts +17 -0
  111. package/dist/frontend/fork-target.js +256 -0
  112. package/dist/frontend/fork-target.js.map +1 -0
  113. package/dist/frontend/lowering/abstract-equality.d.ts +6 -0
  114. package/dist/frontend/lowering/abstract-equality.js +250 -0
  115. package/dist/frontend/lowering/abstract-equality.js.map +1 -0
  116. package/dist/frontend/lowering/containers/bytes.d.ts +0 -4
  117. package/dist/frontend/lowering/containers/bytes.js +112 -28
  118. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  119. package/dist/frontend/lowering/lower-assert.js +87 -12
  120. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  121. package/dist/frontend/lowering/lower-builtins.d.ts +72 -44
  122. package/dist/frontend/lowering/lower-builtins.js +1323 -165
  123. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  124. package/dist/frontend/lowering/lower-calls.d.ts +37 -27
  125. package/dist/frontend/lowering/lower-calls.js +682 -132
  126. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  127. package/dist/frontend/lowering/lower-classes.js +39 -8
  128. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  129. package/dist/frontend/lowering/lower-containers.js +162 -8
  130. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  131. package/dist/frontend/lowering/lower-event-emitter.js +212 -21
  132. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  133. package/dist/frontend/lowering/lower-exprs.js +238 -87
  134. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  135. package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
  136. package/dist/frontend/lowering/lower-inspect.js +8 -1
  137. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  138. package/dist/frontend/lowering/lower-island.d.ts +6 -3
  139. package/dist/frontend/lowering/lower-island.js +165 -6
  140. package/dist/frontend/lowering/lower-island.js.map +1 -1
  141. package/dist/frontend/lowering/lower-modules.d.ts +6 -0
  142. package/dist/frontend/lowering/lower-modules.js +192 -38
  143. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  144. package/dist/frontend/lowering/lower-namespaces.js +7 -0
  145. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  146. package/dist/frontend/lowering/lower-server.d.ts +1 -1
  147. package/dist/frontend/lowering/lower-server.js +130 -27
  148. package/dist/frontend/lowering/lower-server.js.map +1 -1
  149. package/dist/frontend/lowering/lower-stmts.d.ts +5 -4
  150. package/dist/frontend/lowering/lower-stmts.js +141 -21
  151. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  152. package/dist/frontend/lowering/lower-stream.d.ts +3 -0
  153. package/dist/frontend/lowering/lower-stream.js +7 -0
  154. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  155. package/dist/frontend/lowering/lowerer.d.ts +90 -13
  156. package/dist/frontend/lowering/lowerer.js +416 -76
  157. package/dist/frontend/lowering/lowerer.js.map +1 -1
  158. package/dist/frontend/lowering/surfaces.d.ts +31 -3
  159. package/dist/frontend/lowering/surfaces.js +173 -90
  160. package/dist/frontend/lowering/surfaces.js.map +1 -1
  161. package/dist/frontend/npm-static-declarations.d.ts +4 -0
  162. package/dist/frontend/npm-static-declarations.js +83 -14
  163. package/dist/frontend/npm-static-declarations.js.map +1 -1
  164. package/dist/frontend/npm-static-declarations.test.js +33 -2
  165. package/dist/frontend/npm-static-declarations.test.js.map +1 -1
  166. package/dist/frontend/npm-static.js +6 -5
  167. package/dist/frontend/npm-static.js.map +1 -1
  168. package/dist/frontend/npm.d.ts +15 -3
  169. package/dist/frontend/npm.js +80 -8
  170. package/dist/frontend/npm.js.map +1 -1
  171. package/dist/frontend/npm.test.js +76 -9
  172. package/dist/frontend/npm.test.js.map +1 -1
  173. package/dist/frontend/program.js +110 -12
  174. package/dist/frontend/program.js.map +1 -1
  175. package/dist/frontend/resolve.d.ts +28 -7
  176. package/dist/frontend/resolve.js +90 -26
  177. package/dist/frontend/resolve.js.map +1 -1
  178. package/dist/frontend/resolve.test.js +21 -1
  179. package/dist/frontend/resolve.test.js.map +1 -1
  180. package/dist/frontend/type-mapper.d.ts +5 -0
  181. package/dist/frontend/type-mapper.js +115 -33
  182. package/dist/frontend/type-mapper.js.map +1 -1
  183. package/dist/index.d.ts +5 -0
  184. package/dist/index.js +30 -3
  185. package/dist/index.js.map +1 -1
  186. package/dist/ir/analysis.js +1 -0
  187. package/dist/ir/analysis.js.map +1 -1
  188. package/dist/ir/ir.d.ts +155 -66
  189. package/dist/ir/ir.js +143 -6
  190. package/dist/ir/ir.js.map +1 -1
  191. package/dist/ir/ir.test.js +14 -1
  192. package/dist/ir/ir.test.js.map +1 -1
  193. package/dist/ir/serialize.d.ts +1 -1
  194. package/dist/ir/serialize.js +1 -1
  195. package/dist/ir/serialize.js.map +1 -1
  196. package/dist/ir/validate.js +242 -18
  197. package/dist/ir/validate.js.map +1 -1
  198. package/dist/library/int-infer.test.js +4 -4
  199. package/dist/library/int-infer.test.js.map +1 -1
  200. package/dist/library/library-cache.d.ts +1 -0
  201. package/dist/library/library-cache.js +1 -0
  202. package/dist/library/library-cache.js.map +1 -1
  203. package/dist/library/library-cache.test.js +18 -5
  204. package/dist/library/library-cache.test.js.map +1 -1
  205. package/package.json +17 -17
  206. package/surface-manifest.json +163 -54
@@ -15,12 +15,15 @@ export type ParamMode = "required" | "omittable" | "rest" | "dynRest" | "islandR
15
15
  * `type` is the ABI type — what the emitted C parameter carries: the
16
16
  * checker's `T | undefined` union for `x?: T`, a synthesized `T | undefined`
17
17
  * union for `x: T = e`, `T[]` for `...xs: T[]`, the plain declared type
18
- * otherwise. `bodyType` is present exactly for DEFAULTED params: the plain T
19
- * the body sees after the prologue applies the default (see declareParams). */
18
+ * otherwise. `bodyType` is present exactly for DEFAULTED program params:
19
+ * the plain T the body sees after the prologue applies the default (see
20
+ * declareParams). `callDefault` is the compile-time default value for a
21
+ * table-backed builtin's omittable slot. */
20
22
  export interface ParamShape {
21
23
  type: IrType;
22
24
  mode: ParamMode;
23
25
  bodyType?: IrType;
26
+ callDefault?: IrExpr;
24
27
  }
25
28
  export interface FnSig {
26
29
  name: string;
@@ -41,6 +44,21 @@ export interface FnSig {
41
44
  };
42
45
  };
43
46
  }
47
+ /** The one func-type projection of completed parameter shapes. Typed rest
48
+ * parameters keep their packed array as the trailing native ABI slot and
49
+ * mark the value variadic so indirect call sites run completeArgs before
50
+ * callValue. Dynamic rest remains the historical hidden ScrDyn slot, while
51
+ * island rest spells its engine-array slot directly. */
52
+ export declare function funcTypeFromParamShapes(shapes: readonly ParamShape[], ret: IrType): IrType & {
53
+ kind: "func";
54
+ };
55
+ /** Registers `const alias = overloadedDeclaration` as a compile-time
56
+ * callable projection. The source function's one implementation ABI is
57
+ * already collected in fnSigsBySymbol; each direct call still uses the
58
+ * TS7-resolved overload result bridge. The alias owns no storage, and a
59
+ * value read materializes the source function's interned closure, so JS
60
+ * identity (`alias === source`) is preserved. */
61
+ export declare function registerOverloadedCallableAlias(lowerer: Lowerer, decl: ts.VariableDeclaration): boolean;
44
62
  export declare function generatorMeta(lowerer: Lowerer, type: IrType & {
45
63
  kind: "generator";
46
64
  }): NonNullable<IrFunction["generator"]>;
@@ -171,14 +189,6 @@ export declare function paramShapes(lowerer: Lowerer, params: readonly ts.Parame
171
189
  * defaultRunner` and `skip: Set<string> = new Set()` arm like any ref
172
190
  * kind — the nullable-callback union shape, built by the compiler. */
173
191
  export declare function checkDefaultParamBodyType(lowerer: Lowerer, param: ts.ParameterDeclaration, bodyType: IrType): void;
174
- /** CALL-SITE COMPLETION — the frontend half of the one-signature contract
175
- * (docs/ir.md): every call lowers to exactly the callee's full ABI
176
- * parameter list, so backends and the validator stay count-exact and no
177
- * runtime arity machinery exists. Omitted trailing args for omittable
178
- * params become the interned undefined arm (which is also what an
179
- * explicitly-passed `undefined` wraps to — both trigger a default, JS-
180
- * exact); a rest param packs the surplus args (possibly zero) into one
181
- * array literal, evaluated in source order at the call site. */
182
192
  export declare function completeArgs(lowerer: Lowerer, argNodes: readonly ts.Expression[], shapes: readonly ParamShape[], loc: SrcLoc, blame: ts.Node,
183
193
  /** Pre-lowered values virtually PREPENDED to the argument list — the
184
194
  * tagged-template strings object, which has no ts.Expression to lower
@@ -201,13 +211,12 @@ export declare function wrappedUndefined(lowerer: Lowerer, type: IrType, loc: Sr
201
211
  * (direct calls and calls through func-typed values). */
202
212
  export declare function omittedArgFor(lowerer: Lowerer, type: IrType, loc: SrcLoc): IrExpr | null;
203
213
  export declare function undefinedArgFor(lowerer: Lowerer, type: IrType, loc: SrcLoc, blame: ts.Node): IrExpr;
204
- /** DECISION (docs/ir.md): function VALUES keep exact-arity semantics — a
205
- * func-typed IrType spells one completed signature, so a function whose
206
- * declaration has optional/default/rest parameters can become a value only
207
- * where the target type spells that exact signature with required
208
- * parameters (`x?: T` / `x: T = e` params appear as literal `T | undefined`
209
- * unions; a rest signature is never spellable without `...`, which func
210
- * types reject). Direct calls get the full feature. */
214
+ /** DECISION (docs/ir.md): function VALUES carry one completed native ABI.
215
+ * Optional/default parameters appear as literal `T | undefined` slots;
216
+ * typed rest parameters appear as one trailing typed-array slot plus the
217
+ * typed-rest marker that makes indirect call sites pack source arguments.
218
+ * A value is admitted only where its target type projects to that same
219
+ * completed signature. */
211
220
  export declare function requireExactArityValue(lowerer: Lowerer, blame: ts.Node, contextual: ts.Expression | null, shapes: readonly ParamShape[], funcType: IrType): void;
212
221
  /** The BODY-facing return type of a (possibly async) function: an async
213
222
  * body's `return v` fulfills its promise with v, so the body returns the
@@ -394,18 +403,19 @@ export declare function lowerTaggedTemplate(lowerer: Lowerer, expr: ts.TaggedTem
394
403
  * FLATTENED namespace block count — splitFiles hoisted them into the
395
404
  * same collection lists top-level declarations ride. */
396
405
  export declare function isTopLevelFnSymbol(lowerer: Lowerer, ident: ts.Identifier): boolean;
397
- /** Nested `function name(...) {...}`: lowered as `const name = <lambda>`
398
- * at the declaration's statement position (JS hoists function declarations
399
- * to the top of the enclosing function — calling one before this statement
400
- * is a compile error here, not a silent divergence). Self-references inside
401
- * the body lower to `selfRef`, not a capture: a box holding its own
402
- * closure would be an RC cycle. */
406
+ /** Nested `function name(...) {...}`: declare the mutable function binding
407
+ * before lowering its body, then initialize it with the lifted closure.
408
+ * The early declaration is observable only when another nested closure
409
+ * captures the binding: its box must exist before either side of a mutual
410
+ * recursion cycle builds its closure. Forward source references use the
411
+ * same split declaration/assignment through predeclareForwardFnDecl.
412
+ * Self-references inside the body lower to `selfRef`, not a capture: a box
413
+ * holding its own closure would be an RC cycle. */
403
414
  export declare function lowerNestedFunctionDecl(lowerer: Lowerer, stmt: ts.FunctionDeclaration): IrStmt;
404
415
  /** Signature checks + param shapes + IR func type for any lambda-like
405
- * node. The func type's params are the ABI types, so a lambda with
406
- * optional/default params has the same IR type as one spelling the
407
- * `T | undefined` unions with required params — exactly the exact-arity
408
- * value rule (requireExactArityValue decides who may become a value). */
416
+ * node. The func type's params are the ABI types: optional/default params
417
+ * become `T | undefined`, and typed rest becomes one packed-array slot.
418
+ * requireExactArityValue decides whether that completed ABI may escape. */
409
419
  export declare function lambdaSignature(lowerer: Lowerer, node: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration | ts.MethodDeclaration | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration): {
410
420
  shapes: ParamShape[];
411
421
  funcType: IrType & {