@scriptc/compiler 0.3.3 → 0.3.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 (213) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +713 -26
  2. package/dist/backend/cycle-mutability.d.ts +5 -0
  3. package/dist/backend/cycle-mutability.js +62 -3
  4. package/dist/backend/cycle-mutability.js.map +1 -1
  5. package/dist/backend/executable-features.js +1 -0
  6. package/dist/backend/executable-features.js.map +1 -1
  7. package/dist/backend/library-pack.js +1 -0
  8. package/dist/backend/library-pack.js.map +1 -1
  9. package/dist/backend/llvm/call-lifetimes.d.ts +5 -1
  10. package/dist/backend/llvm/call-lifetimes.js +11 -3
  11. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  12. package/dist/backend/llvm/call-lifetimes.test.js +31 -1
  13. package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
  14. package/dist/backend/llvm/common.d.ts +5 -0
  15. package/dist/backend/llvm/common.js +7 -0
  16. package/dist/backend/llvm/common.js.map +1 -1
  17. package/dist/backend/llvm/dense-array-access.js +2 -2
  18. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  19. package/dist/backend/llvm/dyn.d.ts +40 -1
  20. package/dist/backend/llvm/dyn.js +178 -27
  21. package/dist/backend/llvm/dyn.js.map +1 -1
  22. package/dist/backend/llvm/emitter.d.ts +12 -0
  23. package/dist/backend/llvm/emitter.js +164 -27
  24. package/dist/backend/llvm/emitter.js.map +1 -1
  25. package/dist/backend/llvm/expr-bytes.d.ts +9 -0
  26. package/dist/backend/llvm/expr-bytes.js +158 -63
  27. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  28. package/dist/backend/llvm/expr-calls.d.ts +3 -1
  29. package/dist/backend/llvm/expr-calls.js +49 -1
  30. package/dist/backend/llvm/expr-calls.js.map +1 -1
  31. package/dist/backend/llvm/expr-containers.js +16 -5
  32. package/dist/backend/llvm/expr-containers.js.map +1 -1
  33. package/dist/backend/llvm/intern-tables.test.d.ts +1 -0
  34. package/dist/backend/llvm/intern-tables.test.js +77 -0
  35. package/dist/backend/llvm/intern-tables.test.js.map +1 -0
  36. package/dist/backend/llvm/lib-datagram.js +10 -0
  37. package/dist/backend/llvm/lib-datagram.js.map +1 -1
  38. package/dist/backend/llvm/lib-dispatch.js +92 -1
  39. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  40. package/dist/backend/llvm/lib-filesystem.js +51 -0
  41. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  42. package/dist/backend/llvm/lib-network.js +16 -0
  43. package/dist/backend/llvm/lib-network.js.map +1 -1
  44. package/dist/backend/llvm/lib-shared.d.ts +5 -0
  45. package/dist/backend/llvm/lib-shared.js +80 -1
  46. package/dist/backend/llvm/lib-shared.js.map +1 -1
  47. package/dist/backend/llvm/lib-stream.js +87 -0
  48. package/dist/backend/llvm/lib-stream.js.map +1 -1
  49. package/dist/backend/llvm/lib-test.js +9 -0
  50. package/dist/backend/llvm/lib-test.js.map +1 -1
  51. package/dist/backend/llvm/map-number-lookup.d.ts +4 -0
  52. package/dist/backend/llvm/map-number-lookup.js +22 -0
  53. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  54. package/dist/backend/llvm/map-number-lookup.test.js +56 -0
  55. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  56. package/dist/backend/llvm/map-read-lifetimes.d.ts +9 -0
  57. package/dist/backend/llvm/map-read-lifetimes.js +89 -1
  58. package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
  59. package/dist/backend/llvm/map-read-lifetimes.test.js +129 -1
  60. package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
  61. package/dist/backend/llvm/publish.d.ts +5 -0
  62. package/dist/backend/llvm/publish.js +22 -3
  63. package/dist/backend/llvm/publish.js.map +1 -1
  64. package/dist/backend/llvm/reference-writes.js +5 -2
  65. package/dist/backend/llvm/reference-writes.js.map +1 -1
  66. package/dist/backend/llvm/regions.d.ts +4 -1
  67. package/dist/backend/llvm/regions.js +12 -3
  68. package/dist/backend/llvm/regions.js.map +1 -1
  69. package/dist/backend/llvm/string-reads.js +2 -2
  70. package/dist/backend/llvm/string-reads.js.map +1 -1
  71. package/dist/backend/llvm/string-slices.js +2 -2
  72. package/dist/backend/llvm/string-slices.js.map +1 -1
  73. package/dist/backend/may-throw.js +4 -0
  74. package/dist/backend/may-throw.js.map +1 -1
  75. package/dist/backend/native/contracts.d.ts +3 -0
  76. package/dist/backend/native/executable.js +13 -5
  77. package/dist/backend/native/executable.js.map +1 -1
  78. package/dist/backend/native/runtime-inputs.d.ts +1 -1
  79. package/dist/backend/native/runtime-inputs.js +1 -0
  80. package/dist/backend/native/runtime-inputs.js.map +1 -1
  81. package/dist/backend/native-codegen-core.d.ts +4 -4
  82. package/dist/backend/native-codegen-core.js +4 -6
  83. package/dist/backend/native-codegen-core.js.map +1 -1
  84. package/dist/backend/native-codegen.test.js +7 -8
  85. package/dist/backend/native-codegen.test.js.map +1 -1
  86. package/dist/backend/native-link-info-core.d.ts +3 -0
  87. package/dist/backend/native-link-info-core.js.map +1 -1
  88. package/dist/backend/publication.js +3 -1
  89. package/dist/backend/publication.js.map +1 -1
  90. package/dist/backend/runtime-pack-targets.test.js +1 -0
  91. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  92. package/dist/backend/runtime-pack.test.js +1 -0
  93. package/dist/backend/runtime-pack.test.js.map +1 -1
  94. package/dist/backend/target-diagnostics.js +7 -0
  95. package/dist/backend/target-diagnostics.js.map +1 -1
  96. package/dist/backend/warm-cache.js +1 -0
  97. package/dist/backend/warm-cache.js.map +1 -1
  98. package/dist/executable/executable-cache.d.ts +1 -0
  99. package/dist/executable/executable-cache.js +1 -0
  100. package/dist/executable/executable-cache.js.map +1 -1
  101. package/dist/executable/executable-cache.test.js +1 -0
  102. package/dist/executable/executable-cache.test.js.map +1 -1
  103. package/dist/frontend/experimental-import.d.ts +5 -1
  104. package/dist/frontend/experimental-import.js +28 -3
  105. package/dist/frontend/experimental-import.js.map +1 -1
  106. package/dist/frontend/lowering/assert-instances.d.ts +38 -0
  107. package/dist/frontend/lowering/assert-instances.js +269 -0
  108. package/dist/frontend/lowering/assert-instances.js.map +1 -0
  109. package/dist/frontend/lowering/builtins/compression.d.ts +18 -0
  110. package/dist/frontend/lowering/builtins/compression.js +175 -2
  111. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  112. package/dist/frontend/lowering/builtins/constants.js +7 -2
  113. package/dist/frontend/lowering/builtins/constants.js.map +1 -1
  114. package/dist/frontend/lowering/builtins/crypto.d.ts +6 -0
  115. package/dist/frontend/lowering/builtins/crypto.js +111 -1
  116. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  117. package/dist/frontend/lowering/builtins/errors.js +23 -0
  118. package/dist/frontend/lowering/builtins/errors.js.map +1 -1
  119. package/dist/frontend/lowering/builtins/timers.d.ts +3 -0
  120. package/dist/frontend/lowering/builtins/timers.js +109 -23
  121. package/dist/frontend/lowering/builtins/timers.js.map +1 -1
  122. package/dist/frontend/lowering/call-signatures.js +6 -0
  123. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  124. package/dist/frontend/lowering/class-dynamic-dispatch.js +66 -12
  125. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  126. package/dist/frontend/lowering/intern-tables.d.ts +13 -0
  127. package/dist/frontend/lowering/intern-tables.js +536 -0
  128. package/dist/frontend/lowering/intern-tables.js.map +1 -0
  129. package/dist/frontend/lowering/lower-assert.js +700 -61
  130. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  131. package/dist/frontend/lowering/lower-async-iteration.js +11 -2
  132. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  133. package/dist/frontend/lowering/lower-calls.js +17 -3
  134. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  135. package/dist/frontend/lowering/lower-classes.d.ts +3 -0
  136. package/dist/frontend/lowering/lower-classes.js +36 -0
  137. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  138. package/dist/frontend/lowering/lower-dgram.js +77 -52
  139. package/dist/frontend/lowering/lower-dgram.js.map +1 -1
  140. package/dist/frontend/lowering/lower-exprs.js +12 -0
  141. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  142. package/dist/frontend/lowering/lower-inspect.d.ts +6 -0
  143. package/dist/frontend/lowering/lower-inspect.js +112 -39
  144. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  145. package/dist/frontend/lowering/lower-mock.d.ts +11 -0
  146. package/dist/frontend/lowering/lower-mock.js +504 -0
  147. package/dist/frontend/lowering/lower-mock.js.map +1 -0
  148. package/dist/frontend/lowering/lower-modules.js +7 -0
  149. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  150. package/dist/frontend/lowering/lower-server.d.ts +3 -0
  151. package/dist/frontend/lowering/lower-server.js +380 -30
  152. package/dist/frontend/lowering/lower-server.js.map +1 -1
  153. package/dist/frontend/lowering/lower-stmts.js +23 -2
  154. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  155. package/dist/frontend/lowering/lower-stream.d.ts +10 -6
  156. package/dist/frontend/lowering/lower-stream.js +786 -27
  157. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  158. package/dist/frontend/lowering/lower-test.js +86 -8
  159. package/dist/frontend/lowering/lower-test.js.map +1 -1
  160. package/dist/frontend/lowering/lowerer.d.ts +22 -0
  161. package/dist/frontend/lowering/lowerer.js +72 -7
  162. package/dist/frontend/lowering/lowerer.js.map +1 -1
  163. package/dist/frontend/lowering/pairs-snapshot.d.ts +6 -0
  164. package/dist/frontend/lowering/pairs-snapshot.js +49 -0
  165. package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
  166. package/dist/frontend/lowering/surfaces.d.ts +4 -0
  167. package/dist/frontend/lowering/surfaces.js +61 -15
  168. package/dist/frontend/lowering/surfaces.js.map +1 -1
  169. package/dist/frontend/lowering/zlib-constants.d.ts +1 -0
  170. package/dist/frontend/lowering/zlib-constants.js +181 -0
  171. package/dist/frontend/lowering/zlib-constants.js.map +1 -0
  172. package/dist/frontend/mock-shapes.d.ts +10 -0
  173. package/dist/frontend/mock-shapes.js +76 -0
  174. package/dist/frontend/mock-shapes.js.map +1 -0
  175. package/dist/frontend/pipeline.js +5 -3
  176. package/dist/frontend/pipeline.js.map +1 -1
  177. package/dist/frontend/program.js +6 -1
  178. package/dist/frontend/program.js.map +1 -1
  179. package/dist/frontend/resolve.d.ts +4 -0
  180. package/dist/frontend/resolve.js +14 -0
  181. package/dist/frontend/resolve.js.map +1 -1
  182. package/dist/frontend/tsc-codes.js +1 -0
  183. package/dist/frontend/tsc-codes.js.map +1 -1
  184. package/dist/frontend/type-mapper.d.ts +5 -0
  185. package/dist/frontend/type-mapper.js +102 -9
  186. package/dist/frontend/type-mapper.js.map +1 -1
  187. package/dist/index.js +2 -1
  188. package/dist/index.js.map +1 -1
  189. package/dist/ir/builtin-effects.js +36 -0
  190. package/dist/ir/builtin-effects.js.map +1 -1
  191. package/dist/ir/builtin-signatures.d.ts +1 -1
  192. package/dist/ir/builtin-signatures.js +147 -8
  193. package/dist/ir/builtin-signatures.js.map +1 -1
  194. package/dist/ir/ir.d.ts +20 -1
  195. package/dist/ir/ir.js +17 -0
  196. package/dist/ir/ir.js.map +1 -1
  197. package/dist/ir/runtime-features.d.ts +1 -0
  198. package/dist/ir/runtime-features.js +29 -2
  199. package/dist/ir/runtime-features.js.map +1 -1
  200. package/dist/ir/validate.js +195 -5
  201. package/dist/ir/validate.js.map +1 -1
  202. package/dist/library/ir-policy.js +1 -0
  203. package/dist/library/ir-policy.js.map +1 -1
  204. package/dist/native/cli.js +1 -0
  205. package/dist/native/cli.js.map +1 -1
  206. package/dist/native/compiler.js +1 -3
  207. package/dist/native/compiler.js.map +1 -1
  208. package/dist/native/prepare.js +1 -0
  209. package/dist/native/prepare.js.map +1 -1
  210. package/dist/native/sanitizer.test.js +1 -0
  211. package/dist/native/sanitizer.test.js.map +1 -1
  212. package/package.json +20 -20
  213. package/surface-manifest.json +869 -48
