@scriptc/compiler 0.3.1 → 0.3.2
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 +342 -16
- package/dist/backend/executable-features.js +1 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/literals.d.ts +7 -0
- package/dist/backend/literals.js +32 -0
- package/dist/backend/literals.js.map +1 -1
- package/dist/backend/literals.test.js +17 -1
- package/dist/backend/literals.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +15 -4
- package/dist/backend/llvm/alloc.js +39 -15
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +15 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/appended-array-literals.d.ts +2 -0
- package/dist/backend/llvm/appended-array-literals.js +109 -0
- package/dist/backend/llvm/appended-array-literals.js.map +1 -0
- package/dist/backend/llvm/appended-array-literals.test.d.ts +1 -0
- package/dist/backend/llvm/appended-array-literals.test.js +90 -0
- package/dist/backend/llvm/appended-array-literals.test.js.map +1 -0
- package/dist/backend/llvm/call-lifetimes.d.ts +4 -1
- package/dist/backend/llvm/call-lifetimes.js +51 -3
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.js +10 -2
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +2 -2
- package/dist/backend/llvm/dense-array-access.js +17 -12
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +15 -2
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +2 -0
- package/dist/backend/llvm/dyn.js +11 -2
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +43 -2
- package/dist/backend/llvm/emitter.js +306 -32
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +122 -6
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +8 -0
- package/dist/backend/llvm/expr-callbacks.js +81 -1
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +12 -1
- package/dist/backend/llvm/expr-calls.js +126 -54
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +7 -0
- package/dist/backend/llvm/expr-containers.js +38 -7
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +2 -0
- package/dist/backend/llvm/expr-control.d.ts +8 -0
- package/dist/backend/llvm/expr-control.js +103 -69
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +2 -2
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +7 -0
- package/dist/backend/llvm/expr-primitives.js +30 -26
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +11 -1
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
- package/dist/backend/llvm/expr-stream-bridges.js +77 -8
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +49 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/int32-abi.d.ts +18 -2
- package/dist/backend/llvm/int32-abi.js +23 -2
- package/dist/backend/llvm/int32-abi.js.map +1 -1
- package/dist/backend/llvm/int32-abi.test.js +75 -1
- package/dist/backend/llvm/int32-abi.test.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +7 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +58 -0
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +76 -9
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +5 -3
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.d.ts +24 -2
- package/dist/backend/llvm/local-union-storage.js +127 -12
- package/dist/backend/llvm/local-union-storage.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +106 -1
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/record-results.d.ts +26 -0
- package/dist/backend/llvm/record-results.js +252 -0
- package/dist/backend/llvm/record-results.js.map +1 -0
- package/dist/backend/llvm/reference-effects.js +2 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +15 -9
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/regions.d.ts +67 -0
- package/dist/backend/llvm/regions.js +309 -0
- package/dist/backend/llvm/regions.js.map +1 -0
- package/dist/backend/llvm/regions.test.d.ts +1 -0
- package/dist/backend/llvm/regions.test.js +173 -0
- package/dist/backend/llvm/regions.test.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +34 -7
- package/dist/backend/llvm/shapes.js +31 -16
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +7 -6
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/split-loops.js +1 -1
- package/dist/backend/llvm/split-loops.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +29 -0
- package/dist/backend/llvm/stack-objects.js +130 -0
- package/dist/backend/llvm/stack-objects.js.map +1 -0
- package/dist/backend/llvm/stack-objects.test.d.ts +1 -0
- package/dist/backend/llvm/stack-objects.test.js +252 -0
- package/dist/backend/llvm/stack-objects.test.js.map +1 -0
- package/dist/backend/llvm/string-reads.d.ts +4 -1
- package/dist/backend/llvm/string-reads.js +89 -9
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.js +5 -4
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +2 -0
- package/dist/backend/llvm/walkers.js +4 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +1 -0
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +5 -0
- package/dist/backend/native/executable.js +16 -1
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +1 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +2 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +1 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +1 -0
- package/dist/backend/runtime-pack-core.js +1 -0
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack.test.js +1 -1
- package/dist/backend/target-diagnostics.js +14 -0
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +13 -0
- package/dist/backend/target-diagnostics.test.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +1 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/frontend/experimental-import.d.ts +12 -0
- package/dist/frontend/experimental-import.js +63 -0
- package/dist/frontend/experimental-import.js.map +1 -0
- package/dist/frontend/lowering/builtin-calls.d.ts +6 -1
- package/dist/frontend/lowering/builtin-calls.js +36 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/console.d.ts +16 -6
- package/dist/frontend/lowering/builtins/console.js +33 -9
- package/dist/frontend/lowering/builtins/console.js.map +1 -1
- package/dist/frontend/lowering/builtins/errors.js +20 -0
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.d.ts +2 -2
- package/dist/frontend/lowering/builtins/json.js +13 -4
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +16 -1
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +1 -0
- package/dist/frontend/lowering/builtins/numbers.js +17 -0
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +18 -0
- package/dist/frontend/lowering/builtins/operating-system.js +361 -1
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.js +15 -3
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +109 -2
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.d.ts +3 -4
- package/dist/frontend/lowering/builtins/text-codecs.js +3 -4
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/checked-promise-all.d.ts +10 -3
- package/dist/frontend/lowering/checked-promise-all.js +52 -6
- package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +6 -3
- package/dist/frontend/lowering/class-dynamic-dispatch.js +54 -31
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +34 -4
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +8 -4
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.js +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +91 -0
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.d.ts +18 -2
- package/dist/frontend/lowering/cycle-initialization.js +166 -12
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.js +7 -2
- package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.test.js +28 -0
- package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +5 -56
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
- package/dist/frontend/lowering/generator-delegation.js +231 -10
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/lifetime-regions.d.ts +11 -0
- package/dist/frontend/lowering/lifetime-regions.js +216 -0
- package/dist/frontend/lowering/lifetime-regions.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +28 -2
- package/dist/frontend/lowering/lower-array-sort.js +100 -3
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +99 -2
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +72 -102
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +4 -3
- package/dist/frontend/lowering/lower-classes.js +116 -2
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-console.d.ts +13 -0
- package/dist/frontend/lowering/lower-console.js +460 -4
- package/dist/frontend/lowering/lower-console.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -0
- package/dist/frontend/lowering/lower-event-emitter.js +124 -38
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +137 -22
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +15 -7
- package/dist/frontend/lowering/lower-generators.js +183 -99
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +8 -1
- package/dist/frontend/lowering/lower-inspect.js +119 -18
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +20 -14
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +4 -0
- package/dist/frontend/lowering/lower-stdlib.js +35 -1
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +66 -11
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +22 -1
- package/dist/frontend/lowering/lowerer.js +116 -8
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/regex-span-reads.d.ts +12 -0
- package/dist/frontend/lowering/regex-span-reads.js +164 -0
- package/dist/frontend/lowering/regex-span-reads.js.map +1 -0
- package/dist/frontend/lowering/surfaces.js +112 -10
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/var-hoisting.d.ts +3 -0
- package/dist/frontend/lowering/var-hoisting.js +261 -0
- package/dist/frontend/lowering/var-hoisting.js.map +1 -0
- package/dist/frontend/pipeline.js +5 -3
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program.d.ts +3 -2
- package/dist/frontend/program.js +23 -5
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +13 -0
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +13 -1
- package/dist/frontend/type-mapper.js +146 -13
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +29 -2
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +145 -15
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/function-references.test.js +1 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/int32-slots.js +1 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/intrinsic-signatures.js +2 -0
- package/dist/ir/intrinsic-signatures.js.map +1 -1
- package/dist/ir/ir.d.ts +65 -20
- package/dist/ir/ir.js +5 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +1 -0
- package/dist/ir/runtime-features.js +35 -1
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.js +1 -2
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/validate.js +150 -25
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +65 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/ir-policy.js +1 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/native/sanitizer.test.js +1 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +159 -1
|
@@ -30,6 +30,7 @@ import { type GenericFnInfo, type GenericInstance } from "./generic-functions.js
|
|
|
30
30
|
import type { InstantiationPath } from "./instantiation-path.js";
|
|
31
31
|
import { type ArrayHofInfo } from "./containers/array-pipelines.js";
|
|
32
32
|
import { type ComputedEventPattern, type EmitSpecCtx, type EmitSpecRequest, type EventSig } from "./lower-event-emitter.js";
|
|
33
|
+
import { type ConsoleMethodMember, type ConsoleOutputMember } from "./builtins/console.js";
|
|
33
34
|
import { type FieldTarget } from "./lower-exprs.js";
|
|
34
35
|
import type { ExpandoMembers } from "./lower-expando.js";
|
|
35
36
|
/** Entry function name. '%' cannot appear in a TS identifier, so a user
|
|
@@ -427,6 +428,9 @@ export declare class Lowerer {
|
|
|
427
428
|
/** All storage slots widened for runtime absence, including slots whose
|
|
428
429
|
* current control-flow branch has temporarily narrowed the value. */
|
|
429
430
|
readonly runtimeOptionalStorageLocals: Set<IrLocal>;
|
|
431
|
+
/** `var` bindings code can read before their first store
|
|
432
|
+
* (var-hoisting.ts): their storage holds undefined until then. */
|
|
433
|
+
readonly earlyReadVars: Set<ts.Symbol>;
|
|
430
434
|
/** Globals whose checker-bare type was widened because an indexed read can
|
|
431
435
|
* carry undefined at runtime. Identifier reads keep the union tag so
|
|
432
436
|
* typeof and later boundaries observe the real value. */
|
|
@@ -440,6 +444,9 @@ export declare class Lowerer {
|
|
|
440
444
|
* prepass. This includes explicit annotations: unchecked TS annotations do
|
|
441
445
|
* not prove that an array property read produced a value. */
|
|
442
446
|
readonly runtimeOptionalBindingTypes: Map<ts.Symbol, IrType>;
|
|
447
|
+
/** Set when a match result lowers to execGroups/matchGroups, the inputs
|
|
448
|
+
* of regex span folding. */
|
|
449
|
+
regexGroupResults: boolean;
|
|
443
450
|
/** Bindings that receive an unchecked indexed read (or a value derived
|
|
444
451
|
* from one) through an initializer or assignment. The checker narrows a
|
|
445
452
|
* declared optional binding to that read's bare type, so presence tests
|
|
@@ -745,6 +752,12 @@ export declare class Lowerer {
|
|
|
745
752
|
readonly workerTargets: readonly ts.SourceFile[];
|
|
746
753
|
readonly workerTargetIdByPath: Map<string, number>;
|
|
747
754
|
usesWorkers: boolean;
|
|
755
|
+
/** The program constructs a LifetimeRegion (lifetime-regions.ts). */
|
|
756
|
+
usesLifetimeRegions: boolean;
|
|
757
|
+
/** Per-directory answers of experimental-import.ts's declaration-file test. */
|
|
758
|
+
readonly experimentalFiles: Map<string, boolean>;
|
|
759
|
+
/** Interned LifetimeRegion.run helpers, by callback type key. */
|
|
760
|
+
readonly regionRunHelpers: Map<string, string>;
|
|
748
761
|
readonly forkTargetIdByPath: Map<string, number>;
|
|
749
762
|
/** Namespace ModuleBlocks this program lowers, filled by splitFiles:
|
|
750
763
|
* "flattened" — an instantiated namespace whose body joined the file's
|
|
@@ -851,6 +864,9 @@ export declare class Lowerer {
|
|
|
851
864
|
/** Import-cycle bindings with an initialization flag, by global id, and
|
|
852
865
|
* the top-level statements declaring them (cycle-initialization.ts). */
|
|
853
866
|
readonly cycleInitFlags: Map<string, CycleInitFlag>;
|
|
867
|
+
/** Initialization flags of classes reachable before their statement ran,
|
|
868
|
+
* by class name (cycle-initialization.ts). */
|
|
869
|
+
readonly classInitFlags: Map<string, CycleInitFlag>;
|
|
854
870
|
readonly cycleInitDeclarations: Map<ts.StatementBase, CycleInitFlag[]>;
|
|
855
871
|
get ctx(): FnCtx;
|
|
856
872
|
get scopes(): Map<ts.Symbol, IrLocal>[];
|
|
@@ -867,6 +883,9 @@ export declare class Lowerer {
|
|
|
867
883
|
/** Set while a subclass constructor's super() call notes its base
|
|
868
884
|
* constructor edge: that edge does not instantiate the base exactly. */
|
|
869
885
|
private superConstructorEdge;
|
|
886
|
+
/** Set when the async generator `return` being lowered awaited its
|
|
887
|
+
* promise operand (returnedPromiseAwait). */
|
|
888
|
+
private returnAwaitedPromise;
|
|
870
889
|
private readonly virtualEdges;
|
|
871
890
|
classCanBeConstructed(info: ClassInfo): boolean;
|
|
872
891
|
/** Coverage remainder mode: the reachability gate inverts (see wantBody)
|
|
@@ -1453,6 +1472,7 @@ export declare class Lowerer {
|
|
|
1453
1472
|
* caller never sees a value, so the return goes out bare. Async
|
|
1454
1473
|
* void-inner returns still resolve a returned promise first. */
|
|
1455
1474
|
lowerReturnStmt(node: ts.Expression, loc: SrcLoc): IrStmt;
|
|
1475
|
+
private lowerReturnOf;
|
|
1456
1476
|
maybeNarrow(expr: IrExpr, node: ts.Node): IrExpr;
|
|
1457
1477
|
lowerUnitComparison(left: IrExpr, right: IrExpr, negated: boolean, loc: SrcLoc): IrExpr | null;
|
|
1458
1478
|
lowerNullishCoalesce(expr: ts.BinaryExpression, loc: SrcLoc): IrExpr;
|
|
@@ -1856,7 +1876,8 @@ export declare class Lowerer {
|
|
|
1856
1876
|
rejectComptimeCaptures(cb: ts.ArrowFunction | ts.FunctionExpression): void;
|
|
1857
1877
|
comptimeValueToIr(value: unknown, expected: IrType, path: string, blame: ts.Node): IrExpr;
|
|
1858
1878
|
isConsoleLog(call: ts.CallExpression): boolean;
|
|
1859
|
-
consoleCallMember(call: ts.CallExpression):
|
|
1879
|
+
consoleCallMember(call: ts.CallExpression): ConsoleOutputMember | null;
|
|
1880
|
+
consoleMethodMember(call: ts.CallExpression): ConsoleMethodMember | null;
|
|
1860
1881
|
builtinImportOf(ident: ts.Identifier): {
|
|
1861
1882
|
module: string;
|
|
1862
1883
|
member: string;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { lifetimeRegionType, lowerLifetimeRegionCall, lowerLifetimeRegionNew, } from "./lifetime-regions.js";
|
|
2
|
+
import { isExperimentalDeclarationFile } from "../experimental-import.js";
|
|
1
3
|
import { checkCycleBindingAccesses, refuseUncheckedCycleReads, } from "./cycle-initialization.js";
|
|
2
4
|
import { identityPreservingWidening } from "./coercions/identity.js";
|
|
3
5
|
import { scanDivergences } from "./divergences.js";
|
|
4
6
|
import { checkedClassAssertion } from "./class-assertions.js";
|
|
5
7
|
import { narrowStoredClassValue, narrowGenericClassValue } from "./class-unions.js";
|
|
6
8
|
import { isOptionalProcessStreamProperty } from "./builtins/process.js";
|
|
9
|
+
import { isSettledIteratorValueRead } from "./lower-generators.js";
|
|
7
10
|
import { concreteCollectionNarrow } from "./collection-narrowing.js";
|
|
8
11
|
import { lowerWorkerMetadata } from "./builtins/workers.js";
|
|
9
12
|
import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
|
|
@@ -16,6 +19,7 @@ import { funcReturnWidthAdapter, coercibleValue, cleanFuncAdaptable, funcCoerceA
|
|
|
16
19
|
import { unionRetagMappable, narrowedRetagHelper, strandedUnitTrap, strandedCoercionTrap, recordUnionWrapHelper, unionRetagHelper, narrowedArmHelper, checkedNarrowCall, checkedNarrowOperand, deferredReadHelper, } from "./coercions/unions.js";
|
|
17
20
|
import { lowerUtilTypeValue, pathModuleValue, utilTypesModuleValue, } from "./lower-builtin-values.js";
|
|
18
21
|
import { devirtualizeVirtualCalls } from "./devirtualize.js";
|
|
22
|
+
import { foldRegexSpanReads } from "./regex-span-reads.js";
|
|
19
23
|
import { RuntimeOptionalProvenance } from "./runtime-optional-provenance.js";
|
|
20
24
|
import { presentAtUse, reassignedBindings } from "./runtime-optional-guards.js";
|
|
21
25
|
import { NarrowingStability } from "./narrowing-stability.js";
|
|
@@ -33,6 +37,8 @@ import { InternalCompilerError } from "../../errors.js";
|
|
|
33
37
|
import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optional-arguments.js";
|
|
34
38
|
import { ClassDynamicDispatch, trackClassFieldCreation } from "./class-dynamic-dispatch.js";
|
|
35
39
|
import { ClassProtocols } from "./class-protocols.js";
|
|
40
|
+
import { earlyReadVarSymbols } from "./var-hoisting.js";
|
|
41
|
+
import { recordTextCodecClass } from "../../ir/ir.js";
|
|
36
42
|
import { DeferredModuleInitializers } from "./deferred-module-initializers.js";
|
|
37
43
|
import { finalizeClassMethodValues } from "./class-method-values.js";
|
|
38
44
|
export { newFnCtx } from "./function-context.js";
|
|
@@ -60,7 +66,7 @@ import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, c
|
|
|
60
66
|
import { arrayOf, BOOL, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
|
|
61
67
|
import { provenanceActive } from "../provenance-registry.js";
|
|
62
68
|
import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, fallbackDtsPath, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
|
|
63
|
-
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType, FETCH_AMBIENT_TYPES, isUnitOnlyTsType, isWorkerHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
|
|
69
|
+
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType, FETCH_AMBIENT_TYPES, isOsConstantsSymbol, isUnitOnlyTsType, isWorkerHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
|
|
64
70
|
import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
|
|
65
71
|
import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
|
|
66
72
|
import { prepareCjsModuleGraph } from "./lower-node-module.js";
|
|
@@ -104,14 +110,14 @@ import { lowerReadlineMethodCall } from "./builtins/readline.js";
|
|
|
104
110
|
import { lowerDiagnosticsChannelMethodCall, lowerDiagnosticsChannelProperty, lowerAsyncLocalStorageMethodCall, lowerTracingChannelMethodCall, lowerTracingChannelProperty, } from "./builtins/async-context.js";
|
|
105
111
|
import { lowerErrorCodeProperty } from "./builtins/errors.js";
|
|
106
112
|
import { lowerProcessProperty, lowerProcessMethodCall, lowerProcessOptionalMethodCall, lowerProcessStreamProperty, } from "./builtins/process.js";
|
|
107
|
-
import { isConsoleLog,
|
|
113
|
+
import { consoleCallMember, consoleMethodMember, isConsoleLog, } from "./builtins/console.js";
|
|
108
114
|
import { lowerConsoleNew } from "./lower-console.js";
|
|
109
115
|
import { lowerNumberStaticCall, lowerNumberStaticProperty } from "./builtins/numbers.js";
|
|
110
116
|
import { lowerDateCall } from "./builtins/dates.js";
|
|
111
117
|
import { lowerFsConstantsProperty, lowerBuiltinConstantsProperty, builtinConstantBindingOf, builtinConstantsDestructureDecl, } from "./builtins/constants.js";
|
|
112
118
|
import { lowerStringStaticCall, lowerStringLastIndexOfCall } from "./builtins/strings.js";
|
|
113
119
|
import { lowerPromiseStaticCall } from "./builtins/promises.js";
|
|
114
|
-
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
|
|
120
|
+
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerEventTargetNew, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
|
|
115
121
|
import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty, lowerTlsRootCertificates, } from "./lower-server.js";
|
|
116
122
|
import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
|
|
117
123
|
import { lowerNodeTestModuleCall, lowerTestDirectCall, lowerTestMethodCall, lowerTestCtxProperty, } from "./lower-test.js";
|
|
@@ -1116,6 +1122,9 @@ export class Lowerer {
|
|
|
1116
1122
|
/** All storage slots widened for runtime absence, including slots whose
|
|
1117
1123
|
* current control-flow branch has temporarily narrowed the value. */
|
|
1118
1124
|
runtimeOptionalStorageLocals = new Set();
|
|
1125
|
+
/** `var` bindings code can read before their first store
|
|
1126
|
+
* (var-hoisting.ts): their storage holds undefined until then. */
|
|
1127
|
+
earlyReadVars = new Set();
|
|
1119
1128
|
/** Globals whose checker-bare type was widened because an indexed read can
|
|
1120
1129
|
* carry undefined at runtime. Identifier reads keep the union tag so
|
|
1121
1130
|
* typeof and later boundaries observe the real value. */
|
|
@@ -1129,6 +1138,9 @@ export class Lowerer {
|
|
|
1129
1138
|
* prepass. This includes explicit annotations: unchecked TS annotations do
|
|
1130
1139
|
* not prove that an array property read produced a value. */
|
|
1131
1140
|
runtimeOptionalBindingTypes = new Map();
|
|
1141
|
+
/** Set when a match result lowers to execGroups/matchGroups, the inputs
|
|
1142
|
+
* of regex span folding. */
|
|
1143
|
+
regexGroupResults = false;
|
|
1132
1144
|
/** Bindings that receive an unchecked indexed read (or a value derived
|
|
1133
1145
|
* from one) through an initializer or assignment. The checker narrows a
|
|
1134
1146
|
* declared optional binding to that read's bare type, so presence tests
|
|
@@ -1655,6 +1667,12 @@ export class Lowerer {
|
|
|
1655
1667
|
workerTargets;
|
|
1656
1668
|
workerTargetIdByPath = new Map();
|
|
1657
1669
|
usesWorkers = false;
|
|
1670
|
+
/** The program constructs a LifetimeRegion (lifetime-regions.ts). */
|
|
1671
|
+
usesLifetimeRegions = false;
|
|
1672
|
+
/** Per-directory answers of experimental-import.ts's declaration-file test. */
|
|
1673
|
+
experimentalFiles = new Map();
|
|
1674
|
+
/** Interned LifetimeRegion.run helpers, by callback type key. */
|
|
1675
|
+
regionRunHelpers = new Map();
|
|
1658
1676
|
forkTargetIdByPath = new Map();
|
|
1659
1677
|
/** Namespace ModuleBlocks this program lowers, filled by splitFiles:
|
|
1660
1678
|
* "flattened" — an instantiated namespace whose body joined the file's
|
|
@@ -1761,6 +1779,9 @@ export class Lowerer {
|
|
|
1761
1779
|
/** Import-cycle bindings with an initialization flag, by global id, and
|
|
1762
1780
|
* the top-level statements declaring them (cycle-initialization.ts). */
|
|
1763
1781
|
cycleInitFlags = new Map();
|
|
1782
|
+
/** Initialization flags of classes reachable before their statement ran,
|
|
1783
|
+
* by class name (cycle-initialization.ts). */
|
|
1784
|
+
classInitFlags = new Map();
|
|
1764
1785
|
cycleInitDeclarations = new Map();
|
|
1765
1786
|
get ctx() {
|
|
1766
1787
|
const top = this.fnStack[this.fnStack.length - 1];
|
|
@@ -1784,6 +1805,9 @@ export class Lowerer {
|
|
|
1784
1805
|
/** Set while a subclass constructor's super() call notes its base
|
|
1785
1806
|
* constructor edge: that edge does not instantiate the base exactly. */
|
|
1786
1807
|
superConstructorEdge = false;
|
|
1808
|
+
/** Set when the async generator `return` being lowered awaited its
|
|
1809
|
+
* promise operand (returnedPromiseAwait). */
|
|
1810
|
+
returnAwaitedPromise = false;
|
|
1787
1811
|
virtualEdges = new Map();
|
|
1788
1812
|
classCanBeConstructed(info) {
|
|
1789
1813
|
return (this.constructedClasses === null ||
|
|
@@ -1963,6 +1987,9 @@ export class Lowerer {
|
|
|
1963
1987
|
// fileTag is filled just below; the hook is only ever CALLED during
|
|
1964
1988
|
// lowering, long after the constructor completes.
|
|
1965
1989
|
isProgramFile: (sf) => this.fileTag.has(sf),
|
|
1990
|
+
lifetimeRegionClass: (decl) => isExperimentalDeclarationFile(decl.getSourceFile(), this.experimentalFiles)
|
|
1991
|
+
? lifetimeRegionType(this)
|
|
1992
|
+
: null,
|
|
1966
1993
|
moduleNamespaceId: (type) => this.moduleNamespaceIdOfType(type),
|
|
1967
1994
|
};
|
|
1968
1995
|
// Modules reachable only through literal import() joined
|
|
@@ -3009,6 +3036,17 @@ export class Lowerer {
|
|
|
3009
3036
|
familyBySymbol.set(symbol, family);
|
|
3010
3037
|
}
|
|
3011
3038
|
}
|
|
3039
|
+
// Static methods never share a dispatch slot: each is its own family.
|
|
3040
|
+
if (info.staticMethods) {
|
|
3041
|
+
for (const sig of info.staticMethods.values()) {
|
|
3042
|
+
const name = sig.member.name;
|
|
3043
|
+
if (!(ts.isIdentifier(name) || ts.isStringLiteral(name)))
|
|
3044
|
+
continue;
|
|
3045
|
+
const symbol = symbolOf(name);
|
|
3046
|
+
if (symbol && !signatureBySymbol.has(symbol))
|
|
3047
|
+
signatureBySymbol.set(symbol, { params: sig.params, returnType: sig.ret, method: sig });
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3012
3050
|
}
|
|
3013
3051
|
const mappedOrNull = (node) => panicSafe(() => this.mapTypeOf(this.typeOf(node)), null);
|
|
3014
3052
|
const nanCoded = new NanCodedReads({
|
|
@@ -3228,6 +3266,10 @@ export class Lowerer {
|
|
|
3228
3266
|
return true;
|
|
3229
3267
|
if (ts.isPropertyAccessExpression(e) && isOptionalProcessStreamProperty(this, e))
|
|
3230
3268
|
return true;
|
|
3269
|
+
if (ts.isPropertyAccessExpression(e) && isSettledIteratorValueRead(this, e))
|
|
3270
|
+
return true;
|
|
3271
|
+
if (ts.isPropertyAccessExpression(e) && isOsConstantsSymbol(symbolOf(e.expression), this))
|
|
3272
|
+
return true;
|
|
3231
3273
|
if (ts.isCallExpression(e) && this.runtimeOptionalReduceTypes.has(e))
|
|
3232
3274
|
return true;
|
|
3233
3275
|
if (ts.isCallExpression(e) &&
|
|
@@ -3520,6 +3562,19 @@ export class Lowerer {
|
|
|
3520
3562
|
found = true;
|
|
3521
3563
|
return found;
|
|
3522
3564
|
};
|
|
3565
|
+
/** A return of a var that code can read before its first store. */
|
|
3566
|
+
const returnsEarlyVar = (fn) => {
|
|
3567
|
+
const early = (e) => {
|
|
3568
|
+
const read = peel(e);
|
|
3569
|
+
if (!ts.isIdentifier(read))
|
|
3570
|
+
return false;
|
|
3571
|
+
const symbol = symbolOf(read);
|
|
3572
|
+
return symbol !== null && this.earlyReadVars.has(symbol);
|
|
3573
|
+
};
|
|
3574
|
+
if (fn.body && !ts.isBlock(fn.body))
|
|
3575
|
+
return early(fn.body);
|
|
3576
|
+
return returnsOf(fn).some(early);
|
|
3577
|
+
};
|
|
3523
3578
|
const jsLambdas = [];
|
|
3524
3579
|
// TypeScript lambdas keep the checker's inferred return type, which
|
|
3525
3580
|
// spells a missing read as its bare element type and `read ?? "text"`
|
|
@@ -4529,6 +4584,19 @@ export class Lowerer {
|
|
|
4529
4584
|
}
|
|
4530
4585
|
return changed;
|
|
4531
4586
|
};
|
|
4587
|
+
// A `var` that code can read before its first store holds undefined
|
|
4588
|
+
// there, whatever its declared type.
|
|
4589
|
+
for (const symbol of earlyReadVarSymbols(this, sourceFiles)) {
|
|
4590
|
+
// Text codec bindings keep their own presence-checked storage.
|
|
4591
|
+
const declaration = this.checker.valueDeclarationOf(symbol);
|
|
4592
|
+
const mapped = declaration && ts.isVariableDeclaration(declaration)
|
|
4593
|
+
? mappedOrNull(declaration.name)
|
|
4594
|
+
: null;
|
|
4595
|
+
if (mapped?.kind === "record" && recordTextCodecClass(this.shapes.get(mapped.shapeId)))
|
|
4596
|
+
continue;
|
|
4597
|
+
optionalSymbols.add(symbol);
|
|
4598
|
+
this.earlyReadVars.add(symbol);
|
|
4599
|
+
}
|
|
4532
4600
|
let changed = true;
|
|
4533
4601
|
while (changed) {
|
|
4534
4602
|
changed = false;
|
|
@@ -4546,8 +4614,10 @@ export class Lowerer {
|
|
|
4546
4614
|
if (scanReturns(symbol, decl))
|
|
4547
4615
|
changed = true;
|
|
4548
4616
|
for (const fn of tsLambdas) {
|
|
4549
|
-
// An annotated return is the author's contract, as for parameters
|
|
4550
|
-
|
|
4617
|
+
// An annotated return is the author's contract, as for parameters,
|
|
4618
|
+
// except that a var read before its first store is undefined
|
|
4619
|
+
// whatever the annotation says.
|
|
4620
|
+
if (fn.type && !returnsEarlyVar(fn))
|
|
4551
4621
|
continue;
|
|
4552
4622
|
const mapped = this.mapTypeOf(this.typeOf(fn));
|
|
4553
4623
|
if (mapped?.kind !== "func")
|
|
@@ -5107,6 +5177,7 @@ export class Lowerer {
|
|
|
5107
5177
|
globals: this.globalsList,
|
|
5108
5178
|
entry: ENTRY_NAME,
|
|
5109
5179
|
...(this.usesWorkers ? { workers: true } : {}),
|
|
5180
|
+
...(this.usesLifetimeRegions ? { lifetimeRegions: true } : {}),
|
|
5110
5181
|
...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
|
|
5111
5182
|
...(this.ffiImports.length > 0 ? { ffiImports: [...this.ffiImports] } : {}),
|
|
5112
5183
|
};
|
|
@@ -5291,6 +5362,8 @@ export class Lowerer {
|
|
|
5291
5362
|
for (const info of this.classes.values()) {
|
|
5292
5363
|
if (info.builtinError)
|
|
5293
5364
|
continue; // runtime-provided; nothing lowers
|
|
5365
|
+
if (info.lifetimeRegion)
|
|
5366
|
+
continue; // synthesized with the class
|
|
5294
5367
|
// Generic-class INSTANTIATIONS (and mixin instantiations) are
|
|
5295
5368
|
// demand-driven, not units: their members lower unconditionally in
|
|
5296
5369
|
// the instance drain below — the generic-fn instance rule.
|
|
@@ -5606,6 +5679,9 @@ export class Lowerer {
|
|
|
5606
5679
|
...this.liftedFns,
|
|
5607
5680
|
...this.implicitFns,
|
|
5608
5681
|
];
|
|
5682
|
+
if (this.regexGroupResults)
|
|
5683
|
+
for (const fn of functions)
|
|
5684
|
+
foldRegexSpanReads(this, fn);
|
|
5609
5685
|
// The worklist can leave a virtual site with a single implementation.
|
|
5610
5686
|
// Devirtualize after construction/override reachability has settled.
|
|
5611
5687
|
devirtualizeVirtualCalls(this, functions, {
|
|
@@ -7496,8 +7572,10 @@ export class Lowerer {
|
|
|
7496
7572
|
returnedPromiseAwait(e) {
|
|
7497
7573
|
if (e.type.kind !== "promise")
|
|
7498
7574
|
throw new InternalCompilerError("returned-promise await of a non-promise");
|
|
7499
|
-
if (!this.adoptsReturnedPromise())
|
|
7575
|
+
if (!this.adoptsReturnedPromise()) {
|
|
7576
|
+
this.returnAwaitedPromise = true;
|
|
7500
7577
|
return { kind: "awaitExpr", value: e, type: e.type.inner, loc: e.loc };
|
|
7578
|
+
}
|
|
7501
7579
|
return { kind: "awaitExpr", value: e, type: e.type.inner, adopt: true, loc: e.loc };
|
|
7502
7580
|
}
|
|
7503
7581
|
/** `return <expr>` lowered as a STATEMENT against the declared return.
|
|
@@ -7507,6 +7585,26 @@ export class Lowerer {
|
|
|
7507
7585
|
* caller never sees a value, so the return goes out bare. Async
|
|
7508
7586
|
* void-inner returns still resolve a returned promise first. */
|
|
7509
7587
|
lowerReturnStmt(node, loc) {
|
|
7588
|
+
if (!(this.ctx.isAsync === true && this.ctx.generator))
|
|
7589
|
+
return this.lowerReturnOf(node, loc);
|
|
7590
|
+
// An async generator's `return x` awaits x; for a promise that await
|
|
7591
|
+
// is the returned-promise await, and the return needs no other turn.
|
|
7592
|
+
const saved = this.returnAwaitedPromise;
|
|
7593
|
+
this.returnAwaitedPromise = false;
|
|
7594
|
+
const s = this.lowerReturnOf(node, loc);
|
|
7595
|
+
const awaited = this.returnAwaitedPromise;
|
|
7596
|
+
this.returnAwaitedPromise = saved;
|
|
7597
|
+
if (!awaited)
|
|
7598
|
+
return s;
|
|
7599
|
+
if (s.kind === "return")
|
|
7600
|
+
return { ...s, awaited: true };
|
|
7601
|
+
if (s.kind === "block" && s.body.at(-1)?.kind === "return") {
|
|
7602
|
+
const last = s.body.at(-1);
|
|
7603
|
+
return { ...s, body: [...s.body.slice(0, -1), { ...last, awaited: true }] };
|
|
7604
|
+
}
|
|
7605
|
+
return s;
|
|
7606
|
+
}
|
|
7607
|
+
lowerReturnOf(node, loc) {
|
|
7510
7608
|
const expected = this.ctx.returnType;
|
|
7511
7609
|
if (expected.kind === "void") {
|
|
7512
7610
|
let e = this.lowerExpr(node);
|
|
@@ -8945,7 +9043,8 @@ export class Lowerer {
|
|
|
8945
9043
|
// dispatch. The general identifier-call paths have no lowering for a
|
|
8946
9044
|
// promise-returning ambient global, and `import` is a keyword callee no
|
|
8947
9045
|
// identifier path matches.
|
|
8948
|
-
return (
|
|
9046
|
+
return (lowerLifetimeRegionCall(this, expr) ??
|
|
9047
|
+
lowerFfiCall(this, expr) ??
|
|
8949
9048
|
lowerFetchCall(this, expr) ??
|
|
8950
9049
|
lowerStaticFetchCompanionCall(this, expr) ??
|
|
8951
9050
|
lowerStaticAbortControllerCall(this, expr) ??
|
|
@@ -9080,7 +9179,9 @@ export class Lowerer {
|
|
|
9080
9179
|
return inheritsBuiltinEmitterCtor(this, info);
|
|
9081
9180
|
}
|
|
9082
9181
|
lowerNew(expr) {
|
|
9083
|
-
const builtin =
|
|
9182
|
+
const builtin = lowerLifetimeRegionNew(this, expr) ??
|
|
9183
|
+
lowerAbortControllerNew(this, expr) ??
|
|
9184
|
+
lowerEventTargetNew(this, expr) ??
|
|
9084
9185
|
lowerFetchWebNew(this, expr) ??
|
|
9085
9186
|
lowerResponseNew(this, expr) ??
|
|
9086
9187
|
lowerStaticReadableStreamNew(this, expr) ??
|
|
@@ -9135,6 +9236,9 @@ export class Lowerer {
|
|
|
9135
9236
|
consoleCallMember(call) {
|
|
9136
9237
|
return consoleCallMember(this, call);
|
|
9137
9238
|
}
|
|
9239
|
+
consoleMethodMember(call) {
|
|
9240
|
+
return consoleMethodMember(this, call);
|
|
9241
|
+
}
|
|
9138
9242
|
/* ── standard library (process + node:fs) ─────────────────────────── */
|
|
9139
9243
|
builtinImportOf(ident) {
|
|
9140
9244
|
return builtinImportOf(this, ident);
|
|
@@ -9361,6 +9465,10 @@ export class Lowerer {
|
|
|
9361
9465
|
if (bi.module === "http" && bi.member === "STATUS_CODES") {
|
|
9362
9466
|
return { kind: "libCall", fn: "http.statusCodes", args: [], type: DYN, loc };
|
|
9363
9467
|
}
|
|
9468
|
+
// os.constants: the runtime's null-prototype constants object.
|
|
9469
|
+
if (bi.module === "os" && bi.member === "constants") {
|
|
9470
|
+
return { kind: "libCall", fn: "os.constants", args: [], type: DYN, loc };
|
|
9471
|
+
}
|
|
9364
9472
|
// tls.rootCertificates through the namespace: the same runtime-valued
|
|
9365
9473
|
// constant the named-import read lowers to.
|
|
9366
9474
|
{
|