@scriptc/compiler 0.1.4 → 0.1.5
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/ambient/scriptc-node-fallback.d.ts +75 -11
- package/dist/backend/c/c-emitter.d.ts +5 -1
- package/dist/backend/c/c-emitter.js +22 -9
- package/dist/backend/c/c-emitter.js.map +1 -1
- package/dist/backend/c/exprs.d.ts +2 -2
- package/dist/backend/c/exprs.js +264 -21
- package/dist/backend/c/exprs.js.map +1 -1
- package/dist/backend/c/stmts.js +5 -3
- package/dist/backend/c/stmts.js.map +1 -1
- package/dist/backend/c/types.d.ts +2 -3
- package/dist/backend/c/types.js +8 -1
- package/dist/backend/c/types.js.map +1 -1
- package/dist/backend/c/walkers.js +1 -1
- package/dist/backend/c/walkers.js.map +1 -1
- package/dist/backend/link-plan.d.ts +1 -0
- package/dist/backend/link-plan.js +2 -1
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/dyn.js +1 -1
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +25 -9
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +1 -2
- package/dist/backend/llvm/expr-bytes.js +22 -17
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +1 -0
- package/dist/backend/llvm/expr-containers.js +32 -4
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +6 -2
- package/dist/backend/llvm/expr-primitives.js +22 -7
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +12 -0
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +53 -10
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +64 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +2 -0
- package/dist/backend/native-toolchain.js +2 -1
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/targets.d.ts +3 -0
- package/dist/backend/targets.js +13 -0
- package/dist/backend/targets.js.map +1 -1
- package/dist/coverage/surface-manifest.js +6 -4
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +2 -0
- package/dist/executable/executable-cache.js +3 -1
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +3 -3
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +1 -1
- package/dist/frontend/lowering/containers/bytes.js +6 -5
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +7 -6
- package/dist/frontend/lowering/containers/string-and-regexp.js +237 -28
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +8 -0
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +4 -5
- package/dist/frontend/lowering/lower-builtins.js +18 -10
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +3 -2
- package/dist/frontend/lowering/lower-calls.js +265 -88
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +2 -2
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +7 -9
- package/dist/frontend/lowering/lower-containers.js +143 -51
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +12 -0
- package/dist/frontend/lowering/lower-exprs.js +128 -10
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-island.js +17 -6
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +2 -4
- package/dist/frontend/lowering/lower-server.js +288 -32
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +4 -4
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.js +37 -2
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/optional-arguments.d.ts +9 -1
- package/dist/frontend/lowering/optional-arguments.js +67 -1
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.d.ts +3 -1
- package/dist/frontend/lowering/pairs-snapshot.js +12 -4
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +8 -14
- package/dist/frontend/lowering/surfaces.js +37 -27
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm-static-prune.d.ts +6 -0
- package/dist/frontend/npm-static-prune.js +203 -0
- package/dist/frontend/npm-static-prune.js.map +1 -0
- package/dist/frontend/npm-static-prune.test.d.ts +1 -0
- package/dist/frontend/npm-static-prune.test.js +48 -0
- package/dist/frontend/npm-static-prune.test.js.map +1 -0
- package/dist/frontend/npm.js +7 -6
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/program.js +15 -4
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/provenance.js +8 -3
- package/dist/frontend/provenance.js.map +1 -1
- package/dist/frontend/type-mapper.js +16 -5
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +13 -41
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +5 -3
- package/dist/ir/analysis.js +25 -11
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +50 -2
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/constant-tables.d.ts +17 -0
- package/dist/ir/constant-tables.js +99 -0
- package/dist/ir/constant-tables.js.map +1 -0
- package/dist/ir/constant-tables.test.d.ts +1 -0
- package/dist/ir/constant-tables.test.js +78 -0
- package/dist/ir/constant-tables.test.js.map +1 -0
- package/dist/ir/integer-ranges.d.ts +13 -0
- package/dist/ir/integer-ranges.js +122 -0
- package/dist/ir/integer-ranges.js.map +1 -0
- package/dist/ir/integer-ranges.test.d.ts +1 -0
- package/dist/ir/integer-ranges.test.js +63 -0
- package/dist/ir/integer-ranges.test.js.map +1 -0
- package/dist/ir/ir.d.ts +42 -34
- package/dist/ir/ir.js +7 -1
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +6 -0
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/scalar-records.d.ts +8 -0
- package/dist/ir/scalar-records.js +216 -0
- package/dist/ir/scalar-records.js.map +1 -0
- package/dist/ir/scalar-records.test.d.ts +1 -0
- package/dist/ir/scalar-records.test.js +142 -0
- package/dist/ir/scalar-records.test.js.map +1 -0
- package/dist/ir/validate.js +92 -8
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.d.ts +1 -0
- package/dist/ir/validate.test.js +31 -0
- package/dist/ir/validate.test.js.map +1 -0
- package/dist/library/cache-primitives.d.ts +1 -1
- package/dist/library/cache-primitives.js +3 -3
- package/dist/library/cache-primitives.js.map +1 -1
- package/dist/library/fence-eval.js +11 -4
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/library-cache.js +0 -1
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +3 -3
- package/dist/library/library-cache.test.js.map +1 -1
- package/package.json +17 -17
- package/surface-manifest.json +55 -42
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import * as ts from "../ts7/adapter.js";
|
|
2
|
-
import type { IrExpr, IrType } from "../../ir/ir.js";
|
|
2
|
+
import type { IrExpr, IrType, SrcLoc } from "../../ir/ir.js";
|
|
3
3
|
import type { Lowerer } from "./lowerer.js";
|
|
4
4
|
/** Lower an expression whose checker type is statically `undefined`/`void`. */
|
|
5
5
|
export declare function lowerStaticallyUndefinedArgument(lowerer: Lowerer, node: ts.Expression): IrExpr | null;
|
|
6
6
|
/** Preserve an explicitly undefined argument's effects, then use its default. */
|
|
7
7
|
export declare function defaultAfterUndefined(value: IrExpr, defaultValue: IrExpr): IrExpr;
|
|
8
|
+
/** Convert an omitted or supplied string-search value after preserving its effects. */
|
|
9
|
+
export declare function lowerStringSearchArgument(lowerer: Lowerer, node: ts.Expression | undefined, loc: SrcLoc): IrExpr;
|
|
10
|
+
/** Convert a lowered string-search value while preserving unit-value effects. */
|
|
11
|
+
export declare function coerceStringSearchValue(lowerer: Lowerer, value: IrExpr, node: ts.Expression, loc: SrcLoc): IrExpr;
|
|
8
12
|
/** Lower an optional argument, applying its default only to the undefined arm. */
|
|
9
13
|
export declare function lowerOptionalArgument(lowerer: Lowerer, node: ts.Expression, expected: IrType, defaultValue: IrExpr): IrExpr;
|
|
14
|
+
/** Complete an omitted or statically undefined position without dropping argument effects. */
|
|
15
|
+
export declare function lowerPositionArgument(lowerer: Lowerer, node: ts.Expression | undefined, defaultValue: IrExpr): IrExpr;
|
|
16
|
+
/** Convert a stabilized position after the method has evaluated its arguments. */
|
|
17
|
+
export declare function positionNumber(lowerer: Lowerer, value: IrExpr, defaultValue: IrExpr, node: ts.Expression, subject: string): IrExpr;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as ts from "../ts7/adapter.js";
|
|
2
|
-
import { typeEquals } from "../../ir/ir.js";
|
|
2
|
+
import { BOOL, F64, isUnitType, typeEquals } from "../../ir/ir.js";
|
|
3
|
+
import { numLit, strLit } from "../../ir/build.js";
|
|
3
4
|
import { isSafeToDiscard } from "./expressions/evaluation-safety.js";
|
|
4
5
|
/** Lower an expression whose checker type is statically `undefined`/`void`. */
|
|
5
6
|
export function lowerStaticallyUndefinedArgument(lowerer, node) {
|
|
@@ -38,6 +39,23 @@ export function defaultAfterUndefined(value, defaultValue) {
|
|
|
38
39
|
loc: value.loc,
|
|
39
40
|
};
|
|
40
41
|
}
|
|
42
|
+
/** Convert an omitted or supplied string-search value after preserving its effects. */
|
|
43
|
+
export function lowerStringSearchArgument(lowerer, node, loc) {
|
|
44
|
+
const absent = strLit("undefined", loc);
|
|
45
|
+
if (!node)
|
|
46
|
+
return absent;
|
|
47
|
+
const undefinedArg = lowerStaticallyUndefinedArgument(lowerer, node);
|
|
48
|
+
if (undefinedArg)
|
|
49
|
+
return defaultAfterUndefined(undefinedArg, absent);
|
|
50
|
+
return coerceStringSearchValue(lowerer, lowerer.lowerExpr(node), node, loc);
|
|
51
|
+
}
|
|
52
|
+
/** Convert a lowered string-search value while preserving unit-value effects. */
|
|
53
|
+
export function coerceStringSearchValue(lowerer, value, node, loc) {
|
|
54
|
+
if (isUnitType(value.type)) {
|
|
55
|
+
return defaultAfterUndefined(value, strLit(value.type.kind === "nullT" ? "null" : "undefined", loc));
|
|
56
|
+
}
|
|
57
|
+
return lowerer.ensureString(value, node);
|
|
58
|
+
}
|
|
41
59
|
/** Lower an optional argument, applying its default only to the undefined arm. */
|
|
42
60
|
export function lowerOptionalArgument(lowerer, node, expected, defaultValue) {
|
|
43
61
|
const undefinedArg = lowerStaticallyUndefinedArgument(lowerer, node);
|
|
@@ -54,4 +72,52 @@ export function lowerOptionalArgument(lowerer, node, expected, defaultValue) {
|
|
|
54
72
|
}
|
|
55
73
|
return lowerer.coerceInto(node, value, expected);
|
|
56
74
|
}
|
|
75
|
+
/** Complete an omitted or statically undefined position without dropping argument effects. */
|
|
76
|
+
export function lowerPositionArgument(lowerer, node, defaultValue) {
|
|
77
|
+
if (!node)
|
|
78
|
+
return defaultValue;
|
|
79
|
+
const undefinedArg = lowerStaticallyUndefinedArgument(lowerer, node);
|
|
80
|
+
if (undefinedArg)
|
|
81
|
+
return defaultAfterUndefined(undefinedArg, defaultValue);
|
|
82
|
+
const value = lowerer.lowerExpr(node);
|
|
83
|
+
if (isUnitType(value.type) || value.type.kind === "void") {
|
|
84
|
+
return defaultAfterUndefined(value, value.type.kind === "nullT" ? numLit(0, value.loc) : defaultValue);
|
|
85
|
+
}
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
/** Convert a stabilized position after the method has evaluated its arguments. */
|
|
89
|
+
export function positionNumber(lowerer, value, defaultValue, node, subject) {
|
|
90
|
+
const loc = value.loc;
|
|
91
|
+
switch (value.type.kind) {
|
|
92
|
+
case "f64": return value;
|
|
93
|
+
case "string": return { kind: "libCall", fn: "num.fromString", args: [value], type: F64, loc };
|
|
94
|
+
case "bool": return { kind: "ternary", cond: value, then: numLit(1, loc), else_: numLit(0, loc), type: F64, loc };
|
|
95
|
+
case "nullT": return numLit(0, loc);
|
|
96
|
+
case "undefinedT": return defaultValue;
|
|
97
|
+
case "jsval": return { kind: "jsExit", value, type: F64, loc };
|
|
98
|
+
case "union": {
|
|
99
|
+
const unionId = value.type.unionId;
|
|
100
|
+
const arms = lowerer.unions.get(unionId).arms;
|
|
101
|
+
let result = defaultValue;
|
|
102
|
+
for (let tag = arms.length - 1; tag >= 0; tag--) {
|
|
103
|
+
const narrowed = { kind: "unionNarrow", unionId, tag, value, type: arms[tag], loc };
|
|
104
|
+
const converted = positionNumber(lowerer, narrowed, defaultValue, node, subject);
|
|
105
|
+
result = tag === arms.length - 1 ? converted : {
|
|
106
|
+
kind: "ternary",
|
|
107
|
+
cond: { kind: "unionIsTag", unionId, tag, value, negated: false, type: BOOL, loc },
|
|
108
|
+
then: converted, else_: result, type: F64, loc,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
case "dyn": return {
|
|
114
|
+
kind: "ternary",
|
|
115
|
+
cond: { kind: "dynTest", test: "undefined", value, type: BOOL, loc },
|
|
116
|
+
then: defaultValue,
|
|
117
|
+
else_: { kind: "libCall", fn: "dyn.toNumberCoerce", args: [value], type: F64, loc },
|
|
118
|
+
type: F64, loc,
|
|
119
|
+
};
|
|
120
|
+
default: return lowerer.noLowering(`${subject} of '${lowerer.fmt(value.type)}' values`, node);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
57
123
|
//# sourceMappingURL=optional-arguments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional-arguments.js","sourceRoot":"","sources":["../../../src/frontend/lowering/optional-arguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"optional-arguments.js","sourceRoot":"","sources":["../../../src/frontend/lowering/optional-arguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,+EAA+E;AAC/E,MAAM,UAAU,gCAAgC,CAAC,OAAgB,EAAE,IAAmB;IACpF,MAAM,oBAAoB,GAAG,CAAC,KAAoB,EAAiB,EAAE;QACnE,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,OACE,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC;YAClC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC;YACvB,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;YACxB,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAC9B,CAAC;YACD,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IACF,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,OAAO,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC;QAAE,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAClE,IAAI,CAAC,OAAO,CAAC,MAAM,C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c,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;gBACjF,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;oBAC7C,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;oBAClF,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG;iBAC/C,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,KAAK,KAAK,EAAE,OAAO;YACjB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;YACpE,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE;YACnF,IAAI,EAAE,GAAG,EAAE,GAAG;SACf,CAAC;QACF,SAAS,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,QAAQ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAChG,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type IrExpr, type IrLibFn, type IrParam, type IrType, type SrcLoc } from "../../ir/ir.js";
|
|
2
2
|
import type { Lowerer } from "./lowerer.js";
|
|
3
3
|
/** Intern a helper that materializes a pure string-index record from a flat
|
|
4
|
-
* `[key, value, ...]` array
|
|
4
|
+
* `[key, value, ...]` array. Distinct HTTP records use the pair keys and
|
|
5
|
+
* look up each key's full string[] value. */
|
|
5
6
|
export declare function pairsSnapshotHelper(lowerer: Lowerer, shapeId: string, loc: SrcLoc, options: {
|
|
6
7
|
keyPrefix: string;
|
|
7
8
|
libCall: IrLibFn;
|
|
8
9
|
params?: IrParam[];
|
|
9
10
|
callArgs?: IrExpr[];
|
|
10
11
|
indexValueOk?: (indexValue: IrType) => boolean;
|
|
12
|
+
lookupValue?: "http.reqHeaderValues" | "http.reqTrailerValues";
|
|
11
13
|
}): string | null;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { arrayOf, BOOL, F64, STRING } from "../../ir/ir.js";
|
|
2
2
|
import { numLit, varRef } from "../../ir/build.js";
|
|
3
3
|
/** Intern a helper that materializes a pure string-index record from a flat
|
|
4
|
-
* `[key, value, ...]` array
|
|
4
|
+
* `[key, value, ...]` array. Distinct HTTP records use the pair keys and
|
|
5
|
+
* look up each key's full string[] value. */
|
|
5
6
|
export function pairsSnapshotHelper(lowerer, shapeId, loc, options) {
|
|
6
7
|
const shape = lowerer.shapes.get(shapeId);
|
|
7
8
|
if (!shape || shape.tuple || shape.fields.length > 0 || !shape.indexValue)
|
|
@@ -11,8 +12,13 @@ export function pairsSnapshotHelper(lowerer, shapeId, loc, options) {
|
|
|
11
12
|
return null;
|
|
12
13
|
if (indexValue.kind !== "union")
|
|
13
14
|
return null;
|
|
14
|
-
const stringTag = lowerer.armTag(indexValue.unionId, STRING);
|
|
15
|
-
if (
|
|
15
|
+
const stringTag = options.lookupValue ? -1 : lowerer.armTag(indexValue.unionId, STRING);
|
|
16
|
+
if (options.lookupValue) {
|
|
17
|
+
const arrayValue = lowerer.withUndefinedArm(arrayOf(STRING));
|
|
18
|
+
if (arrayValue.kind !== "union" || indexValue.unionId !== arrayValue.unionId)
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
else if (stringTag < 0)
|
|
16
22
|
return null;
|
|
17
23
|
const key = `${options.keyPrefix}.snapshot:${shapeId}`;
|
|
18
24
|
const existing = lowerer.widthHelpers.get(key);
|
|
@@ -71,7 +77,9 @@ export function pairsSnapshotHelper(lowerer, shapeId, loc, options) {
|
|
|
71
77
|
obj: varRef("out.0", recordType, loc),
|
|
72
78
|
shapeId,
|
|
73
79
|
key: pairAt(0),
|
|
74
|
-
value:
|
|
80
|
+
value: options.lookupValue
|
|
81
|
+
? { kind: "libCall", fn: options.lookupValue, args: [...(options.callArgs ?? []), pairAt(0)], type: indexValue, loc }
|
|
82
|
+
: { kind: "unionWrap", unionId: indexValue.unionId, tag: stringTag, value: pairAt(1), type: indexValue, loc },
|
|
75
83
|
loc,
|
|
76
84
|
}],
|
|
77
85
|
loc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pairs-snapshot.js","sourceRoot":"","sources":["../../../src/frontend/lowering/pairs-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAwD,MAAM,EAAe,MAAM,gBAAgB,CAAC;AAC/H,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGnD;
|
|
1
|
+
{"version":3,"file":"pairs-snapshot.js","sourceRoot":"","sources":["../../../src/frontend/lowering/pairs-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAwD,MAAM,EAAe,MAAM,gBAAgB,CAAC;AAC/H,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;6CAE6C;AAC7C,MAAM,UAAU,mBAAmB,CACjC,OAAgB,EAChB,OAAe,EACf,GAAW,EACX,OAOC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,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,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE;oBACrG,GAAG;iBACJ;gBACD,IAAI,EAAE,CAAC;wBACL,IAAI,EAAE,cAAc;wBACpB,GAAG,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC;wBACrC,OAAO;wBACP,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;wBACd,KAAK,EAAE,OAAO,CAAC,WAAW;4BACxB,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE;4BACrH,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE;wBAC/G,GAAG;qBACJ,CAAC;gBACF,GAAG;aACJ;YACD,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE;SACjE;QACD,GAAG;KACJ,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -114,8 +114,8 @@ export interface IslandFnEntry {
|
|
|
114
114
|
export declare const boundaryIntoIslandMsg: (typeName: string) => string;
|
|
115
115
|
export declare const boundaryOutOfIslandMsg: (typeName: string) => string;
|
|
116
116
|
/** The island-backed surface — standard-library APIs with no static
|
|
117
|
-
* runtime implementation (Math methods
|
|
118
|
-
*
|
|
117
|
+
* runtime implementation (Math methods outside STATIC_MATH_FNS,
|
|
118
|
+
* number/string methods beyond the
|
|
119
119
|
* intrinsic set, parseFloat, ...). ONE table drives both sides of the
|
|
120
120
|
* gate: under --dynamic each entry lowers to marshal → engine execution →
|
|
121
121
|
* validated exit to the declared return type; without the flag each use
|
|
@@ -132,8 +132,8 @@ export declare const ISLAND_SURFACE: {
|
|
|
132
132
|
/** `Math.<fn>(...)` lowers to callMethod(globalGet("Math"), fn, args);
|
|
133
133
|
* Math.PI and Math.E are compile-time numeric literals in STATIC_MATH_PROPS;
|
|
134
134
|
* remaining Math properties retain island/fence behavior.
|
|
135
|
-
*
|
|
136
|
-
*
|
|
135
|
+
* The entries here handle untabled scalar call shapes where --dynamic is
|
|
136
|
+
* available; STATIC_MATH_FNS handles the ordinary typed calls first. */
|
|
137
137
|
math: {
|
|
138
138
|
fns: Record<string, IslandFnEntry | undefined>;
|
|
139
139
|
props: Record<string, IrType | undefined>;
|
|
@@ -164,16 +164,10 @@ export declare const ISLAND_SURFACE: {
|
|
|
164
164
|
* their island/fence behavior through ISLAND_SURFACE.math.props and the
|
|
165
165
|
* generic standard-library member fence. */
|
|
166
166
|
export declare const STATIC_MATH_PROPS: Record<string, number | undefined>;
|
|
167
|
-
/** Math members with a STATIC lowering
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* (lowerIslandMethodCall), so the tabled arities compile statically and
|
|
172
|
-
* other arities keep the island/fence story — except min/max, whose
|
|
173
|
-
* variadic spelling lowers at ANY plain arity (the n-ary left fold of
|
|
174
|
-
* the scalar compare; zero arguments answer the fold's ∓Infinity seed);
|
|
175
|
-
* unioned with the island table for the methods-as-values fence
|
|
176
|
-
* (lowerMathProperty). */
|
|
167
|
+
/** Math members with a STATIC lowering. Most use the tabled arity; min/max
|
|
168
|
+
* accept any plain arity, and hypot accepts any arity including number[]
|
|
169
|
+
* spreads. Checked before the island table by lowerIslandMethodCall and
|
|
170
|
+
* included in the methods-as-values fence by lowerMathProperty. */
|
|
177
171
|
export declare const STATIC_MATH_FNS: Record<string, {
|
|
178
172
|
fn: IrLibFn;
|
|
179
173
|
arity: number;
|
|
@@ -276,6 +276,7 @@ export const ARRAY_METHODS = new Set([
|
|
|
276
276
|
"reduce",
|
|
277
277
|
"reduceRight",
|
|
278
278
|
"indexOf",
|
|
279
|
+
"lastIndexOf",
|
|
279
280
|
"includes",
|
|
280
281
|
"join",
|
|
281
282
|
"slice",
|
|
@@ -330,19 +331,19 @@ export const COMPOUND_ASSIGN_OPS = {
|
|
|
330
331
|
* parameters) that typecheck but have no lowering — those forms are fenced
|
|
331
332
|
* per site instead of silently dropping arguments. */
|
|
332
333
|
export const STR_METHODS = {
|
|
333
|
-
charCodeAt: { method: "charCodeAt", result: F64, minArgs:
|
|
334
|
-
charAt: { method: "charAt", result: STRING, minArgs:
|
|
335
|
-
indexOf: { method: "indexOf", result: F64, minArgs:
|
|
334
|
+
charCodeAt: { method: "charCodeAt", result: F64, minArgs: 0, maxArgs: 1 },
|
|
335
|
+
charAt: { method: "charAt", result: STRING, minArgs: 0, maxArgs: 1 },
|
|
336
|
+
indexOf: { method: "indexOf", result: F64, minArgs: 0, maxArgs: 2 },
|
|
336
337
|
// includes with a position argument is indexOf's clamp exactly (the
|
|
337
338
|
// spec routes both through StringIndexOf) — the emitter composes
|
|
338
339
|
// scr_str_index_of(...) != -1 for the two-argument form.
|
|
339
|
-
includes: { method: "includes", result: BOOL, minArgs:
|
|
340
|
-
startsWith: { method: "startsWith", result: BOOL, minArgs:
|
|
341
|
-
endsWith: { method: "endsWith", result: BOOL, minArgs:
|
|
340
|
+
includes: { method: "includes", result: BOOL, minArgs: 0, maxArgs: 2 },
|
|
341
|
+
startsWith: { method: "startsWith", result: BOOL, minArgs: 0, maxArgs: 2 },
|
|
342
|
+
endsWith: { method: "endsWith", result: BOOL, minArgs: 0, maxArgs: 2 },
|
|
342
343
|
slice: { method: "slice", result: STRING, minArgs: 0, maxArgs: 2 },
|
|
343
344
|
// substring: slice's clamp-and-swap sibling (negatives clamp to 0
|
|
344
345
|
// instead of counting from the end; start > end swaps).
|
|
345
|
-
substring: { method: "substring", result: STRING, minArgs:
|
|
346
|
+
substring: { method: "substring", result: STRING, minArgs: 0, maxArgs: 2 },
|
|
346
347
|
repeat: { method: "repeat", result: STRING, minArgs: 1, maxArgs: 1 },
|
|
347
348
|
trim: { method: "trim", result: STRING, minArgs: 0, maxArgs: 0 },
|
|
348
349
|
trimStart: { method: "trimStart", result: STRING, minArgs: 0, maxArgs: 0 },
|
|
@@ -358,10 +359,9 @@ export const STR_METHODS = {
|
|
|
358
359
|
// astral halves become U+FFFD (SEMANTICS.md divergence 2, the same
|
|
359
360
|
// substitution the island's boundary marshal applied).
|
|
360
361
|
split: { method: "split", result: arrayOf(STRING), minArgs: 1, maxArgs: 2 },
|
|
361
|
-
//
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
padEnd: { method: "padEnd", result: STRING, minArgs: 1, maxArgs: 2 },
|
|
362
|
+
// Padding completes omitted lengths and fill strings in its lowering.
|
|
363
|
+
padStart: { method: "padStart", result: STRING, minArgs: 0, maxArgs: 2 },
|
|
364
|
+
padEnd: { method: "padEnd", result: STRING, minArgs: 0, maxArgs: 2 },
|
|
365
365
|
// The lre-backed pair (ECMA Default Case Conversion, final sigma
|
|
366
366
|
// included — scr_regex.c): static now, no island needed; their presence
|
|
367
367
|
// flips the regex LINK switch (moduleUsesRegex).
|
|
@@ -383,8 +383,8 @@ export const boundaryOutOfIslandMsg = (typeName) => `using an 'any' value where
|
|
|
383
383
|
`(an 'any' value can only exit to numbers, strings, booleans, JSON-safe records/arrays/unions, ` +
|
|
384
384
|
`and 'T | undefined' over those)`;
|
|
385
385
|
/** The island-backed surface — standard-library APIs with no static
|
|
386
|
-
* runtime implementation (Math methods
|
|
387
|
-
*
|
|
386
|
+
* runtime implementation (Math methods outside STATIC_MATH_FNS,
|
|
387
|
+
* number/string methods beyond the
|
|
388
388
|
* intrinsic set, parseFloat, ...). ONE table drives both sides of the
|
|
389
389
|
* gate: under --dynamic each entry lowers to marshal → engine execution →
|
|
390
390
|
* validated exit to the declared return type; without the flag each use
|
|
@@ -401,11 +401,10 @@ export const ISLAND_SURFACE = {
|
|
|
401
401
|
/** `Math.<fn>(...)` lowers to callMethod(globalGet("Math"), fn, args);
|
|
402
402
|
* Math.PI and Math.E are compile-time numeric literals in STATIC_MATH_PROPS;
|
|
403
403
|
* remaining Math properties retain island/fence behavior.
|
|
404
|
-
*
|
|
405
|
-
*
|
|
404
|
+
* The entries here handle untabled scalar call shapes where --dynamic is
|
|
405
|
+
* available; STATIC_MATH_FNS handles the ordinary typed calls first. */
|
|
406
406
|
math: {
|
|
407
|
-
//
|
|
408
|
-
// (STATIC_MATH_FNS below).
|
|
407
|
+
// The static table below handles these methods at its admitted arities.
|
|
409
408
|
fns: {
|
|
410
409
|
abs: ISL_N1, acos: ISL_N1, asin: ISL_N1, atan: ISL_N1, atan2: ISL_N2,
|
|
411
410
|
cbrt: ISL_N1, ceil: ISL_N1, cos: ISL_N1, exp: ISL_N1,
|
|
@@ -456,16 +455,10 @@ export const STATIC_MATH_PROPS = {
|
|
|
456
455
|
PI: 3.141592653589793,
|
|
457
456
|
E: 2.718281828459045,
|
|
458
457
|
};
|
|
459
|
-
/** Math members with a STATIC lowering
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
* (lowerIslandMethodCall), so the tabled arities compile statically and
|
|
464
|
-
* other arities keep the island/fence story — except min/max, whose
|
|
465
|
-
* variadic spelling lowers at ANY plain arity (the n-ary left fold of
|
|
466
|
-
* the scalar compare; zero arguments answer the fold's ∓Infinity seed);
|
|
467
|
-
* unioned with the island table for the methods-as-values fence
|
|
468
|
-
* (lowerMathProperty). */
|
|
458
|
+
/** Math members with a STATIC lowering. Most use the tabled arity; min/max
|
|
459
|
+
* accept any plain arity, and hypot accepts any arity including number[]
|
|
460
|
+
* spreads. Checked before the island table by lowerIslandMethodCall and
|
|
461
|
+
* included in the methods-as-values fence by lowerMathProperty. */
|
|
469
462
|
export const STATIC_MATH_FNS = {
|
|
470
463
|
floor: { fn: "math.floor", arity: 1 },
|
|
471
464
|
abs: { fn: "math.abs", arity: 1 },
|
|
@@ -478,6 +471,22 @@ export const STATIC_MATH_FNS = {
|
|
|
478
471
|
min: { fn: "math.min", arity: 2 },
|
|
479
472
|
max: { fn: "math.max", arity: 2 },
|
|
480
473
|
random: { fn: "math.random", arity: 0 },
|
|
474
|
+
sin: { fn: "math.sin", arity: 1 },
|
|
475
|
+
cos: { fn: "math.cos", arity: 1 },
|
|
476
|
+
tan: { fn: "math.tan", arity: 1 },
|
|
477
|
+
asin: { fn: "math.asin", arity: 1 },
|
|
478
|
+
acos: { fn: "math.acos", arity: 1 },
|
|
479
|
+
atan: { fn: "math.atan", arity: 1 },
|
|
480
|
+
cbrt: { fn: "math.cbrt", arity: 1 },
|
|
481
|
+
sign: { fn: "math.sign", arity: 1 },
|
|
482
|
+
exp: { fn: "math.exp", arity: 1 },
|
|
483
|
+
sqrt: { fn: "math.sqrt", arity: 1 },
|
|
484
|
+
log: { fn: "math.log", arity: 1 },
|
|
485
|
+
log2: { fn: "math.log2", arity: 1 },
|
|
486
|
+
log10: { fn: "math.log10", arity: 1 },
|
|
487
|
+
atan2: { fn: "math.atan2", arity: 2 },
|
|
488
|
+
pow: { fn: "math.pow", arity: 2 },
|
|
489
|
+
hypot: { fn: "math.hypotArr", arity: 2 },
|
|
481
490
|
};
|
|
482
491
|
/** Number prototype methods with dedicated STATIC lowering paths. The
|
|
483
492
|
* libCall spellings are also the compiled-graph witnesses used by library
|
|
@@ -828,6 +837,7 @@ export const BUILTIN_MODULE_FNS = {
|
|
|
828
837
|
* thread machinery) and never runs as a cluster worker (cluster forks the
|
|
829
838
|
* node binary itself) — Node's own answers for a directly-run script. */
|
|
830
839
|
export const BUILTIN_MODULE_CONSTS = {
|
|
840
|
+
http: { maxHeaderSize: 16384 },
|
|
831
841
|
path: { sep: "/", delimiter: ":" },
|
|
832
842
|
"path/posix": { sep: "/", delimiter: ":" },
|
|
833
843
|
"path/win32": { sep: "\\", delimiter: ";" },
|