@@ -0,0 +1,504 @@
1
+ /* node:test's mock functions (Node 24.22, lib/internal/test_runner/mock):
2
+ * mock.fn and t.mock.fn, and the fn.mock context's calls, callCount,
3
+ * mockImplementation, mockImplementationOnce, resetCalls and restore.
4
+ *
5
+ * mock.fn(original, implementation?) lowers to the hybrid record
6
+ * { %call: wrapper, mock: context } (mock-shapes.ts). The wrapper is a
7
+ * closure over the context, lifted once per context type: it takes the
8
+ * one-time implementation registered for this call index, or the current
9
+ * one, calls it, and appends { arguments, error, result, this } to the
10
+ * calls log before returning or rethrowing. The context's mutating
11
+ * methods are lifted helpers of the same type. */
12
+ import * as ts from "../ts7/adapter.js";
13
+ import { BOOL, CAUGHT, DYN, F64, UNDEFINED_T, VOID, typeKey, } from "../../ir/ir.js";
14
+ import { countedFor, dynUndefinedExpr, numLit, varRef } from "../../ir/build.js";
15
+ import { locOf } from "../program.js";
16
+ /** The context record's parts, or null when `type` is not a mock context
17
+ * (mock-shapes.ts). */
18
+ function mockContextFields(lowerer, type) {
19
+ if (type.kind !== "record")
20
+ return null;
21
+ const shape = lowerer.shapes.get(type.shapeId);
22
+ const field = (name) => shape?.fields.find((f) => f.name === name)?.type;
23
+ const impl = field("%impl");
24
+ const once = field("%once");
25
+ const calls = field("calls");
26
+ if (impl?.kind !== "func" ||
27
+ once?.kind !== "array" ||
28
+ calls?.kind !== "array" ||
29
+ field("%original") === undefined)
30
+ return null;
31
+ const call = calls.elem;
32
+ const callShape = call.kind === "record" ? lowerer.shapes.get(call.shapeId) : undefined;
33
+ const result = callShape?.fields.find((f) => f.name === "result")?.type;
34
+ const args = callShape?.fields.find((f) => f.name === "arguments")?.type;
35
+ if (!result || !args)
36
+ return null;
37
+ return { fn: impl, call, calls, once, onceEntry: once.elem, result, args };
38
+ }
39
+ export function isMockContextType(lowerer, type) {
40
+ return mockContextFields(lowerer, type) !== null;
41
+ }
42
+ const recordGet = (obj, field, type, loc) => ({
43
+ kind: "recordGet",
44
+ obj,
45
+ shapeId: obj.type.shapeId,
46
+ field,
47
+ type,
48
+ loc,
49
+ });
50
+ const recordSet = (obj, field, value, loc) => ({
51
+ kind: "recordSet",
52
+ obj,
53
+ shapeId: obj.type.shapeId,
54
+ field,
55
+ value,
56
+ loc,
57
+ });
58
+ const length = (arr, loc) => ({
59
+ kind: "arrIntrinsic",
60
+ method: "length",
61
+ receiver: arr,
62
+ args: [],
63
+ type: F64,
64
+ loc,
65
+ });
66
+ const local = (id, name, type, mutable = false) => ({
67
+ id,
68
+ name,
69
+ type,
70
+ mutable,
71
+ });
72
+ /** Lifts one function per (context type, role), cached on the lowerer. */
73
+ function liftOnce(lowerer, ctxType, role, build) {
74
+ const key = `mock.${role}:${ctxType.shapeId}`;
75
+ const existing = lowerer.assertHelpers.get(key);
76
+ if (existing)
77
+ return existing;
78
+ const name = `%mock.${role}.${lowerer.assertHelpers.size}`;
79
+ lowerer.assertHelpers.set(key, name);
80
+ build(name);
81
+ return name;
82
+ }
83
+ /** `%mock.wrap.N(ctx)`: the closure that records each call into ctx. */
84
+ function mockWrapperFactory(lowerer, ctxType, loc) {
85
+ return liftOnce(lowerer, ctxType, "wrap", (name) => {
86
+ const { fn, call, calls, once, onceEntry, result, args } = mockContextFields(lowerer, ctxType);
87
+ const impl = `${name}.impl`;
88
+ const ctx = () => varRef("ctx.0", ctxType, loc);
89
+ const params = fn.params.map((type, i) => ({ localId: `p${i}.0`, name: `p${i}`, type }));
90
+ const paramRefs = () => params.map((p) => varRef(p.localId, p.type, loc));
91
+ const argumentsValue = () => fn.rest
92
+ ? paramRefs()[0]
93
+ : {
94
+ kind: "recordLit",
95
+ fields: paramRefs().map((value, i) => ({ name: String(i), value })),
96
+ type: args,
97
+ loc,
98
+ };
99
+ const record = (resultValue, error) => ({
100
+ kind: "exprStmt",
101
+ expr: {
102
+ kind: "arrIntrinsic",
103
+ method: "push",
104
+ receiver: recordGet(ctx(), "calls", calls, loc),
105
+ args: [
106
+ {
107
+ kind: "recordLit",
108
+ fields: [
109
+ { name: "arguments", value: argumentsValue() },
110
+ { name: "error", value: error },
111
+ { name: "result", value: resultValue },
112
+ { name: "this", value: dynUndefinedExpr(loc) },
113
+ ],
114
+ type: call,
115
+ loc,
116
+ },
117
+ ],
118
+ type: F64,
119
+ loc,
120
+ },
121
+ loc,
122
+ });
123
+ const voidReturn = fn.ret.kind === "void" || fn.ret.kind === "undefinedT";
124
+ // The result slot: a checked-dynamic undefined for void functions, R
125
+ // when R already admits undefined, else the `R | undefined` union.
126
+ const asResult = (value) => {
127
+ if (result.kind === "dyn")
128
+ return dynUndefinedExpr(loc);
129
+ if (value !== null && result.kind === "union" && value.type.kind !== "union")
130
+ return {
131
+ kind: "unionWrap",
132
+ unionId: result.unionId,
133
+ tag: lowerer.armTag(result.unionId, value.type),
134
+ value,
135
+ type: result,
136
+ loc,
137
+ };
138
+ if (value !== null)
139
+ return value;
140
+ const unionId = result.unionId;
141
+ return {
142
+ kind: "unionWrap",
143
+ unionId,
144
+ tag: lowerer.armTag(unionId, UNDEFINED_T),
145
+ value: { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc },
146
+ type: result,
147
+ loc,
148
+ };
149
+ };
150
+ const invoke = {
151
+ kind: "callValue",
152
+ callee: varRef("f.0", fn, loc),
153
+ args: paramRefs(),
154
+ type: fn.ret,
155
+ loc,
156
+ };
157
+ const tryBody = voidReturn
158
+ ? [
159
+ { kind: "exprStmt", expr: invoke, loc },
160
+ record(asResult(null), dynUndefinedExpr(loc)),
161
+ { kind: "return", value: null, loc },
162
+ ]
163
+ : [
164
+ { kind: "varDecl", localId: "r.0", init: invoke, loc },
165
+ record(asResult(varRef("r.0", fn.ret, loc)), dynUndefinedExpr(loc)),
166
+ { kind: "return", value: varRef("r.0", fn.ret, loc), loc },
167
+ ];
168
+ const catchBody = [
169
+ record(asResult(null), {
170
+ kind: "caughtToDyn",
171
+ value: varRef("e.0", CAUGHT, loc),
172
+ type: DYN,
173
+ loc,
174
+ }),
175
+ { kind: "rethrow", localId: "e.0", loc },
176
+ ];
177
+ const onceArray = () => recordGet(ctx(), "%once", once, loc);
178
+ const entry = (j) => ({
179
+ kind: "arrayGet",
180
+ arr: onceArray(),
181
+ index: j,
182
+ type: onceEntry,
183
+ loc,
184
+ });
185
+ // The one-time implementation for this call index, used once.
186
+ const pickOnce = countedFor(loc, length(onceArray(), loc), (j) => [
187
+ {
188
+ kind: "if",
189
+ cond: {
190
+ kind: "bin",
191
+ op: "===",
192
+ left: recordGet(entry(j), "at", F64, loc),
193
+ right: varRef("n.0", F64, loc),
194
+ type: BOOL,
195
+ loc,
196
+ },
197
+ then: [
198
+ { kind: "assign", localId: "f.0", value: recordGet(entry(j), "fn", fn, loc), loc },
199
+ {
200
+ kind: "exprStmt",
201
+ expr: {
202
+ kind: "arrIntrinsic",
203
+ method: "splice",
204
+ receiver: onceArray(),
205
+ args: [j, numLit(1, loc)],
206
+ type: once,
207
+ loc,
208
+ },
209
+ loc,
210
+ },
211
+ ],
212
+ else_: null,
213
+ loc,
214
+ },
215
+ ]);
216
+ lowerer.liftedFns.push({
217
+ name: impl,
218
+ params,
219
+ returnType: fn.ret,
220
+ captures: [{ localId: "ctx.0", name: "ctx", type: ctxType }],
221
+ locals: [
222
+ ...params.map((p) => local(p.localId, p.name, p.type)),
223
+ { ...local("ctx.0", "ctx", ctxType), boxed: true },
224
+ local("n.0", "index", F64),
225
+ local("f.0", "implementation", fn, true),
226
+ local("i.0", "entry", F64, true),
227
+ ...(voidReturn ? [] : [local("r.0", "result", fn.ret)]),
228
+ local("e.0", "error", CAUGHT),
229
+ ],
230
+ body: [
231
+ {
232
+ kind: "varDecl",
233
+ localId: "n.0",
234
+ init: length(recordGet(ctx(), "calls", calls, loc), loc),
235
+ loc,
236
+ },
237
+ { kind: "varDecl", localId: "f.0", init: recordGet(ctx(), "%impl", fn, loc), loc },
238
+ pickOnce,
239
+ { kind: "tryCatch", tryBody, catchBody, catchLocalId: "e.0", finallyBody: null, loc },
240
+ ],
241
+ loc,
242
+ });
243
+ lowerer.liftedFns.push({
244
+ name,
245
+ params: [{ localId: "ctx.0", name: "ctx", type: ctxType }],
246
+ returnType: fn,
247
+ locals: [{ ...local("ctx.0", "ctx", ctxType), boxed: true }],
248
+ body: [
249
+ {
250
+ kind: "return",
251
+ value: { kind: "closure", fnName: impl, captures: ["ctx.0"], type: fn, loc },
252
+ loc,
253
+ },
254
+ ],
255
+ loc,
256
+ });
257
+ });
258
+ }
259
+ /** A VOID helper over the context: `%mock.<role>.N(ctx, ...extra)`. */
260
+ function mockHelper(lowerer, ctxType, role, extra, body, loc) {
261
+ return liftOnce(lowerer, ctxType, role, (name) => {
262
+ const ctx = () => varRef("ctx.0", ctxType, loc);
263
+ lowerer.liftedFns.push({
264
+ name,
265
+ params: [
266
+ { localId: "ctx.0", name: "ctx", type: ctxType },
267
+ ...extra.map((e) => ({ localId: e.id, name: e.name, type: e.type })),
268
+ ],
269
+ returnType: VOID,
270
+ locals: [
271
+ local("ctx.0", "ctx", ctxType),
272
+ ...extra.map((e) => local(e.id, e.name, e.type, true)),
273
+ local("i.0", "entry", F64, true),
274
+ ],
275
+ body: [...body(ctx, loc), { kind: "return", value: null, loc }],
276
+ loc,
277
+ });
278
+ });
279
+ }
280
+ /** mock.fn(original, implementation?) and t.mock.fn(...). */
281
+ export function lowerMockFn(lowerer, call, what) {
282
+ const loc = locOf(call);
283
+ const mockType = lowerer.mapTypeOf(lowerer.typeOf(call));
284
+ const shape = mockType?.kind === "record" ? lowerer.shapes.get(mockType.shapeId) : undefined;
285
+ const ctxType = shape?.fields.find((f) => f.name === "mock")?.type;
286
+ if (!mockType ||
287
+ !shape ||
288
+ shape.fields.length !== 2 ||
289
+ !shape.fields.some((f) => f.name === "%call") ||
290
+ !ctxType ||
291
+ !isMockContextType(lowerer, ctxType)) {
292
+ lowerer.noLowering(`${what} of this function type`, call, "mock functions lower for functions with fixed parameters, or a single rest array parameter");
293
+ }
294
+ const { fn, calls, once, result } = mockContextFields(lowerer, ctxType);
295
+ if (fn.ret.kind === "union" && typeKey(result) !== typeKey(fn.ret)) {
296
+ lowerer.noLowering(`${what} of a function returning '${lowerer.fmt(fn.ret)}'`, call, "a union return type needs an undefined arm here (the calls log records undefined for calls that throw)");
297
+ }
298
+ const args = call.arguments;
299
+ if (args.length === 0 || args.length > 2 || args.some(ts.isSpreadElement)) {
300
+ lowerer.noLowering(`${what} with ${args.length} arguments`, call, "the supported forms are mock.fn(original) and mock.fn(original, implementation); mock.fn() and mock options have no lowering");
301
+ }
302
+ const stmts = [];
303
+ const originalLocal = lowerer.declareHiddenLocal("%mockOriginal", fn);
304
+ stmts.push({
305
+ kind: "varDecl",
306
+ localId: originalLocal.id,
307
+ init: lowerer.lowerExprExpecting(args[0], fn),
308
+ loc,
309
+ });
310
+ const implementation = args.length === 2
311
+ ? lowerer.lowerExprExpecting(args[1], fn)
312
+ : varRef(originalLocal.id, fn, loc);
313
+ const ctxLocal = lowerer.declareHiddenLocal("%mockContext", ctxType);
314
+ stmts.push({
315
+ kind: "varDecl",
316
+ localId: ctxLocal.id,
317
+ init: {
318
+ kind: "recordLit",
319
+ fields: [
320
+ { name: "%impl", value: implementation },
321
+ { name: "%once", value: { kind: "arrayLit", elems: [], type: once, loc } },
322
+ { name: "%original", value: varRef(originalLocal.id, fn, loc) },
323
+ { name: "calls", value: { kind: "arrayLit", elems: [], type: calls, loc } },
324
+ ],
325
+ type: ctxType,
326
+ loc,
327
+ },
328
+ loc,
329
+ });
330
+ const factory = mockWrapperFactory(lowerer, ctxType, loc);
331
+ return {
332
+ kind: "seqExpr",
333
+ stmts,
334
+ result: {
335
+ kind: "recordLit",
336
+ fields: [
337
+ {
338
+ name: "%call",
339
+ value: {
340
+ kind: "call",
341
+ callee: factory,
342
+ args: [varRef(ctxLocal.id, ctxType, loc)],
343
+ type: fn,
344
+ loc,
345
+ },
346
+ },
347
+ { name: "mock", value: varRef(ctxLocal.id, ctxType, loc) },
348
+ ],
349
+ type: mockType,
350
+ loc,
351
+ },
352
+ type: mockType,
353
+ loc,
354
+ };
355
+ }
356
+ /** `fn.mock.calls`: a copy of the log, as Node's getter returns. Null for
357
+ * other reads. */
358
+ export function lowerMockContextProperty(lowerer, expr) {
359
+ if (expr.questionDotToken || expr.name.text !== "calls")
360
+ return null;
361
+ const receiverType = lowerer.mapTypeOf(lowerer.typeOf(expr.expression));
362
+ if (!receiverType || !isMockContextType(lowerer, receiverType))
363
+ return null;
364
+ const { calls } = mockContextFields(lowerer, receiverType);
365
+ const loc = locOf(expr);
366
+ return {
367
+ kind: "arrIntrinsic",
368
+ method: "slice",
369
+ receiver: recordGet(lowerer.lowerExpr(expr.expression), "calls", calls, loc),
370
+ args: [],
371
+ type: calls,
372
+ loc,
373
+ };
374
+ }
375
+ /** The fn.mock context's methods. Null for other receivers. */
376
+ export function lowerMockContextCall(lowerer, call, access) {
377
+ const ctxType = lowerer.mapTypeOf(lowerer.typeOf(access.expression));
378
+ if (!ctxType || !isMockContextType(lowerer, ctxType))
379
+ return null;
380
+ const { fn, calls, once, onceEntry } = mockContextFields(lowerer, ctxType);
381
+ const loc = locOf(call);
382
+ const member = access.name.text;
383
+ const args = call.arguments;
384
+ const arity = (min, max = min) => {
385
+ if (args.length < min || args.length > max || args.some(ts.isSpreadElement))
386
+ lowerer.noLowering(`MockFunctionContext.${member} with ${args.length} arguments`, call);
387
+ };
388
+ const helperCall = (helper, extra) => ({
389
+ kind: "call",
390
+ callee: helper,
391
+ args: [lowerer.lowerExpr(access.expression), ...extra],
392
+ type: VOID,
393
+ loc,
394
+ });
395
+ switch (member) {
396
+ case "callCount":
397
+ arity(0);
398
+ return length(recordGet(lowerer.lowerExpr(access.expression), "calls", calls, loc), loc);
399
+ case "mockImplementation": {
400
+ arity(1);
401
+ const helper = mockHelper(lowerer, ctxType, "setImplementation", [{ id: "f.0", name: "implementation", type: fn }], (ctx) => [recordSet(ctx(), "%impl", varRef("f.0", fn, loc), loc)], loc);
402
+ return helperCall(helper, [lowerer.lowerExprExpecting(args[0], fn)]);
403
+ }
404
+ case "mockImplementationOnce": {
405
+ arity(1, 2);
406
+ // onCall defaults to the next call: the log's length (NaN marks the
407
+ // default). A later registration for the same index replaces it, as
408
+ // Node's Map does.
409
+ const helper = mockHelper(lowerer, ctxType, "setImplementationOnce", [
410
+ { id: "f.0", name: "implementation", type: fn },
411
+ { id: "at.0", name: "onCall", type: F64 },
412
+ ], (ctx) => {
413
+ const at = () => varRef("at.0", F64, loc);
414
+ const onceArray = () => recordGet(ctx(), "%once", once, loc);
415
+ return [
416
+ {
417
+ kind: "if",
418
+ cond: { kind: "bin", op: "!==", left: at(), right: at(), type: BOOL, loc },
419
+ then: [
420
+ {
421
+ kind: "assign",
422
+ localId: "at.0",
423
+ value: length(recordGet(ctx(), "calls", calls, loc), loc),
424
+ loc,
425
+ },
426
+ ],
427
+ else_: null,
428
+ loc,
429
+ },
430
+ countedFor(loc, length(onceArray(), loc), (j) => [
431
+ {
432
+ kind: "if",
433
+ cond: {
434
+ kind: "bin",
435
+ op: "===",
436
+ left: recordGet({ kind: "arrayGet", arr: onceArray(), index: j, type: onceEntry, loc }, "at", F64, loc),
437
+ right: at(),
438
+ type: BOOL,
439
+ loc,
440
+ },
441
+ then: [
442
+ {
443
+ kind: "exprStmt",
444
+ expr: {
445
+ kind: "arrIntrinsic",
446
+ method: "splice",
447
+ receiver: onceArray(),
448
+ args: [j, numLit(1, loc)],
449
+ type: once,
450
+ loc,
451
+ },
452
+ loc,
453
+ },
454
+ ],
455
+ else_: null,
456
+ loc,
457
+ },
458
+ ]),
459
+ {
460
+ kind: "exprStmt",
461
+ expr: {
462
+ kind: "arrIntrinsic",
463
+ method: "push",
464
+ receiver: onceArray(),
465
+ args: [
466
+ {
467
+ kind: "recordLit",
468
+ fields: [
469
+ { name: "at", value: at() },
470
+ { name: "fn", value: varRef("f.0", fn, loc) },
471
+ ],
472
+ type: onceEntry,
473
+ loc,
474
+ },
475
+ ],
476
+ type: F64,
477
+ loc,
478
+ },
479
+ loc,
480
+ },
481
+ ];
482
+ }, loc);
483
+ return helperCall(helper, [
484
+ lowerer.lowerExprExpecting(args[0], fn),
485
+ args.length === 2 ? lowerer.lowerExprExpecting(args[1], F64) : numLit(NaN, loc),
486
+ ]);
487
+ }
488
+ case "resetCalls": {
489
+ arity(0);
490
+ const helper = mockHelper(lowerer, ctxType, "resetCalls", [], (ctx) => [
491
+ recordSet(ctx(), "calls", { kind: "arrayLit", elems: [], type: calls, loc }, loc),
492
+ ], loc);
493
+ return helperCall(helper, []);
494
+ }
495
+ case "restore": {
496
+ arity(0);
497
+ const helper = mockHelper(lowerer, ctxType, "restore", [], (ctx) => [recordSet(ctx(), "%impl", recordGet(ctx(), "%original", fn, loc), loc)], loc);
498
+ return helperCall(helper, []);
499
+ }
500
+ default:
501
+ return lowerer.noLowering(`MockFunctionContext.${member}`, call, "calls, callCount, mockImplementation, mockImplementationOnce, resetCalls and restore are the supported mock context members");
502
+ }
503
+ }
504
+ //# sourceMappingURL=lower-mock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lower-mock.js","sourceRoot":"","sources":["../../../src/frontend/lowering/lower-mock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;kDAUkD;AAClD,OAAO,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EACL,IAAI,EACJ,MAAM,EACN,GAAG,EACH,GAAG,EACH,WAAW,EACX,IAAI,EACJ,OAAO,GAMR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAetC;uBACuB;AACvB,SAAS,iBAAiB,CAAC,OAAgB,EAAE,IAAY;IACvD,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,IAA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AO,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;QACD,KAAK,SAAS,EAAE,CAAC;YACf,KAAK,CAAC,CAAC,CAAC,CAAC;YACT,MAAM,MAAM,GAAG,UAAU,CACvB,OAAO,EACP,OAAO,EACP,SAAS,EACT,EAAE,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,EACjF,GAAG,CACJ,CAAC;YACF,OAAO,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;QACD;YACE,OAAO,OAAO,CAAC,UAAU,CACvB,uBAAuB,MAAM,EAAE,EAC/B,IAAI,EACJ,6HAA6H,CAC9H,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -28,6 +28,7 @@ import { funcTypeFromParamShapes, registerOverloadedCallableAlias } from "./call
28
28
  import { jsBindingHasOpenWrites, hasJsTypeAnnotation, isVarDeclared, numericIteratorSourceOf, provenanceElidedConstDecl, } from "./lower-stmts.js";
