@cotal-ai/lang 0.24.0 → 0.26.0
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.
- package/README.md +11 -0
- package/dist/engine/bridge.d.ts +71 -0
- package/dist/engine/bridge.d.ts.map +1 -0
- package/dist/engine/bridge.js +277 -0
- package/dist/engine/bridge.js.map +1 -0
- package/dist/engine/ctx.d.ts +140 -0
- package/dist/engine/ctx.d.ts.map +1 -0
- package/dist/engine/ctx.js +834 -0
- package/dist/engine/ctx.js.map +1 -0
- package/dist/engine/frame.d.ts +69 -0
- package/dist/engine/frame.d.ts.map +1 -0
- package/dist/engine/frame.js +105 -0
- package/dist/engine/frame.js.map +1 -0
- package/dist/engine/host.d.ts +77 -0
- package/dist/engine/host.d.ts.map +1 -0
- package/dist/engine/host.js +134 -0
- package/dist/engine/host.js.map +1 -0
- package/dist/engine/worker-entry.d.ts +26 -0
- package/dist/engine/worker-entry.d.ts.map +1 -0
- package/dist/engine/worker-entry.js +175 -0
- package/dist/engine/worker-entry.js.map +1 -0
- package/dist/engine/worker.d.ts +156 -0
- package/dist/engine/worker.d.ts.map +1 -0
- package/dist/engine/worker.js +123 -0
- package/dist/engine/worker.js.map +1 -0
- package/dist/errors.d.ts +44 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +97 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/interpret.d.ts +7 -38
- package/dist/interpret.d.ts.map +1 -1
- package/dist/interpret.js +45 -1003
- package/dist/interpret.js.map +1 -1
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +75 -1
- package/dist/journal.js.map +1 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +13 -1
- package/dist/library.js.map +1 -1
- package/dist/perform.d.ts +138 -0
- package/dist/perform.d.ts.map +1 -0
- package/dist/perform.js +1052 -0
- package/dist/perform.js.map +1 -0
- package/dist/pins.d.ts +28 -8
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +31 -11
- package/dist/pins.js.map +1 -1
- package/dist/sim.d.ts +15 -1
- package/dist/sim.d.ts.map +1 -1
- package/dist/sim.js.map +1 -1
- package/dist/transform/emit.d.ts +23 -0
- package/dist/transform/emit.d.ts.map +1 -0
- package/dist/transform/emit.js +934 -0
- package/dist/transform/emit.js.map +1 -0
- package/dist/transform/index.d.ts +34 -0
- package/dist/transform/index.d.ts.map +1 -0
- package/dist/transform/index.js +31 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/transform/scope.d.ts +58 -0
- package/dist/transform/scope.d.ts.map +1 -0
- package/dist/transform/scope.js +500 -0
- package/dist/transform/scope.js.map +1 -0
- package/dist/transform/seam.d.ts +78 -0
- package/dist/transform/seam.d.ts.map +1 -0
- package/dist/transform/seam.js +111 -0
- package/dist/transform/seam.js.map +1 -0
- package/dist/values.d.ts +15 -0
- package/dist/values.d.ts.map +1 -1
- package/dist/values.js +79 -0
- package/dist/values.js.map +1 -1
- package/package.json +9 -4
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The binding analysis the emitter runs first: which names resolve where, and which of them are
|
|
3
|
+
* CELLS.
|
|
4
|
+
*
|
|
5
|
+
* A cell is L2032's binding half, and it exists because the walker's rule is a runtime one. `Env.set`
|
|
6
|
+
* refuses a write whose binding was declared at a shallower concurrency depth than the frame doing
|
|
7
|
+
* the writing, and the depth travels with the BINDING, which is what catches the shape the
|
|
8
|
+
* validator provably cannot see (`scopes.smoke` §8: a record of thunks returned from a function, so
|
|
9
|
+
* there is no function node at the combinator call to check). Native JavaScript bindings carry no
|
|
10
|
+
* depth, so a transform that emits them verbatim loses that refusal.
|
|
11
|
+
*
|
|
12
|
+
* The fix needs no new seam member. A binding written from inside a DEEPER function than the one
|
|
13
|
+
* that declared it becomes a one-field record built with `__ctx.born({v})`: birth depth is stamped
|
|
14
|
+
* at the declaration, `__ctx.set` refuses the write from a deeper frame, and L2032's binding half
|
|
15
|
+
* lands on the same door as its value half. Every other binding stays a native `const`/`let`,
|
|
16
|
+
* which is sound rather than merely fast: a binding no nested function writes can only be written
|
|
17
|
+
* at the depth it was declared at, so there is nothing for the check to refuse.
|
|
18
|
+
*/
|
|
19
|
+
import { RESERVED_NAMES } from "../primitives.js";
|
|
20
|
+
class Scope {
|
|
21
|
+
parent;
|
|
22
|
+
funcId;
|
|
23
|
+
names = new Map();
|
|
24
|
+
constructor(parent, funcId) {
|
|
25
|
+
this.parent = parent;
|
|
26
|
+
this.funcId = funcId;
|
|
27
|
+
}
|
|
28
|
+
declare(b) {
|
|
29
|
+
this.names.set(b.name, b);
|
|
30
|
+
}
|
|
31
|
+
resolve(name) {
|
|
32
|
+
for (let s = this; s !== null; s = s.parent) {
|
|
33
|
+
const b = s.names.get(name);
|
|
34
|
+
if (b !== undefined)
|
|
35
|
+
return b;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
class Walk {
|
|
41
|
+
bindingOf = new Map();
|
|
42
|
+
bindings = [];
|
|
43
|
+
nextFunc = 0;
|
|
44
|
+
/**
|
|
45
|
+
* The functions currently open, outermost first. The dead-zone rule reads the path from a use out
|
|
46
|
+
* to its binding.
|
|
47
|
+
*/
|
|
48
|
+
fns = [];
|
|
49
|
+
/** The statement being walked. A function literal's "enclosing statement" is this one. */
|
|
50
|
+
stmtStart = 0;
|
|
51
|
+
declare(scope, name, kind, declEnd = null) {
|
|
52
|
+
const b = { name, kind, funcId: scope.funcId, declEnd, cell: false, deadZone: false };
|
|
53
|
+
this.bindings.push(b);
|
|
54
|
+
scope.declare(b);
|
|
55
|
+
return b;
|
|
56
|
+
}
|
|
57
|
+
/** A reference: record where it resolved, so the emitter reads the answer rather than recomputing it. */
|
|
58
|
+
ref(node, scope) {
|
|
59
|
+
const b = scope.resolve(node.name);
|
|
60
|
+
// A name the program never declared is a free name (a builtin, a primitive, `undefined`). The
|
|
61
|
+
// validator refuses shadowing a reserved name, so resolution cannot disagree with that table.
|
|
62
|
+
if (b !== undefined) {
|
|
63
|
+
this.bindingOf.set(node, b);
|
|
64
|
+
this.deadZone(b);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The dead-zone rule: which captured bindings can be READ BEFORE THEY HOLD A VALUE, and so must
|
|
69
|
+
* be cells.
|
|
70
|
+
*
|
|
71
|
+
* The walker refuses that read L2004 (a code a program can catch and read) while a native
|
|
72
|
+
* JavaScript binding answers a host ReferenceError, which `caught` can only report as L4000/host.
|
|
73
|
+
* So a binding a closure could read early becomes a record, `get` answers L2004 for it by name,
|
|
74
|
+
* and the two engines agree. Same-block direct reads never reach here: the validator refuses them
|
|
75
|
+
* (measured, `log(x); const x = 1;` is a validation error).
|
|
76
|
+
*
|
|
77
|
+
* The rule, as ruled, over the path from the read out to the binding's own scope:
|
|
78
|
+
* (i) ANY hoisted `function` declaration on the path, at any depth, because an arrow inside a
|
|
79
|
+
* hoisted function called early is reachable just the same (measured: `const r = f()` with
|
|
80
|
+
* `function f() { const g = () => x; return g(); }` and `const x = 1` after is L2004); or
|
|
81
|
+
* (ii) the OUTERMOST function on the path is an expression whose enclosing statement is not
|
|
82
|
+
* textually after the end of the declarator, which deliberately includes an arrow inside
|
|
83
|
+
* the binding's own initializer, since `const x = (() => x)()` is L2004 (measured).
|
|
84
|
+
* Every other captured binding stays native, and that class keeps its own evidence: `const x = 1`
|
|
85
|
+
* followed by a closure reading it answers 1 on both engines.
|
|
86
|
+
*/
|
|
87
|
+
deadZone(b) {
|
|
88
|
+
if (b.declEnd === null)
|
|
89
|
+
return;
|
|
90
|
+
const at = this.fns.findIndex((f) => f.funcId === b.funcId);
|
|
91
|
+
const path = this.fns.slice(at + 1);
|
|
92
|
+
if (path.length === 0)
|
|
93
|
+
return;
|
|
94
|
+
if (path.some((f) => f.hoisted) || path[0].stmtStart < b.declEnd) {
|
|
95
|
+
b.cell = true;
|
|
96
|
+
b.deadZone = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** A write to a binding. The cell rule is here and nowhere else. */
|
|
100
|
+
write(node, scope, funcId) {
|
|
101
|
+
const b = scope.resolve(node.name);
|
|
102
|
+
if (b === undefined)
|
|
103
|
+
return;
|
|
104
|
+
this.bindingOf.set(node, b);
|
|
105
|
+
if (b.funcId !== funcId && b.kind !== "const")
|
|
106
|
+
b.cell = true;
|
|
107
|
+
// AND THE SAME RULE OVER WRITES, added after the read half landed. A write reaches the dead
|
|
108
|
+
// zone by the same path a read does. Measured on the walker, `n = 2` inside a hoisted
|
|
109
|
+
// `function` called
|
|
110
|
+
// before `let n = 1` is a CATCHABLE L2004 and `n` still reads 1 afterwards, so the same
|
|
111
|
+
// predicate decides it, and the record has to be hoisted for the same reason: an unhoisted one
|
|
112
|
+
// is still in its own temporal dead zone when the early write evaluates the argument, and the
|
|
113
|
+
// native ReferenceError never reaches the seam.
|
|
114
|
+
this.deadZone(b);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The names a declaration or a parameter introduces, declared into `scope`.
|
|
118
|
+
*
|
|
119
|
+
* The declaring Identifier node is recorded in `bindingOf` too, not only its references: the
|
|
120
|
+
* emitter asks the same question at a declaration as at a use (is this a cell?), and answering
|
|
121
|
+
* "no" for every declaration because the node was not in the map is a cell that is emitted as a
|
|
122
|
+
* plain binding, with the L2032 refusal silently gone.
|
|
123
|
+
*/
|
|
124
|
+
declarePattern(node, scope, kind, declEnd = null) {
|
|
125
|
+
switch (node.type) {
|
|
126
|
+
case "Identifier":
|
|
127
|
+
this.bindingOf.set(node, this.declare(scope, node.name, kind, declEnd));
|
|
128
|
+
return;
|
|
129
|
+
case "AssignmentPattern":
|
|
130
|
+
this.declarePattern(node.left, scope, kind, declEnd);
|
|
131
|
+
return;
|
|
132
|
+
case "RestElement":
|
|
133
|
+
this.declarePattern(node.argument, scope, kind, declEnd);
|
|
134
|
+
return;
|
|
135
|
+
case "ObjectPattern":
|
|
136
|
+
for (const p of node.properties ?? []) {
|
|
137
|
+
this.declarePattern((p.type === "RestElement" ? p.argument : p.value), scope, kind, declEnd);
|
|
138
|
+
}
|
|
139
|
+
return;
|
|
140
|
+
case "ArrayPattern":
|
|
141
|
+
for (const el of node.elements ?? []) {
|
|
142
|
+
if (el !== null && el !== undefined)
|
|
143
|
+
this.declarePattern(el, scope, kind, declEnd);
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
default:
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** The expressions INSIDE a declaration pattern (a default value, a computed key). */
|
|
151
|
+
patternExprs(node, scope, funcId) {
|
|
152
|
+
switch (node.type) {
|
|
153
|
+
case "AssignmentPattern":
|
|
154
|
+
this.patternExprs(node.left, scope, funcId);
|
|
155
|
+
this.expr(node.right, scope, funcId);
|
|
156
|
+
return;
|
|
157
|
+
case "RestElement":
|
|
158
|
+
this.patternExprs(node.argument, scope, funcId);
|
|
159
|
+
return;
|
|
160
|
+
case "ObjectPattern":
|
|
161
|
+
for (const p of node.properties ?? []) {
|
|
162
|
+
if (p.type === "RestElement") {
|
|
163
|
+
this.patternExprs(p.argument, scope, funcId);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (p.computed === true)
|
|
167
|
+
this.expr(p.key, scope, funcId);
|
|
168
|
+
this.patternExprs(p.value, scope, funcId);
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
case "ArrayPattern":
|
|
172
|
+
for (const el of node.elements ?? []) {
|
|
173
|
+
if (el !== null && el !== undefined)
|
|
174
|
+
this.patternExprs(el, scope, funcId);
|
|
175
|
+
}
|
|
176
|
+
return;
|
|
177
|
+
default:
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/** An ASSIGNMENT pattern: `[a, b] = [b, a]`. Its names are written, not declared. */
|
|
182
|
+
assignPattern(node, scope, funcId) {
|
|
183
|
+
switch (node.type) {
|
|
184
|
+
case "Identifier":
|
|
185
|
+
this.write(node, scope, funcId);
|
|
186
|
+
return;
|
|
187
|
+
case "MemberExpression":
|
|
188
|
+
this.expr(node, scope, funcId);
|
|
189
|
+
return;
|
|
190
|
+
case "AssignmentPattern":
|
|
191
|
+
this.assignPattern(node.left, scope, funcId);
|
|
192
|
+
this.expr(node.right, scope, funcId);
|
|
193
|
+
return;
|
|
194
|
+
case "RestElement":
|
|
195
|
+
this.assignPattern(node.argument, scope, funcId);
|
|
196
|
+
return;
|
|
197
|
+
case "ObjectPattern":
|
|
198
|
+
for (const p of node.properties ?? []) {
|
|
199
|
+
if (p.type === "RestElement") {
|
|
200
|
+
this.assignPattern(p.argument, scope, funcId);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (p.computed === true)
|
|
204
|
+
this.expr(p.key, scope, funcId);
|
|
205
|
+
this.assignPattern(p.value, scope, funcId);
|
|
206
|
+
}
|
|
207
|
+
return;
|
|
208
|
+
case "ArrayPattern":
|
|
209
|
+
for (const el of node.elements ?? []) {
|
|
210
|
+
if (el !== null && el !== undefined)
|
|
211
|
+
this.assignPattern(el, scope, funcId);
|
|
212
|
+
}
|
|
213
|
+
return;
|
|
214
|
+
default:
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* A function: its own scope, its own id. The id is what the cell rule compares: a write from a
|
|
220
|
+
* different function id than the declaration's is a write from a frame the walker would have
|
|
221
|
+
* charged a deeper depth.
|
|
222
|
+
*/
|
|
223
|
+
fn(node, outer) {
|
|
224
|
+
this.nextFunc += 1;
|
|
225
|
+
const funcId = this.nextFunc;
|
|
226
|
+
const scope = new Scope(outer, funcId);
|
|
227
|
+
this.fns.push({ funcId, hoisted: node.type === "FunctionDeclaration", stmtStart: this.stmtStart });
|
|
228
|
+
try {
|
|
229
|
+
this.fnBody(node, scope, funcId);
|
|
230
|
+
}
|
|
231
|
+
finally {
|
|
232
|
+
this.fns.pop();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
fnBody(node, scope, funcId) {
|
|
236
|
+
// A named function expression sees its own name, exactly as the walker's `makeFunction` binds it.
|
|
237
|
+
if (node.type === "FunctionExpression" && node.id !== null && node.id !== undefined) {
|
|
238
|
+
this.declare(scope, node.id.name, "function");
|
|
239
|
+
}
|
|
240
|
+
for (const p of node.params ?? [])
|
|
241
|
+
this.declarePattern(p, scope, "param");
|
|
242
|
+
for (const p of node.params ?? [])
|
|
243
|
+
this.patternExprs(p, scope, funcId);
|
|
244
|
+
const body = node.body;
|
|
245
|
+
if (body.type === "BlockStatement")
|
|
246
|
+
this.block(body, scope, funcId);
|
|
247
|
+
else
|
|
248
|
+
this.expr(body, scope, funcId);
|
|
249
|
+
}
|
|
250
|
+
/** A block: hoist its function declarations and its dead-zone names, then walk it. */
|
|
251
|
+
block(node, outer, funcId) {
|
|
252
|
+
const scope = new Scope(outer, funcId);
|
|
253
|
+
const body = node.body ?? [];
|
|
254
|
+
for (const s of body) {
|
|
255
|
+
if (s.type === "FunctionDeclaration")
|
|
256
|
+
this.declare(scope, s.id.name, "function");
|
|
257
|
+
}
|
|
258
|
+
for (const s of body) {
|
|
259
|
+
if (s.type !== "VariableDeclaration")
|
|
260
|
+
continue;
|
|
261
|
+
for (const d of s.declarations ?? []) {
|
|
262
|
+
this.declarePattern(d.id, scope, s.kind === "let" ? "let" : "const", d.end);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
for (const s of body)
|
|
266
|
+
this.stmt(s, scope, funcId);
|
|
267
|
+
}
|
|
268
|
+
stmt(node, scope, funcId) {
|
|
269
|
+
const outer = this.stmtStart;
|
|
270
|
+
this.stmtStart = node.start;
|
|
271
|
+
try {
|
|
272
|
+
this.statement(node, scope, funcId);
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
this.stmtStart = outer;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
statement(node, scope, funcId) {
|
|
279
|
+
switch (node.type) {
|
|
280
|
+
case "ExpressionStatement":
|
|
281
|
+
this.expr(node.expression, scope, funcId);
|
|
282
|
+
return;
|
|
283
|
+
case "VariableDeclaration":
|
|
284
|
+
for (const d of node.declarations ?? []) {
|
|
285
|
+
this.patternExprs(d.id, scope, funcId);
|
|
286
|
+
if (d.init !== null && d.init !== undefined)
|
|
287
|
+
this.expr(d.init, scope, funcId);
|
|
288
|
+
}
|
|
289
|
+
return;
|
|
290
|
+
case "FunctionDeclaration":
|
|
291
|
+
this.fn(node, scope);
|
|
292
|
+
return;
|
|
293
|
+
case "BlockStatement":
|
|
294
|
+
this.block(node, scope, funcId);
|
|
295
|
+
return;
|
|
296
|
+
case "IfStatement":
|
|
297
|
+
this.expr(node.test, scope, funcId);
|
|
298
|
+
this.stmt(node.consequent, scope, funcId);
|
|
299
|
+
if (node.alternate !== null && node.alternate !== undefined)
|
|
300
|
+
this.stmt(node.alternate, scope, funcId);
|
|
301
|
+
return;
|
|
302
|
+
case "WhileStatement":
|
|
303
|
+
this.expr(node.test, scope, funcId);
|
|
304
|
+
this.stmt(node.body, scope, funcId);
|
|
305
|
+
return;
|
|
306
|
+
case "ForStatement": {
|
|
307
|
+
const head = new Scope(scope, funcId);
|
|
308
|
+
const init = node.init;
|
|
309
|
+
if (init !== null && init !== undefined) {
|
|
310
|
+
if (init.type === "VariableDeclaration") {
|
|
311
|
+
for (const d of init.declarations ?? []) {
|
|
312
|
+
this.declarePattern(d.id, head, init.kind === "let" ? "let" : "const");
|
|
313
|
+
}
|
|
314
|
+
this.stmt(init, head, funcId);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
this.expr(init, head, funcId);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (node.test !== null && node.test !== undefined)
|
|
321
|
+
this.expr(node.test, head, funcId);
|
|
322
|
+
if (node.update !== null && node.update !== undefined)
|
|
323
|
+
this.expr(node.update, head, funcId);
|
|
324
|
+
this.stmt(node.body, head, funcId);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
case "ForOfStatement": {
|
|
328
|
+
this.expr(node.right, scope, funcId);
|
|
329
|
+
const head = new Scope(scope, funcId);
|
|
330
|
+
const left = node.left;
|
|
331
|
+
if (left.type === "VariableDeclaration") {
|
|
332
|
+
const target = left.declarations[0].id;
|
|
333
|
+
this.declarePattern(target, head, left.kind === "let" ? "let" : "const");
|
|
334
|
+
this.patternExprs(target, head, funcId);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
this.assignPattern(left, head, funcId);
|
|
338
|
+
}
|
|
339
|
+
this.stmt(node.body, head, funcId);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
case "ReturnStatement":
|
|
343
|
+
case "ThrowStatement":
|
|
344
|
+
if (node.argument !== null && node.argument !== undefined)
|
|
345
|
+
this.expr(node.argument, scope, funcId);
|
|
346
|
+
return;
|
|
347
|
+
case "BreakStatement":
|
|
348
|
+
case "ContinueStatement":
|
|
349
|
+
case "EmptyStatement":
|
|
350
|
+
return;
|
|
351
|
+
case "TryStatement": {
|
|
352
|
+
this.block(node.block, scope, funcId);
|
|
353
|
+
const handler = node.handler;
|
|
354
|
+
if (handler !== null && handler !== undefined) {
|
|
355
|
+
const catchScope = new Scope(scope, funcId);
|
|
356
|
+
if (handler.param !== null && handler.param !== undefined) {
|
|
357
|
+
this.declarePattern(handler.param, catchScope, "let");
|
|
358
|
+
this.patternExprs(handler.param, catchScope, funcId);
|
|
359
|
+
}
|
|
360
|
+
this.block(handler.body, catchScope, funcId);
|
|
361
|
+
}
|
|
362
|
+
if (node.finalizer !== null && node.finalizer !== undefined)
|
|
363
|
+
this.block(node.finalizer, scope, funcId);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
case "SwitchStatement": {
|
|
367
|
+
this.expr(node.discriminant, scope, funcId);
|
|
368
|
+
// One scope for the whole switch, as the walker's `switchEnv` is: a `let` in one clause is
|
|
369
|
+
// visible in the next, which is what falling through means.
|
|
370
|
+
const switchScope = new Scope(scope, funcId);
|
|
371
|
+
const cases = node.cases ?? [];
|
|
372
|
+
for (const c of cases) {
|
|
373
|
+
for (const s of c.consequent ?? []) {
|
|
374
|
+
if (s.type === "FunctionDeclaration")
|
|
375
|
+
this.declare(switchScope, s.id.name, "function");
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
for (const c of cases) {
|
|
379
|
+
for (const s of c.consequent ?? []) {
|
|
380
|
+
if (s.type !== "VariableDeclaration")
|
|
381
|
+
continue;
|
|
382
|
+
for (const d of s.declarations ?? []) {
|
|
383
|
+
this.declarePattern(d.id, switchScope, s.kind === "let" ? "let" : "const");
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
for (const c of cases) {
|
|
388
|
+
if (c.test !== null && c.test !== undefined)
|
|
389
|
+
this.expr(c.test, switchScope, funcId);
|
|
390
|
+
for (const s of c.consequent ?? [])
|
|
391
|
+
this.stmt(s, switchScope, funcId);
|
|
392
|
+
}
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
default:
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
expr(node, scope, funcId) {
|
|
400
|
+
switch (node.type) {
|
|
401
|
+
case "Literal":
|
|
402
|
+
return;
|
|
403
|
+
case "Identifier":
|
|
404
|
+
this.ref(node, scope);
|
|
405
|
+
return;
|
|
406
|
+
case "TemplateLiteral":
|
|
407
|
+
for (const e of node.expressions ?? [])
|
|
408
|
+
this.expr(e, scope, funcId);
|
|
409
|
+
return;
|
|
410
|
+
case "ArrayExpression":
|
|
411
|
+
for (const el of node.elements ?? []) {
|
|
412
|
+
if (el === null || el === undefined)
|
|
413
|
+
continue;
|
|
414
|
+
this.expr((el.type === "SpreadElement" ? el.argument : el), scope, funcId);
|
|
415
|
+
}
|
|
416
|
+
return;
|
|
417
|
+
case "ObjectExpression":
|
|
418
|
+
for (const p of node.properties ?? []) {
|
|
419
|
+
if (p.type === "SpreadElement") {
|
|
420
|
+
this.expr(p.argument, scope, funcId);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (p.computed === true)
|
|
424
|
+
this.expr(p.key, scope, funcId);
|
|
425
|
+
this.expr(p.value, scope, funcId);
|
|
426
|
+
}
|
|
427
|
+
return;
|
|
428
|
+
case "MemberExpression":
|
|
429
|
+
this.expr(node.object, scope, funcId);
|
|
430
|
+
if (node.computed === true)
|
|
431
|
+
this.expr(node.property, scope, funcId);
|
|
432
|
+
return;
|
|
433
|
+
case "ChainExpression":
|
|
434
|
+
this.expr(node.expression, scope, funcId);
|
|
435
|
+
return;
|
|
436
|
+
case "UnaryExpression":
|
|
437
|
+
this.expr(node.argument, scope, funcId);
|
|
438
|
+
return;
|
|
439
|
+
case "UpdateExpression": {
|
|
440
|
+
const arg = node.argument;
|
|
441
|
+
if (arg.type === "Identifier")
|
|
442
|
+
this.write(arg, scope, funcId);
|
|
443
|
+
else
|
|
444
|
+
this.expr(arg, scope, funcId);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
case "BinaryExpression":
|
|
448
|
+
case "LogicalExpression":
|
|
449
|
+
this.expr(node.left, scope, funcId);
|
|
450
|
+
this.expr(node.right, scope, funcId);
|
|
451
|
+
return;
|
|
452
|
+
case "ConditionalExpression":
|
|
453
|
+
this.expr(node.test, scope, funcId);
|
|
454
|
+
this.expr(node.consequent, scope, funcId);
|
|
455
|
+
this.expr(node.alternate, scope, funcId);
|
|
456
|
+
return;
|
|
457
|
+
case "AssignmentExpression": {
|
|
458
|
+
const left = node.left;
|
|
459
|
+
if (left.type === "Identifier")
|
|
460
|
+
this.write(left, scope, funcId);
|
|
461
|
+
else if (left.type === "MemberExpression")
|
|
462
|
+
this.expr(left, scope, funcId);
|
|
463
|
+
else
|
|
464
|
+
this.assignPattern(left, scope, funcId);
|
|
465
|
+
this.expr(node.right, scope, funcId);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
case "AwaitExpression":
|
|
469
|
+
this.expr(node.argument, scope, funcId);
|
|
470
|
+
return;
|
|
471
|
+
case "ArrowFunctionExpression":
|
|
472
|
+
case "FunctionExpression":
|
|
473
|
+
this.fn(node, scope);
|
|
474
|
+
return;
|
|
475
|
+
case "CallExpression":
|
|
476
|
+
this.expr(node.callee, scope, funcId);
|
|
477
|
+
for (const a of node.arguments ?? []) {
|
|
478
|
+
this.expr((a.type === "SpreadElement" ? a.argument : a), scope, funcId);
|
|
479
|
+
}
|
|
480
|
+
return;
|
|
481
|
+
default:
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Resolve every name in a validated program and mark the cells.
|
|
488
|
+
*
|
|
489
|
+
* Reserved names are never declared by a program (the validator refuses shadowing one), so a name
|
|
490
|
+
* that resolves to nothing here is a free name and the emitter routes it through the seam.
|
|
491
|
+
*/
|
|
492
|
+
export function analyze(program) {
|
|
493
|
+
const w = new Walk();
|
|
494
|
+
const root = new Scope(null, 0);
|
|
495
|
+
w.block(program, root, 0);
|
|
496
|
+
return { bindingOf: w.bindingOf, bindings: w.bindings };
|
|
497
|
+
}
|
|
498
|
+
/** The free names a program may reference without declaring. Read from the language's own table. */
|
|
499
|
+
export const FREE_NAMES = RESERVED_NAMES;
|
|
500
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/transform/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAiClD,MAAM,KAAK;IAGE;IACA;IAHF,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC5C,YACW,MAAoB,EACpB,MAAc;QADd,WAAM,GAAN,MAAM,CAAc;QACpB,WAAM,GAAN,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AAM,CAAC,CAAC;gBACjD,KAAK,MAAM,CAAC,IAAK,IAAI,CAAC,SAAuB,IAAI,EAAE,EAAE,CAAC;oBACpD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAY,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;gBACrF,CAAC;gBACD,OAAO;YACT;gBACE,OAAO;QACX,CAAC;IACH,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,OAAgB;IACtC,MAAM,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IACrB,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1B,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC1D,CAAC;AAED,oGAAoG;AACpG,MAAM,CAAC,MAAM,UAAU,GAAwB,cAAc,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seam, as data: the members the emitted module may reach, and the names it may not collide with.
|
|
3
|
+
*
|
|
4
|
+
* The transform and its host share this seam, and neither side widens it on its own. That is
|
|
5
|
+
* mechanized from this file: `transform.smoke` re-parses the emitted string, resolves its scopes,
|
|
6
|
+
* and requires ZERO unbound references and every `<ctx>.<member>` it reaches to be listed here. A
|
|
7
|
+
* member added without changing this table is a change a reader sees in one place, not a call
|
|
8
|
+
* buried in an emitter.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The members the seam grants, each with the range of ARGUMENT COUNTS the emitter may pass.
|
|
12
|
+
*
|
|
13
|
+
* The arity is written here rather than left implicit in the emitter because a member's shape is as
|
|
14
|
+
* much of the contract as its name, and the two that vary are exactly where a divergence hid from a
|
|
15
|
+
* names-only comparison: `call` grew a fourth and then a fifth argument for the optional call
|
|
16
|
+
* against a host member declared with three, and the differential found it rather than the surface.
|
|
17
|
+
* `transform.smoke` checks every emitted call site against this range in both directions - no site
|
|
18
|
+
* outside it, and no bound without a site that reaches it - and `engine.smoke` checks the host's
|
|
19
|
+
* `ctx` against the same table: names by set-equality, and `ctx[name].length === max` for each. That
|
|
20
|
+
* last is the contracted spelling, and it is `max` rather than `min` for a measured reason: a
|
|
21
|
+
* TypeScript optional parameter is a plain parameter after erasure and still counts toward
|
|
22
|
+
* `Function.length`, so a `<= min` rule
|
|
23
|
+
* would be vacuous on every fixed member and false on all four variadic ones. The MIN end cannot be
|
|
24
|
+
* read from a function at all - erasure has discarded which parameters were optional - so it is
|
|
25
|
+
* behavioural on the host's side: each variadic member has a cell calling it in its shortest form.
|
|
26
|
+
*
|
|
27
|
+
* `fuel` is the step check (budget L4013 + yield); `get`/`set`/`call` are the member law
|
|
28
|
+
* (L4014/L4018/L4020, curated tables, birth depth L2032, freeze L2031); `born` stamps a literal;
|
|
29
|
+
* `effect` is a journalled primitive, with a static per-call-site payload; `free` is a free name
|
|
30
|
+
* that journals nothing; `await` is the thenable gate; `template` is the interpolation law;
|
|
31
|
+
* `binary`/`unary` are the operator coercion law (L4018 + the operators' meaning); `iter` is the
|
|
32
|
+
* iterability law (L4015); `caught` heads every emitted catch clause (rethrow the six uncatchable
|
|
33
|
+
* classes, else the walker's frozen `{code, kind, message}` record).
|
|
34
|
+
*/
|
|
35
|
+
export declare const SEAM_MEMBERS: Readonly<Record<string, readonly [number, number]>>;
|
|
36
|
+
/** The member NAMES the seam grants. Derived from the table above, so the two cannot disagree. */
|
|
37
|
+
export declare const SEAM_RULED: ReadonlySet<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Members the emitter reaches that are SURFACED but not yet ruled.
|
|
40
|
+
*
|
|
41
|
+
* Kept apart from {@link SEAM_RULED} on purpose. The alternative to naming the debt is either to
|
|
42
|
+
* stop building or to let a proposed member sit indistinguishable from a granted one, and the
|
|
43
|
+
* second is the forbidden move wearing a green suite. `TransformMeta.proposed` reports which of
|
|
44
|
+
* these an emission actually reached, and `transform.smoke` pins that set, so the debt is a
|
|
45
|
+
* measured number rather than a memory.
|
|
46
|
+
*/
|
|
47
|
+
export declare const SEAM_PROPOSED: Readonly<Record<string, string>>;
|
|
48
|
+
/**
|
|
49
|
+
* Every operator selector the emitter hands `unary`, and no other.
|
|
50
|
+
*
|
|
51
|
+
* `!` and `typeof` never reach here: neither can refuse, so both are emitted natively. `update` is
|
|
52
|
+
* `UpdateExpression`'s operand read, and it carries the coercion refusal rather than the walker's
|
|
53
|
+
* bare `Number(...)`. The walker's answer there (NaN for a record, 6 for `"5"++`) is the
|
|
54
|
+
* silent-coercion class, filed as issue 646 and carried as a declared divergence with named cells.
|
|
55
|
+
* An op set is as much a contract as a member name, which is why it is written down here rather
|
|
56
|
+
* than left implicit in the emitter.
|
|
57
|
+
*/
|
|
58
|
+
export declare const UNARY_OPS: readonly string[];
|
|
59
|
+
/** Names chosen against the program's own identifier universe, so nothing the emitter needs can be shadowed. */
|
|
60
|
+
export interface Names {
|
|
61
|
+
/** The ctx parameter. The validator admits a program-declared `__ctx` (measured), so this is computed, not fixed. */
|
|
62
|
+
readonly ctx: string;
|
|
63
|
+
/** Prefix for emitter temporaries. */
|
|
64
|
+
readonly temp: string;
|
|
65
|
+
/** Prefix for emitter labels. Labels have their own namespace in JavaScript, but the prefix keeps output readable. */
|
|
66
|
+
readonly label: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Pick emitter names that cannot collide with anything the program spells.
|
|
70
|
+
*
|
|
71
|
+
* The module shape is a CLOSED function expression with zero free identifiers. That replaced an
|
|
72
|
+
* earlier premise this file carried, which a review falsified: the validator admits `$x`, `__y`,
|
|
73
|
+
* and a program-declared `__ctx`. So the ctx parameter's name is derived from the source rather
|
|
74
|
+
* than assumed, and the derivation is deterministic: the same source picks the
|
|
75
|
+
* same names on every run, which is what makes `transform` byte-reproducible.
|
|
76
|
+
*/
|
|
77
|
+
export declare function pickNames(identifiers: ReadonlySet<string>): Names;
|
|
78
|
+
//# sourceMappingURL=seam.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seam.d.ts","sourceRoot":"","sources":["../../src/transform/seam.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAyB3E,CAAC;AAEH,kGAAkG;AAClG,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,MAAM,CAAsC,CAAC;AAElF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAqB,CAAC;AAEjF;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAA6C,CAAC;AAErF,gHAAgH;AAChH,MAAM,WAAW,KAAK;IACpB,qHAAqH;IACrH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sHAAsH;IACtH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,KAAK,CAcjE"}
|