@scriptc/compiler 0.0.9 → 0.0.10
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/dist/backend/emission/emit-exprs.js +136 -12
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-walkers.js +29 -2
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +1 -0
- package/dist/backend/llvm/dyn.js +83 -1
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +151 -9
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +21 -7
- package/dist/diagnostics/diagnostic.js +35 -16
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/render.js +8 -0
- package/dist/diagnostics/render.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +11 -1
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +13 -0
- package/dist/frontend/lowering/lower-builtins.js +146 -1
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +41 -0
- package/dist/frontend/lowering/lower-calls.js +524 -10
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +17 -0
- package/dist/frontend/lowering/lower-containers.js +193 -10
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +92 -17
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +179 -10
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +33 -2
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +25 -11
- package/dist/frontend/lowering/lower-namespaces.js +50 -15
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +211 -4
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +1 -5
- package/dist/frontend/lowering/lower-stmts.js +216 -7
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +65 -4
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +36 -1
- package/dist/frontend/lowering/lowerer.js +106 -3
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/types.d.ts +13 -0
- package/dist/frontend/types.js +84 -7
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +99 -5
- package/dist/ir/nodes.js +44 -3
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +53 -3
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/fence-eval.d.ts +77 -0
- package/dist/library/fence-eval.js +385 -0
- package/dist/library/fence-eval.js.map +1 -0
- package/dist/library/profile.d.ts +11 -1
- package/dist/library/profile.js +102 -18
- package/dist/library/profile.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +1 -1
package/dist/frontend/types.d.ts
CHANGED
|
@@ -303,6 +303,19 @@ export declare function withUndefinedArm(t: IrType, unions: UnionRegistry): IrTy
|
|
|
303
303
|
* Object.keys over such a shape omits the member (a pin — every excluded
|
|
304
304
|
* member is a function the key walk would name). */
|
|
305
305
|
export declare function isGenericCallableMemberType(t: ts.Type, checker: ts.TypeChecker): boolean;
|
|
306
|
+
/** The `string | object`-family collapse domain (mapTypeInner's union
|
|
307
|
+
* rule): arms the checked-dynamic representation holds FAITHFULLY, so a
|
|
308
|
+
* union carrying a dyn arm beside only these maps to DYN wholesale.
|
|
309
|
+
* Scalars and units are the DOM's own kinds (value-exact ===/typeof);
|
|
310
|
+
* records and arrays qualify exactly when the dynFrom conversion can
|
|
311
|
+
* build them (canConvertToDyn — JSON-safe data plus bytes-bearing
|
|
312
|
+
* composites), entering as DOM data under the documented deep-copy
|
|
313
|
+
* stance. Everything else — class instances, Maps/Sets, functions
|
|
314
|
+
* (closure identity and `x === String` narrowing live in the typed union
|
|
315
|
+
* machinery), promises, regexes, generators, handles, nested unions —
|
|
316
|
+
* would DEGRADE (identity, methods, dispatch) riding dyn, so those arms
|
|
317
|
+
* keep their existing homes and fences. */
|
|
318
|
+
export declare function dynSubsumableUnionArm(arm: IrType, ctx: TypeMapperCtx): boolean;
|
|
306
319
|
/** When an unmapped type is a SUPPORTED container/composite whose failure
|
|
307
320
|
* lives in a component, answer a message tail naming the component (the
|
|
308
321
|
* SC2009 story); null when the shape itself is the blocker (the caller
|
package/dist/frontend/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "./ts7/adapter.js";
|
|
2
|
-
import { arrayOf, BOOL, bytesOf, CHILD_T, DYN, F64, funcOf, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, JSVAL, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, setOf, STRING, SYMBOL_T, typeEquals, typeKey, UNDEFINED_T, VOID } from "../ir/nodes.js";
|
|
2
|
+
import { arrayOf, BOOL, bytesOf, canConvertToDyn, CHILD_T, DYN, F64, funcOf, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, JSVAL, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, setOf, STRING, SYMBOL_T, typeEquals, typeKey, UNDEFINED_T, VOID } from "../ir/nodes.js";
|
|
3
3
|
import { isJsSourceFile, isNodeTypesPath } from "./program.js";
|
|
4
4
|
import { accessorSlotProp } from "../ir/nodes.js";
|
|
5
5
|
// typeKey moved to ir/nodes.ts (the backend needs it too, for per-type
|
|
@@ -813,10 +813,19 @@ function mapTypeInner(type, ctx) {
|
|
|
813
813
|
elem.kind === "fsWatcher" ||
|
|
814
814
|
elem.kind === "childStream" ||
|
|
815
815
|
elem.kind === "procStream" ||
|
|
816
|
-
elem.kind === "generator"
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
816
|
+
elem.kind === "generator") {
|
|
817
|
+
return null; // ScrArr has no closure/map/regex/url element kinds yet
|
|
818
|
+
}
|
|
819
|
+
// A dyn ELEMENT makes the WHOLE array the checked-dynamic value:
|
|
820
|
+
// `unknown[]`, `object[]`, and the collapsed `(string | object)[]`
|
|
821
|
+
// (the plugins-slot shape) — the DOM has real arrays, so length/
|
|
822
|
+
// index/push/iteration ride the keyed-DOM paths, while a dyn-element
|
|
823
|
+
// STATIC array has no backend representation (ScrArr has no dyn
|
|
824
|
+
// element kind). This is dynFallbackType's JS stance promoted into
|
|
825
|
+
// the mapping itself; construction sites build dynArrLit (the DOM
|
|
826
|
+
// array literal) and typed sources convert per element at the slot.
|
|
827
|
+
if (elem.kind === "dyn")
|
|
828
|
+
return DYN;
|
|
820
829
|
// ChildProcess[] (the running-apps list) and Server[] (the [...set]
|
|
821
830
|
// drain of the auxiliary-server registries): handles are ordinary
|
|
822
831
|
// refcounted REF elements (their `_v` adapters, no trace — both drop
|
|
@@ -2049,6 +2058,31 @@ function mapTypeInner(type, ctx) {
|
|
|
2049
2058
|
return null;
|
|
2050
2059
|
return arms[0];
|
|
2051
2060
|
}
|
|
2061
|
+
// The `string | object`-family COLLAPSE (world unification lane 3):
|
|
2062
|
+
// a union with an 'object'/'unknown'/`{}`-flavored arm (dyn) beside
|
|
2063
|
+
// arms the checked-dynamic representation FAITHFULLY holds maps to
|
|
2064
|
+
// DYN WHOLESALE — the DOM's scalar kinds ARE the scalar arms (===,
|
|
2065
|
+
// typeof, switch dispatch all exact), typeof/Array.isArray/unit
|
|
2066
|
+
// narrowing on dyn already dispatches natively (dynTest +
|
|
2067
|
+
// maybeNarrow's validated scalar extraction), and engine-valued
|
|
2068
|
+
// arms ride the island kind (SCR_DYN_JSVAL), so no per-arm runtime
|
|
2069
|
+
// tag is ever needed and the component fence retires at these
|
|
2070
|
+
// sites. The domain is dynSubsumableUnionArm's: scalars, units, dyn
|
|
2071
|
+
// itself, and records/arrays inside the dynFrom conversion domain
|
|
2072
|
+
// (those enter as DOM data — the deep-copy stance, so identity and
|
|
2073
|
+
// mutation coupling with the source value end at the slot;
|
|
2074
|
+
// SEMANTICS.md). Arms with real typed representations whose
|
|
2075
|
+
// semantics would DEGRADE under the collapse — class instances,
|
|
2076
|
+
// Maps/Sets, functions (closure identity, `x === String`
|
|
2077
|
+
// narrowing), promises, regexes, generators, handles — keep their
|
|
2078
|
+
// existing union homes and fences below. A pending recursive
|
|
2079
|
+
// placeholder cannot collapse (back-references already hold the
|
|
2080
|
+
// union id); the degenerate recursive spelling keeps its fence.
|
|
2081
|
+
if (arms.some((a) => a.kind === "dyn") &&
|
|
2082
|
+
arms.every((a) => dynSubsumableUnionArm(a, ctx)) &&
|
|
2083
|
+
!unions.recursivePending(widened)) {
|
|
2084
|
+
return DYN;
|
|
2085
|
+
}
|
|
2052
2086
|
if (arms.some((a) => a.kind === "void" || a.kind === "union" ||
|
|
2053
2087
|
// Map/Set arms stay out (like func against data arms: no
|
|
2054
2088
|
// narrowing test — no discriminant fields on them). REGEX
|
|
@@ -2932,6 +2966,34 @@ const STDLIB_CONTAINERS = {
|
|
|
2932
2966
|
Generator: { role: (i) => ["yield", "return", "next"][i] ?? "channel" },
|
|
2933
2967
|
AsyncGenerator: { role: (i) => ["yield", "return", "next"][i] ?? "channel" },
|
|
2934
2968
|
};
|
|
2969
|
+
/** The `string | object`-family collapse domain (mapTypeInner's union
|
|
2970
|
+
* rule): arms the checked-dynamic representation holds FAITHFULLY, so a
|
|
2971
|
+
* union carrying a dyn arm beside only these maps to DYN wholesale.
|
|
2972
|
+
* Scalars and units are the DOM's own kinds (value-exact ===/typeof);
|
|
2973
|
+
* records and arrays qualify exactly when the dynFrom conversion can
|
|
2974
|
+
* build them (canConvertToDyn — JSON-safe data plus bytes-bearing
|
|
2975
|
+
* composites), entering as DOM data under the documented deep-copy
|
|
2976
|
+
* stance. Everything else — class instances, Maps/Sets, functions
|
|
2977
|
+
* (closure identity and `x === String` narrowing live in the typed union
|
|
2978
|
+
* machinery), promises, regexes, generators, handles, nested unions —
|
|
2979
|
+
* would DEGRADE (identity, methods, dispatch) riding dyn, so those arms
|
|
2980
|
+
* keep their existing homes and fences. */
|
|
2981
|
+
export function dynSubsumableUnionArm(arm, ctx) {
|
|
2982
|
+
switch (arm.kind) {
|
|
2983
|
+
case "dyn":
|
|
2984
|
+
case "f64":
|
|
2985
|
+
case "string":
|
|
2986
|
+
case "bool":
|
|
2987
|
+
case "undefinedT":
|
|
2988
|
+
case "nullT":
|
|
2989
|
+
return true;
|
|
2990
|
+
case "record":
|
|
2991
|
+
case "array":
|
|
2992
|
+
return canConvertToDyn(arm, (id) => ctx.shapes.get(id), (id) => ctx.unions.get(id));
|
|
2993
|
+
default:
|
|
2994
|
+
return false;
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2935
2997
|
/** Arm kinds with no home in a compiled union (mapTypeInner's union rule):
|
|
2936
2998
|
* no runtime narrowing test exists against sibling data arms. */
|
|
2937
2999
|
function armHasUnionHome(arm, siblingCount) {
|
|
@@ -3027,8 +3089,23 @@ export function describeComponentBlocker(widened, ctx) {
|
|
|
3027
3089
|
const parts = widened.getTypes();
|
|
3028
3090
|
const UNIT = ts.TypeFlags.Undefined | ts.TypeFlags.Void | ts.TypeFlags.Null;
|
|
3029
3091
|
const dataArms = parts.filter((p) => (p.flags & UNIT) === 0);
|
|
3030
|
-
|
|
3031
|
-
|
|
3092
|
+
// A union carrying an 'object'/'unknown'-flavored arm rides the
|
|
3093
|
+
// checked-dynamic representation WHOLESALE when every sibling is
|
|
3094
|
+
// dyn-subsumable (mapTypeInner's collapse) — so when such a union
|
|
3095
|
+
// still failed, the story is the sibling that CANNOT ride the
|
|
3096
|
+
// collapse, never the dyn arm itself.
|
|
3097
|
+
const mappedArms = dataArms.map((p) => ({ p, mapped: mapType(p, ctx) }));
|
|
3098
|
+
if (mappedArms.some(({ mapped }) => mapped?.kind === "dyn")) {
|
|
3099
|
+
const blocker = mappedArms.find(({ mapped }) => mapped !== null && !dynSubsumableUnionArm(mapped, ctx));
|
|
3100
|
+
if (blocker) {
|
|
3101
|
+
return `the union shape is supported, and unions in the 'string | object' family ride the checked-dynamic representation wholesale, but '${text(blocker.p)}' arms have a typed representation whose semantics (identity, methods, dispatch) do not survive that collapse`;
|
|
3102
|
+
}
|
|
3103
|
+
// Every sibling subsumable and the union STILL failed: the
|
|
3104
|
+
// recursive-placeholder fence (a degenerate spelling) — no per-arm
|
|
3105
|
+
// story is true, so the residual fence speaks.
|
|
3106
|
+
return null;
|
|
3107
|
+
}
|
|
3108
|
+
for (const { p: part, mapped } of mappedArms) {
|
|
3032
3109
|
if (!mapped) {
|
|
3033
3110
|
return `the union shape is supported, but its arm '${text(part)}' does not compile`;
|
|
3034
3111
|
}
|