29
29
  import { objectFactoryGlobalType } from "./object-factory-new.js";
30
30
  import { streamClassAliasDecl } from "./lower-stream.js";
31
+ import { isAssertClassNew } from "./assert-instances.js";
31
32
  import { stdlibGlobalAliasDecl, stdlibGlobalAliasNameOf, stdlibGlobalNameOf } from "./surfaces.js";
32
33
  import { isNativeBuiltinValueInitializer } from "./lower-builtin-values.js";
33
34
  import { collectNamespaceStmt, nsMemberIdentOf, nsPathPrefix, trapDeclRootOf, } from "./lower-namespaces.js";
@@ -1631,6 +1632,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
1631
1632
  // test).
1632
1633
  if (isConst && streamClassAliasDecl(lowerer, decl.name, decl.initializer))
1633
1634
  continue;
1635
+ // `new Assert(...)`: a static instance has no global storage, and any
1636
+ // other instance is refused where its declaration lowers.
1637
+ if (decl.initializer !== undefined &&
1638
+ ts.isNewExpression(stripTypeCasts(decl.initializer)) &&
1639
+ isAssertClassNew(lowerer, stripTypeCasts(decl.initializer)))
1640
+ continue;
1634
1641
  // `const process = globalThis.process` at file scope: a stdlib-
1635
1642
  // global snapshot — alias plumbing, no global storage (see
1636
1643
  // stdlibGlobalAliasDecl; the statement lowering skips it by the