@geastack/compiler 1.0.32 → 1.0.34
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 +1 -1
- package/dist/cli-coverage.js +2 -4
- package/dist/cli-emit.js +1 -1
- package/dist/cli-module-graph.js +1 -1
- package/dist/cli.js +2 -1
- package/dist/compiler.js +35 -28
- package/dist/conversion/array-view.js +9 -0
- package/dist/conversion/build.js +15 -8
- package/dist/conversion/dictionary-view.js +2 -2
- package/dist/conversion/nodes.d.ts +7 -0
- package/dist/conversion/nodes.js +58 -11
- package/dist/identity/ids.d.ts +4 -0
- package/dist/identity/ids.js +4 -0
- package/dist/ir/build.d.ts +4 -3
- package/dist/ir/build.js +14 -5
- package/dist/ir/call-dispatch.js +67 -7
- package/dist/ir/call-entry.js +1 -1
- package/dist/ir/callable-class-flow.d.ts +4 -0
- package/dist/ir/callable-class-flow.js +123 -1
- package/dist/ir/certify/parallel-region.js +698 -20
- package/dist/ir/certify.d.ts +3 -0
- package/dist/ir/certify.js +44 -9
- package/dist/ir/class-allocation-domain.js +2 -2
- package/dist/ir/class-construction-status.d.ts +10 -0
- package/dist/ir/class-construction-status.js +36 -0
- package/dist/ir/convert-carriers.d.ts +10 -1
- package/dist/ir/convert-carriers.js +18 -1
- package/dist/ir/dynamic-constructor-conversions.js +4 -2
- package/dist/ir/finite-iterator-close.d.ts +14 -0
- package/dist/ir/finite-iterator-close.js +50 -0
- package/dist/ir/host-template-conversions.js +9 -0
- package/dist/ir/lower-allocation.js +1 -1
- package/dist/ir/lower-flow.js +24 -3
- package/dist/ir/lower-operands.js +88 -7
- package/dist/ir/lower-protocol.js +1 -1
- package/dist/ir/lower.js +22 -6
- package/dist/ir/model.d.ts +41 -1
- package/dist/ir/native-accessor-definition.d.ts +3 -2
- package/dist/ir/native-accessor-definition.js +29 -10
- package/dist/ir/native-array-transport.js +2 -2
- package/dist/ir/native-field-view-domains.d.ts +23 -0
- package/dist/ir/native-field-view-domains.js +115 -9
- package/dist/ir/native-field-view-facts.d.ts +46 -2
- package/dist/ir/native-field-view-facts.js +159 -4
- package/dist/ir/native-iterable.d.ts +17 -0
- package/dist/ir/native-iterable.js +72 -0
- package/dist/ir/native-key-query.js +1 -1
- package/dist/ir/operation-conversions.js +15 -3
- package/dist/ir/program-conversions.js +2 -2
- package/dist/ir/publish-native-field-view-facts.js +9 -4
- package/dist/ir/pure-conversion-reuse.d.ts +58 -0
- package/dist/ir/pure-conversion-reuse.js +263 -0
- package/dist/ir/queries.js +1 -0
- package/dist/ir/reflection-demand.js +70 -18
- package/dist/ir/shake.js +2 -2
- package/dist/ir/unobserved-callable-inputs.d.ts +37 -0
- package/dist/ir/unobserved-callable-inputs.js +111 -0
- package/dist/native-signatures.d.ts +1 -1
- package/dist/native-signatures.js +27 -2
- package/dist/plugins/gea/component-classes.d.ts +2 -1
- package/dist/plugins/gea/component-classes.js +3 -3
- package/dist/plugins/gea/contract.d.ts +26 -3
- package/dist/plugins/gea/contract.js +42 -43
- package/dist/plugins/gea/host.d.ts +9 -0
- package/dist/plugins/gea/host.js +25 -4
- package/dist/plugins/gea/plugin.js +12 -6
- package/dist/plugins/gea/producer.d.ts +2 -2
- package/dist/plugins/gea/producer.js +2 -2
- package/dist/plugins/load.js +18 -1
- package/dist/plugins/model.d.ts +5 -0
- package/dist/plugins/native-iterable-providers.d.ts +18 -0
- package/dist/plugins/native-iterable-providers.js +51 -0
- package/dist/project-preparation.d.ts +8 -0
- package/dist/project-preparation.js +49 -7
- package/dist/projection/bindings.d.ts +13 -0
- package/dist/projection/bindings.js +20 -1
- package/dist/projection/classes.d.ts +4 -2
- package/dist/projection/classes.js +12 -5
- package/dist/representation/collections.js +2 -0
- package/dist/representation/derive.js +1 -0
- package/dist/representation/model.d.ts +2 -0
- package/dist/representation/model.js +1 -0
- package/dist/representation/policies.d.ts +2 -0
- package/dist/representation/primitive-domain.d.ts +1 -1
- package/dist/representation/primitive-domain.js +1 -1
- package/dist/representation/unassigned-binding-cells.d.ts +4 -3
- package/dist/representation/unassigned-binding-cells.js +19 -2
- package/dist/representation/union.js +6 -6
- package/dist/semantics/frontend.d.ts +2 -0
- package/dist/semantics/frontend.js +34 -5
- package/dist/semantics/host-methods.js +4 -1
- package/dist/semantics/jsx-runtime-provider.d.ts +5 -0
- package/dist/semantics/jsx-runtime-provider.js +16 -0
- package/dist/semantics/model/native-iterable.d.ts +14 -0
- package/dist/semantics/model/native-iterable.js +7 -0
- package/dist/semantics/model/operands.d.ts +30 -0
- package/dist/semantics/model/operations.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.js +27 -4
- package/dist/semantics/module-resolution.js +13 -2
- package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +32 -4
- package/dist/semantics/normalize/callback-parameter-contracts.js +66 -6
- package/dist/semantics/normalize/census.d.ts +3 -0
- package/dist/semantics/normalize/census.js +17 -12
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +4 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +29 -9
- package/dist/semantics/normalize/flow/callable-reach.js +94 -3
- package/dist/semantics/normalize/flow/component-solver.js +144 -55
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +9 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.js +30 -4
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +2 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.js +27 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.js +87 -14
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +2 -0
- package/dist/semantics/normalize/flow/source-commonjs-exports.js +2 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +17 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +125 -0
- package/dist/semantics/normalize/flow/source-native-origin.d.ts +6 -0
- package/dist/semantics/normalize/flow/source-native-origin.js +38 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +37 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.js +201 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +73 -0
- package/dist/semantics/normalize/flow/source-value-session.d.ts +50 -1
- package/dist/semantics/normalize/flow/source-value-session.js +596 -57
- package/dist/semantics/normalize/flow/value-flow.d.ts +17 -0
- package/dist/semantics/normalize/flow/value-flow.js +84 -0
- package/dist/semantics/normalize/fresh-dictionary-storage.js +2 -2
- package/dist/semantics/normalize/fresh-table-last-use.d.ts +52 -0
- package/dist/semantics/normalize/fresh-table-last-use.js +129 -0
- package/dist/semantics/normalize/gating.js +5 -1
- package/dist/semantics/normalize/global-host-mutations.js +190 -13
- package/dist/semantics/normalize/identities.js +20 -1
- package/dist/semantics/normalize/local-bindings.js +2 -2
- package/dist/semantics/normalize/parameter-bindings.js +10 -1
- package/dist/semantics/normalize/producer-context.d.ts +5 -0
- package/dist/semantics/normalize/producers/binding-kind.js +2 -0
- package/dist/semantics/normalize/producers/cited-value-type.d.ts +2 -2
- package/dist/semantics/normalize/producers/cited-value-type.js +2 -2
- package/dist/semantics/normalize/producers/class-lifecycle.js +39 -9
- package/dist/semantics/normalize/producers/computations.js +36 -5
- package/dist/semantics/normalize/producers/conditional-guard.d.ts +6 -0
- package/dist/semantics/normalize/producers/conditional-guard.js +5 -0
- package/dist/semantics/normalize/producers/control.js +7 -1
- package/dist/semantics/normalize/producers/destructuring.js +8 -9
- package/dist/semantics/normalize/producers/invocations.js +55 -2
- package/dist/semantics/normalize/producers/properties.d.ts +13 -0
- package/dist/semantics/normalize/producers/properties.js +21 -3
- package/dist/semantics/normalize/producers/references.js +8 -4
- package/dist/semantics/normalize/reachability.d.ts +15 -3
- package/dist/semantics/normalize/reachability.js +128 -20
- package/dist/semantics/normalize/return-bindings.js +3 -3
- package/dist/semantics/normalize/source-native-iterable.d.ts +19 -0
- package/dist/semantics/normalize/source-native-iterable.js +74 -0
- package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
- package/dist/semantics/normalize/structural-declarations.js +1 -1
- package/dist/semantics/normalize/structural-indexed-access.js +9 -0
- package/dist/semantics/normalize/structural.js +11 -0
- package/dist/semantics/normalize/unshared-array-result.d.ts +42 -0
- package/dist/semantics/normalize/unshared-array-result.js +269 -0
- package/dist/semantics/package-sources.js +3 -2
- package/dist/semantics/program.d.ts +8 -0
- package/dist/semantics/program.js +55 -0
- package/dist/semantics/source-transform-exports.d.ts +8 -0
- package/dist/semantics/source-transform-exports.js +145 -0
- package/dist/semantics/source-transform-protocol.d.ts +22 -0
- package/dist/semantics/this-constructor-source-transform.js +19 -1
- package/dist/targets/cpp/class-layout.d.ts +2 -0
- package/dist/targets/cpp/class-layout.js +35 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +11 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +33 -4
- package/dist/targets/cpp/conversions.js +6 -3
- package/dist/targets/cpp/emit-callable.js +73 -7
- package/dist/targets/cpp/emit-context.d.ts +23 -9
- package/dist/targets/cpp/emit-context.js +19 -8
- package/dist/targets/cpp/emit-equality.js +41 -1
- package/dist/targets/cpp/emit-exceptions.js +29 -11
- package/dist/targets/cpp/emit-iterator-object-view.js +2 -2
- package/dist/targets/cpp/emit-iterator.js +33 -9
- package/dist/targets/cpp/emit-live-field-view.js +6 -1
- package/dist/targets/cpp/emit-narrowing.d.ts +11 -3
- package/dist/targets/cpp/emit-narrowing.js +58 -18
- package/dist/targets/cpp/emit-native-field-view.d.ts +3 -1
- package/dist/targets/cpp/emit-native-field-view.js +84 -8
- package/dist/targets/cpp/emit-properties.d.ts +1 -0
- package/dist/targets/cpp/emit-properties.js +26 -7
- package/dist/targets/cpp/emit-protocol-iterator.js +5 -2
- package/dist/targets/cpp/emit-record-view.js +14 -2
- package/dist/targets/cpp/emit-tostring.js +23 -1
- package/dist/targets/cpp/emit-union-properties.js +1 -1
- package/dist/targets/cpp/emit.d.ts +1 -1
- package/dist/targets/cpp/emit.js +132 -21
- package/dist/targets/cpp/host/emit-host-invoke.js +2 -2
- package/dist/targets/cpp/host/emit-host-object.js +28 -2
- package/dist/targets/cpp/host/emit-host-properties.js +9 -1
- package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
- package/dist/targets/cpp/host/emit-host-value.js +8 -6
- package/dist/targets/cpp/host/host-members.js +2 -1
- package/dist/targets/cpp/prototype/emit-prototype-array.js +69 -5
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +9 -9
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +2 -2
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +7 -7
- package/dist/targets/cpp/records.d.ts +1 -0
- package/dist/targets/cpp/records.js +16 -7
- package/dist/targets/cpp/translation-unit.js +30 -16
- package/package.json +8 -7
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +42 -3
- package/src/targets/cpp/runtime/gea_eval.h +3 -0
- package/src/targets/cpp/runtime/gea_runtime.h +2407 -684
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ boards, desktop, mobile and consoles. The other repositories plug into it:
|
|
|
34
34
|
- Xbox — the Xbox target is not open source; it is available commercially.
|
|
35
35
|
Contact [contact@geastack.com](mailto:contact@geastack.com).
|
|
36
36
|
- [`node-compat`](https://github.com/geastack/node-compat) — the Node.js
|
|
37
|
-
runtime and geatsc plugin for compiling Node servers (`node:http`,
|
|
37
|
+
runtime and geatsc plugin for compiling Node servers (`node:http`, HTTP frameworks) to
|
|
38
38
|
native executables. It is a dependency of this package: running `geatsc`
|
|
39
39
|
with no input file inside a Node project builds each of the project's entry
|
|
40
40
|
points through node-compat into `dist/`.
|
package/dist/cli-coverage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { relative, resolve } from 'node:path';
|
|
1
|
+
import { dirname, relative, resolve } from 'node:path';
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
3
|
import { compile } from './compiler.js';
|
|
4
4
|
import { nodeOfOperation, operationOfResult } from './identity/ids.js';
|
|
@@ -308,9 +308,7 @@ export const runCoverage = async (argv) => {
|
|
|
308
308
|
process.stderr.write(`coverage: ${parsed.plugin} does not export a compiler plugin factory\n`);
|
|
309
309
|
return 1;
|
|
310
310
|
}
|
|
311
|
-
const projectFileName = parsed.projectFileName === 'discover'
|
|
312
|
-
? findProjectFile(entry.slice(0, Math.max(0, entry.lastIndexOf('/'))) || '.')
|
|
313
|
-
: parsed.projectFileName;
|
|
311
|
+
const projectFileName = parsed.projectFileName === 'discover' ? findProjectFile(dirname(entry)) : parsed.projectFileName;
|
|
314
312
|
const result = compile({
|
|
315
313
|
rootFileNames: [entry],
|
|
316
314
|
projectFileName,
|
package/dist/cli-emit.js
CHANGED
|
@@ -195,7 +195,7 @@ export const runEmit = async (argv, moduleGraph = false) => {
|
|
|
195
195
|
// A named project wins over discovery, and over the bundle rule above: a
|
|
196
196
|
// caller that states which project an input belongs to has answered the
|
|
197
197
|
// question this command would otherwise guess at.
|
|
198
|
-
const projectFileName = parsed.projectFileName ?? (bundled ? null : findProjectFile(
|
|
198
|
+
const projectFileName = parsed.projectFileName ?? (bundled ? null : findProjectFile(dirname(input)));
|
|
199
199
|
const result = compile({
|
|
200
200
|
rootFileNames: [input],
|
|
201
201
|
projectFileName,
|
package/dist/cli-module-graph.js
CHANGED
|
@@ -93,7 +93,7 @@ export const readModuleGraph = (manifestPath, stage, statedEntry) => {
|
|
|
93
93
|
for (const one of module.imports ?? []) {
|
|
94
94
|
if (!one.resolvedId)
|
|
95
95
|
continue;
|
|
96
|
-
const linked = byId.get(one.resolvedId) ?? (one.resolvedId
|
|
96
|
+
const linked = byId.get(one.resolvedId) ?? (isAbsolute(one.resolvedId) ? resolve(one.resolvedId) : null);
|
|
97
97
|
if (!linked)
|
|
98
98
|
continue;
|
|
99
99
|
// A dependency the bundler resolved to its BUILD, redirected to the
|
package/dist/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import { findProjectFile } from './semantics/program.js';
|
|
|
9
9
|
import { preflightReportLines } from './preflight/report.js';
|
|
10
10
|
import { structuralShapeKey } from './semantics/model/structural-types.js';
|
|
11
11
|
import { closeSync, openSync, writeSync } from 'node:fs';
|
|
12
|
+
import { dirname } from 'node:path';
|
|
12
13
|
/**
|
|
13
14
|
* `--project <tsconfig.json>` names the project explicitly; `--no-project`
|
|
14
15
|
* compiles the roots under this compiler's own defaults. With neither, the
|
|
@@ -22,7 +23,7 @@ const parseArguments = (argv) => {
|
|
|
22
23
|
const named = flagIndex >= 0 ? (argv[flagIndex + 1] ?? null) : null;
|
|
23
24
|
const rootFileNames = named ? positional.filter((argument) => argument !== named) : positional;
|
|
24
25
|
const first = rootFileNames[0];
|
|
25
|
-
const discovered = first ? findProjectFile(
|
|
26
|
+
const discovered = first ? findProjectFile(dirname(first)) : null;
|
|
26
27
|
return {
|
|
27
28
|
rootFileNames,
|
|
28
29
|
preflight: argv.includes('--preflight'),
|
package/dist/compiler.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mergeNativeIterableProviders } from './plugins/native-iterable-providers.js';
|
|
1
2
|
import { nodeOfOperation, operationOfResult } from './identity/ids.js';
|
|
2
3
|
import { readFileSync } from 'fs';
|
|
3
4
|
import { projectAbis } from './projection/abi.js';
|
|
@@ -15,7 +16,7 @@ import { publishNativeOwnAssignments } from './ir/native-own-assignment.js';
|
|
|
15
16
|
import { publishNativeAccessorDefinitions } from './ir/native-accessor-definition.js';
|
|
16
17
|
import { publishNativeFieldViewFacts } from './ir/publish-native-field-view-facts.js';
|
|
17
18
|
import { publishNativeArrayDescriptorSnapshots } from './ir/native-array-descriptor-snapshot.js';
|
|
18
|
-
import { projectBindingPlacements } from './projection/bindings.js';
|
|
19
|
+
import { hostDeclarationFileTable, projectBindingPlacements } from './projection/bindings.js';
|
|
19
20
|
import { physicalClassInstanceResolverOf, physicalClassLayoutsOf, projectClasses } from './projection/classes.js';
|
|
20
21
|
import { isMaterializable } from './conversion/algebra.js';
|
|
21
22
|
import { recipeClosureOf } from './conversion/recipe-closure.js';
|
|
@@ -61,6 +62,7 @@ import { splitGeneratorBodies } from './ir/generator-split.js';
|
|
|
61
62
|
import { shakeProgram } from './ir/shake.js';
|
|
62
63
|
import { pruneProvenBranches } from './ir/proven-branches.js';
|
|
63
64
|
import { threadShortCircuitJoins } from './ir/short-circuit-threading.js';
|
|
65
|
+
import { dropUnreadPureConversions } from './ir/pure-conversion-reuse.js';
|
|
64
66
|
import { publishEmissionRepresentationsOf } from './ir/emission-representations.js';
|
|
65
67
|
import { finalizeTypedComputedReads, reflectionExposureOf } from './ir/reflection-demand.js';
|
|
66
68
|
import { confirmUnboxedMethodBinds } from './ir/boxed-bind-assumptions.js';
|
|
@@ -235,6 +237,23 @@ export const compile = (request) => {
|
|
|
235
237
|
const nativeTypes = new Map([...coreNativeTypes, ...plugins.flatMap((plugin) => [...plugin.capabilities.nativeTypes])]);
|
|
236
238
|
const nativeTypesByDeclaration = new Map(plugins.flatMap((plugin) => [...(plugin.capabilities.nativeTypesByDeclaration ?? new Map())]));
|
|
237
239
|
const hostNamespaceRootDeclarations = plugins.flatMap((plugin) => plugin.capabilities.hostNamespaceRootDeclarations ?? []);
|
|
240
|
+
const hostProvidedNames = new Set([
|
|
241
|
+
...coreHostFunctions.keys(),
|
|
242
|
+
...coreHostConstants.keys(),
|
|
243
|
+
...plugins.flatMap((plugin) => [
|
|
244
|
+
...plugin.capabilities.hostFunctions.keys(),
|
|
245
|
+
...plugin.capabilities.nativeConstants.keys(),
|
|
246
|
+
...[...plugin.capabilities.hostFunctionsByDeclaration.values()].flatMap((names) => [...names.keys()]),
|
|
247
|
+
...[...plugin.capabilities.hostConstantsByDeclaration.values()].flatMap((names) => [...names.keys()]),
|
|
248
|
+
// A namespace root or singleton is equally the host's by name: the
|
|
249
|
+
// framework states `declare const __gea_Panel: {...}` module-locally
|
|
250
|
+
// for a root its host table claims, and no global declares it.
|
|
251
|
+
...plugin.capabilities.hostNamespaces.roots,
|
|
252
|
+
...[...plugin.capabilities.hostNamespaceRootsByDeclaration.values()].flatMap((names) => [...names]),
|
|
253
|
+
...plugin.capabilities.hostSingletons,
|
|
254
|
+
...[...plugin.capabilities.hostSingletonsByDeclaration.values()].flatMap((names) => [...names])
|
|
255
|
+
])
|
|
256
|
+
]);
|
|
238
257
|
const frontend = runFrontend({
|
|
239
258
|
nativeFunctionDeclarations: plugins.flatMap((plugin) => plugin.capabilities.nativeFunctionDeclarations ?? []),
|
|
240
259
|
...(request.packageSources ? { packageSources: request.packageSources } : {}),
|
|
@@ -251,36 +270,19 @@ export const compile = (request) => {
|
|
|
251
270
|
producers: installedProducers((context) => plugins.flatMap((plugin) => plugin.producers(context))),
|
|
252
271
|
hostTypedArrayDeclarations: plugins.flatMap((plugin) => plugin.capabilities.typedArrayDeclarations ?? []),
|
|
253
272
|
nativeTypes,
|
|
273
|
+
nativeIterableProviders: mergeNativeIterableProviders(plugins.map((plugin) => plugin.capabilities.nativeIterableProviders)),
|
|
254
274
|
nativeTypesByDeclaration,
|
|
255
275
|
hostSingletonDeclarations: new Map(plugins.flatMap((plugin) => [...(plugin.capabilities.hostSingletonDeclarations ?? new Map())])),
|
|
256
276
|
standardClasses: new Set(coreNativeTypes.keys()),
|
|
257
|
-
//
|
|
258
|
-
//
|
|
259
|
-
|
|
260
|
-
// declaration is believed exactly as before.
|
|
261
|
-
absentGlobals: new Set(plugins.flatMap((plugin) => [...plugin.capabilities.absentGlobals])),
|
|
277
|
+
// An optional feature cannot erase a global another installed host
|
|
278
|
+
// actually supplies (for example WebGL absence versus Gea worker self).
|
|
279
|
+
absentGlobals: new Set(plugins.flatMap((plugin) => [...plugin.capabilities.absentGlobals]).filter((name) => !hostProvidedNames.has(name))),
|
|
262
280
|
// The members the installed hosts reach on their own, unioned the same way
|
|
263
281
|
// every other plugin table here is. `reachability.ts` keeps an instance
|
|
264
282
|
// method only when live code names it, and a name only a lowering
|
|
265
283
|
// synthesizes is one no walk over the source can see.
|
|
266
284
|
hostReachedMemberKeys: new Set(plugins.flatMap((plugin) => [...plugin.capabilities.reachedMemberKeys])),
|
|
267
|
-
hostProvidedNames
|
|
268
|
-
...coreHostFunctions.keys(),
|
|
269
|
-
...coreHostConstants.keys(),
|
|
270
|
-
...plugins.flatMap((plugin) => [
|
|
271
|
-
...plugin.capabilities.hostFunctions.keys(),
|
|
272
|
-
...plugin.capabilities.nativeConstants.keys(),
|
|
273
|
-
...[...plugin.capabilities.hostFunctionsByDeclaration.values()].flatMap((names) => [...names.keys()]),
|
|
274
|
-
...[...plugin.capabilities.hostConstantsByDeclaration.values()].flatMap((names) => [...names.keys()]),
|
|
275
|
-
// A namespace root or singleton is equally the host's by name: the
|
|
276
|
-
// framework states `declare const __gea_Panel: {...}` module-locally
|
|
277
|
-
// for a root its host table claims, and no global declares it.
|
|
278
|
-
...plugin.capabilities.hostNamespaces.roots,
|
|
279
|
-
...[...plugin.capabilities.hostNamespaceRootsByDeclaration.values()].flatMap((names) => [...names]),
|
|
280
|
-
...plugin.capabilities.hostSingletons,
|
|
281
|
-
...[...plugin.capabilities.hostSingletonsByDeclaration.values()].flatMap((names) => [...names])
|
|
282
|
-
])
|
|
283
|
-
]),
|
|
285
|
+
hostProvidedNames,
|
|
284
286
|
hostNamespaceRoots: new Set(['Reflect', ...plugins.flatMap((plugin) => [...plugin.capabilities.hostNamespaces.roots])]),
|
|
285
287
|
hostNamespaceRootDeclarations,
|
|
286
288
|
// Every leaf path a plugin's own namespace tables publish -- see
|
|
@@ -339,6 +341,7 @@ export const compile = (request) => {
|
|
|
339
341
|
// done once, here, so the carrier states the transitive answer and nobody
|
|
340
342
|
// downstream has to walk anything (see `Representation`'s `native-handle`).
|
|
341
343
|
const hostBases = new Map(plugins.flatMap((plugin) => [...plugin.capabilities.nativeBases]));
|
|
344
|
+
const hostReferenceIdentities = new Set(plugins.flatMap((plugin) => [...(plugin.capabilities.nativeReferenceIdentities ?? [])]));
|
|
342
345
|
const hostViews = new Map(plugins.flatMap((plugin) => [...(plugin.capabilities.nativeViews ?? [])]));
|
|
343
346
|
const hostBaseChain = (native) => {
|
|
344
347
|
const chain = [];
|
|
@@ -370,6 +373,7 @@ export const compile = (request) => {
|
|
|
370
373
|
}, {
|
|
371
374
|
forDeclaration: (declaration) => frontend.hostProtocols.get(declaration) ?? null,
|
|
372
375
|
basesOf: (native) => hostBaseChain(native),
|
|
376
|
+
referenceIdentityOf: (native) => native !== null && hostReferenceIdentities.has(native),
|
|
373
377
|
viewsInto: (native) => (native === null ? new Map() : (hostViews.get(native) ?? new Map()))
|
|
374
378
|
}, {
|
|
375
379
|
forDeclaration: (declaration) => frontend.typedArrayElements.get(declaration) ?? null
|
|
@@ -685,9 +689,9 @@ export const compile = (request) => {
|
|
|
685
689
|
// is: each plugin's own table is keyed by ITS declaration files, so a
|
|
686
690
|
// union of the per-plugin maps cannot let one plugin's file collide with
|
|
687
691
|
// another's.
|
|
688
|
-
hostConstantsByDeclaration:
|
|
692
|
+
hostConstantsByDeclaration: hostDeclarationFileTable(plugins.flatMap((plugin) => [...plugin.capabilities.hostConstantsByDeclaration])),
|
|
689
693
|
hostFunctions: new Map([...plugins.flatMap((plugin) => [...plugin.capabilities.hostFunctions]), ...coreHostFunctions]),
|
|
690
|
-
hostFunctionsByDeclaration:
|
|
694
|
+
hostFunctionsByDeclaration: hostDeclarationFileTable(plugins.flatMap((plugin) => [...plugin.capabilities.hostFunctionsByDeclaration])),
|
|
691
695
|
// The backend's own table, unioned in the same way `coreHostMembers` is
|
|
692
696
|
// above and for the same reason: `btoa`/`encodeURIComponent` are language
|
|
693
697
|
// builtins, so a plugin row for one would make an ECMAScript global
|
|
@@ -699,11 +703,11 @@ export const compile = (request) => {
|
|
|
699
703
|
coreGlobalSingletons,
|
|
700
704
|
standardLibraryExternals: frontend.standardLibraryBindings,
|
|
701
705
|
hostNamespaces: hosts.namespaces,
|
|
702
|
-
hostNamespaceRootsByDeclaration:
|
|
706
|
+
hostNamespaceRootsByDeclaration: hostDeclarationFileTable(plugins.flatMap((plugin) => [...plugin.capabilities.hostNamespaceRootsByDeclaration])),
|
|
703
707
|
hostNamespaceBindings: frontend.hostNamespaceBindings,
|
|
704
708
|
exactHostNamespaceNames: new Set(hostNamespaceRootDeclarations.map((row) => row.declarationName)),
|
|
705
709
|
hostSingletons: hosts.singletons,
|
|
706
|
-
hostSingletonsByDeclaration:
|
|
710
|
+
hostSingletonsByDeclaration: hostDeclarationFileTable(plugins.flatMap((plugin) => [...plugin.capabilities.hostSingletonsByDeclaration])),
|
|
707
711
|
hostSingletonBindings: frontend.hostSingletonBindings
|
|
708
712
|
});
|
|
709
713
|
stage('diagnostics+abi');
|
|
@@ -1103,7 +1107,7 @@ export const compile = (request) => {
|
|
|
1103
1107
|
// only the CLOSED exposure can say its class never gained a dynamic protocol.
|
|
1104
1108
|
const absentArmBodies = finalizedBodies && reflection ? finalizeAbsentClassArms(finalizedBodies, reflection, executableClasses) : finalizedBodies;
|
|
1105
1109
|
// Last, so the call targets it follows into a callee are the final ones.
|
|
1106
|
-
const
|
|
1110
|
+
const sharedEmptyBodies = absentArmBodies
|
|
1107
1111
|
? shareReadOnlyEmptyRecords(absentArmBodies, {
|
|
1108
1112
|
placements: splitPlacements,
|
|
1109
1113
|
declaresField: (shapeId, key) => {
|
|
@@ -1117,6 +1121,9 @@ export const compile = (request) => {
|
|
|
1117
1121
|
}
|
|
1118
1122
|
})
|
|
1119
1123
|
: absentArmBodies;
|
|
1124
|
+
// Before the recipes and certification that read the final operation list:
|
|
1125
|
+
// a selection an `instanceof` no longer reads (`call-dispatch.ts`) goes.
|
|
1126
|
+
const emittedBodies = sharedEmptyBodies ? dropUnreadPureConversions(sharedEmptyBodies, conversionCensus) : sharedEmptyBodies;
|
|
1120
1127
|
stage('reflection');
|
|
1121
1128
|
// Certification is a walk of the IR lowering actually built
|
|
1122
1129
|
// (one question, one census): every capability the printer
|
|
@@ -41,6 +41,15 @@ const arrayStorageViewPlanOf = (source, target, accepted, readAccepted, resolve,
|
|
|
41
41
|
const read = exact(source.element, target.element, readAccepted, resolve);
|
|
42
42
|
if (!read || !liveRead(read, resolve))
|
|
43
43
|
return null;
|
|
44
|
+
// A typed array holds exactly the values its element carrier admits, every
|
|
45
|
+
// one of which JavaScript reads back as is. A reader that checks them --
|
|
46
|
+
// `Array<Vector2 | Vector3>` seen as a stated `Array<Vector2>` -- throws on
|
|
47
|
+
// an element the program stored and never tested, so it is no view of that
|
|
48
|
+
// array; the pair refuses instead. A dynamic element stays checked: there
|
|
49
|
+
// the program's own type is the only statement of what the value is.
|
|
50
|
+
if (source.element.kind !== 'dynamic' &&
|
|
51
|
+
[...recipeClosureOf([read], resolve).values()].some((child) => conversionRequiresSourceGuard(child.capability, resolve)))
|
|
52
|
+
return null;
|
|
44
53
|
if (source.element.kind === 'dynamic') {
|
|
45
54
|
const write = nativeEntryWriterOf(target.element, source.element, accepted, resolve);
|
|
46
55
|
if (!write)
|
package/dist/conversion/build.js
CHANGED
|
@@ -908,20 +908,27 @@ export const buildConversionGraph = (plan, registry = emptyConversionRegistry, c
|
|
|
908
908
|
continue;
|
|
909
909
|
const installed = registry.narrowing(representation, target);
|
|
910
910
|
// The same order `conversion/nodes.ts`'s `capabilityOf` asks in: an
|
|
911
|
-
// installed
|
|
912
|
-
// `never` minted here is what
|
|
913
|
-
//
|
|
914
|
-
//
|
|
915
|
-
|
|
911
|
+
// installed narrowing, else an installed widening or recast, else the
|
|
912
|
+
// registry's static recipe, else never. A `never` minted here is what
|
|
913
|
+
// `nodeFor` hands back for the pair, so a pair the static recipe
|
|
914
|
+
// answers must be answered here too or the eager graph would refuse
|
|
915
|
+
// what a late question would allow -- and an installed recast must win
|
|
916
|
+
// here as it does there: `never[]` into a class array is the identity
|
|
917
|
+
// `gea::emptyArraySentinel`, not the element-wise copy the static chain
|
|
918
|
+
// would mint for it, which the array rule then refuses.
|
|
919
|
+
const recast = installed ? null : (registry.widening(representation, target) ?? registry.recasting(representation, target));
|
|
920
|
+
const recipe = installed || recast ? null : registry.staticRecipe(representation, target);
|
|
916
921
|
nodes.set(id, {
|
|
917
922
|
id,
|
|
918
923
|
source: representation,
|
|
919
924
|
target,
|
|
920
925
|
capability: installed
|
|
921
926
|
? narrowingCapabilityFor(representation, target, installed)
|
|
922
|
-
:
|
|
923
|
-
? { kind: '
|
|
924
|
-
:
|
|
927
|
+
: recast
|
|
928
|
+
? { kind: 'atom', classifier: recast.classifier, materializer: recast.materializer }
|
|
929
|
+
: recipe
|
|
930
|
+
? { kind: 'static', materializer: recipe }
|
|
931
|
+
: { kind: 'never', reason: `no runtime narrowing is installed from ${sourceKey} to ${targetKey}` }
|
|
925
932
|
});
|
|
926
933
|
}
|
|
927
934
|
}
|
|
@@ -96,8 +96,8 @@ const checkedDynamicWrapperRead = (node, resolve) => {
|
|
|
96
96
|
* An entry read into the table's declared any/unknown carrier: `gea::Value::box`
|
|
97
97
|
* of a primitive keeps the ECMAScript value, and of a shared class reference
|
|
98
98
|
* holds that same object. The box allocates only its envelope, so the read is
|
|
99
|
-
* live -- `Record<string, Node>` reaching `Record<string, unknown>` (
|
|
100
|
-
* `hasChildren`) or `Record<string, number>` likewise.
|
|
99
|
+
* live -- `Record<string, Node>` reaching `Record<string, unknown>` (a trie
|
|
100
|
+
* router's `hasChildren`) or `Record<string, number>` likewise.
|
|
101
101
|
*/
|
|
102
102
|
const boxedEntryIsLive = (node) => {
|
|
103
103
|
if (node.target.kind !== 'dynamic' || node.target.reason === 'untyped-callable' || node.capability.kind !== 'atom')
|
|
@@ -208,6 +208,13 @@ export declare const ARM_VIEW_MATERIALIZER = "gea::host::armView";
|
|
|
208
208
|
export declare const ASSERTED_UNION_MATERIALIZER = "gea::host::assertedUnion";
|
|
209
209
|
/** The asserted-union node that may rebuild an `Array<any>` arm as a copy. */
|
|
210
210
|
export declare const ASSERTED_UNION_COPY_MATERIALIZER = "gea::host::assertedUnionCopy";
|
|
211
|
+
/**
|
|
212
|
+
* The live-arm dispatch of a union ARGUMENT a callable adapter frame hands to a
|
|
213
|
+
* body declaring one of its classes (`nodes.ts`'s `checkedFrameNarrowingFor`):
|
|
214
|
+
* `assertedUnionFor`'s dispatch, but a boxed arm is admitted by a class check
|
|
215
|
+
* and a value that is no instance is a catchable `TypeError`, not an abort.
|
|
216
|
+
*/
|
|
217
|
+
export declare const FRAME_ARGUMENT_UNION_MATERIALIZER = "gea::host::frameArgumentUnion";
|
|
211
218
|
/** The materializer id every asserted-view node carries; the printer dispatches its recipe on it. */
|
|
212
219
|
export declare const ASSERTED_VIEW_MATERIALIZER = "gea::host::assertedView";
|
|
213
220
|
/** A structural record carrier: a value that can be a view of a class allocation only through its origin. */
|
package/dist/conversion/nodes.js
CHANGED
|
@@ -184,7 +184,7 @@ export const createConversionNodes = (input) => {
|
|
|
184
184
|
const recipe = input.registry.staticRecipe(source, target);
|
|
185
185
|
if (recipe && !recipe.staticRecipeFallback)
|
|
186
186
|
return { kind: 'static', materializer: recipe };
|
|
187
|
-
const structural = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
187
|
+
const structural = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
188
188
|
if (structural)
|
|
189
189
|
return { kind: 'static', materializer: structural };
|
|
190
190
|
if (recipe)
|
|
@@ -259,7 +259,7 @@ export const createConversionNodes = (input) => {
|
|
|
259
259
|
// census happened to mint first.
|
|
260
260
|
const payload = target.kind === 'optional' ? nodeFor(source, target.payload).capability : null;
|
|
261
261
|
const sealed = payload === null || ('materializer' in payload && payload.materializer.documentRecordView)
|
|
262
|
-
? input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
262
|
+
? input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor)
|
|
263
263
|
: undefined;
|
|
264
264
|
capability = sealed?.documentRecordView
|
|
265
265
|
? { kind: 'static', materializer: sealed }
|
|
@@ -335,7 +335,7 @@ export const createConversionNodes = (input) => {
|
|
|
335
335
|
if (source.kind === 'tagged-union' &&
|
|
336
336
|
(target.kind === 'record' || (target.kind === 'native-record-ref' && target.native === null)) &&
|
|
337
337
|
(capability.materializer.armSelection !== undefined || capability.materializer.nativeSelection !== undefined)) {
|
|
338
|
-
const complete = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
338
|
+
const complete = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
339
339
|
if (complete?.recordView?.view.kind === 'dispatch')
|
|
340
340
|
capability = { kind: 'static', materializer: complete };
|
|
341
341
|
}
|
|
@@ -353,13 +353,13 @@ export const createConversionNodes = (input) => {
|
|
|
353
353
|
target.value.kind !== 'dynamic' &&
|
|
354
354
|
(capability.materializer.wrapperKind === 'unbox-tag' || capability.materializer.wrapperKind === 'unbox-payload') &&
|
|
355
355
|
dictionaryEntriesAreSharedRecords(target.value)) {
|
|
356
|
-
const viewed = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
356
|
+
const viewed = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
357
357
|
if (viewed?.dictionaryView !== undefined)
|
|
358
358
|
capability = { kind: 'static', materializer: viewed };
|
|
359
359
|
}
|
|
360
360
|
const materializer = capability.materializer;
|
|
361
361
|
if (structuralRecipeRequiredFor({ id, source, target, capability })) {
|
|
362
|
-
const sealed = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
362
|
+
const sealed = input.registry.structuralRecipe?.(source, target, nodeFor, undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
363
363
|
capability =
|
|
364
364
|
sealed?.recordView ||
|
|
365
365
|
sealed?.documentRecordView ||
|
|
@@ -598,7 +598,7 @@ export const createConversionNodes = (input) => {
|
|
|
598
598
|
});
|
|
599
599
|
const sealed = input.registry.structuralRecipe?.(source, frame, (from, into) => representationKey(from) === representationKey(result.source) && representationKey(into) === representationKey(result.target)
|
|
600
600
|
? result
|
|
601
|
-
: nodeFor(from, into), undefined, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
601
|
+
: nodeFor(from, into), undefined, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor);
|
|
602
602
|
if (sealed?.callableView === undefined)
|
|
603
603
|
return null;
|
|
604
604
|
frameAdaptation = contextualNode(source, frame, 'native-method-result-frame', sealed);
|
|
@@ -735,12 +735,15 @@ export const createConversionNodes = (input) => {
|
|
|
735
735
|
return node;
|
|
736
736
|
};
|
|
737
737
|
const assertedUnions = new Map();
|
|
738
|
-
const assertedUnionFor = (source, target, copyAllowed) =>
|
|
738
|
+
const assertedUnionFor = (source, target, copyAllowed) => liveArmDispatchFor(source, target, copyAllowed ? 'copy' : 'asserted');
|
|
739
|
+
const liveArmDispatchFor = (source, target, mode) => {
|
|
740
|
+
const copyAllowed = mode === 'copy';
|
|
739
741
|
if (source.kind !== 'tagged-union' && !(source.kind === 'optional' && source.payload.kind === 'tagged-union'))
|
|
740
742
|
return null;
|
|
741
743
|
if (target.kind === 'tagged-union' || target.kind === 'dynamic')
|
|
742
744
|
return null;
|
|
743
|
-
const
|
|
745
|
+
const suffix = mode === 'copy' ? 'asserted-union:copy' : mode === 'frame-argument' ? 'frame-argument-union' : 'asserted-union';
|
|
746
|
+
const id = `${representationKey(source)}->${representationKey(target)}#${suffix}`;
|
|
744
747
|
const remembered = assertedUnions.get(id);
|
|
745
748
|
if (remembered !== undefined)
|
|
746
749
|
return remembered;
|
|
@@ -770,8 +773,16 @@ export const createConversionNodes = (input) => {
|
|
|
770
773
|
capability: {
|
|
771
774
|
kind: 'static',
|
|
772
775
|
materializer: {
|
|
773
|
-
id:
|
|
774
|
-
|
|
776
|
+
id: mode === 'copy'
|
|
777
|
+
? ASSERTED_UNION_COPY_MATERIALIZER
|
|
778
|
+
: mode === 'frame-argument'
|
|
779
|
+
? FRAME_ARGUMENT_UNION_MATERIALIZER
|
|
780
|
+
: ASSERTED_UNION_MATERIALIZER,
|
|
781
|
+
domain: mode === 'copy'
|
|
782
|
+
? 'static:asserted-union-copy'
|
|
783
|
+
: mode === 'frame-argument'
|
|
784
|
+
? 'static:frame-argument-union'
|
|
785
|
+
: 'static:asserted-union',
|
|
775
786
|
allocates: copyAllowed,
|
|
776
787
|
...(native ? { nativeFieldProtocol: 'unused' } : {})
|
|
777
788
|
}
|
|
@@ -839,7 +850,7 @@ export const createConversionNodes = (input) => {
|
|
|
839
850
|
const remembered = familyMemberViews.get(id);
|
|
840
851
|
if (remembered !== undefined)
|
|
841
852
|
return remembered;
|
|
842
|
-
const materializer = input.registry.structuralRecipe?.(source, target, nodeFor, members, nativeMethodFor, nodeById, dictionaryReadFor,
|
|
853
|
+
const materializer = input.registry.structuralRecipe?.(source, target, nodeFor, members, nativeMethodFor, nodeById, dictionaryReadFor, checkedFrameNarrowingFor) ?? null;
|
|
843
854
|
if (materializer === null)
|
|
844
855
|
return null;
|
|
845
856
|
const node = { id, source, target, capability: { kind: 'static', materializer }, familyMembers: members };
|
|
@@ -895,6 +906,35 @@ export const createConversionNodes = (input) => {
|
|
|
895
906
|
assertedClassDowncasts.set(id, node);
|
|
896
907
|
return node;
|
|
897
908
|
};
|
|
909
|
+
// The checked narrowing a callable ADAPTER FRAME may apply to an argument
|
|
910
|
+
// (`structural-plan.ts`'s `callableViewPlan`, `downcast`). Besides the
|
|
911
|
+
// class downcast above, a union-typed public parameter entering a body
|
|
912
|
+
// that declares one of its arms: a function value stored into a method
|
|
913
|
+
// slot that some other writer widened (`m.hook = (s, r: Renderer) => ...`
|
|
914
|
+
// beside `n.hook = (s, r: any) => ...` makes the slot's frame take
|
|
915
|
+
// `Renderer | any`), which TypeScript admits through method-parameter
|
|
916
|
+
// bivariance. The frame has no `instanceof` guard for the ordinary arm
|
|
917
|
+
// selection to trust, so the live arm is dispatched instead
|
|
918
|
+
// (`FRAME_ARGUMENT_UNION_MATERIALIZER`): the arm the body declares passes as
|
|
919
|
+
// it is, with no conversion; every other arm through its own conversion,
|
|
920
|
+
// except that a boxed (`any`) arm is admitted by a class check first -- an
|
|
921
|
+
// `any` holding the instance unboxes to it, anything else is a catchable
|
|
922
|
+
// TypeError, never the unbox's abort -- and an arm that cannot be the
|
|
923
|
+
// parameter at all is the same TypeError. Only a union one of whose arms
|
|
924
|
+
// reaches the target without a prior guard qualifies; a frame narrowing
|
|
925
|
+
// that converts no arm stays refused. The ordinary unguarded conversion,
|
|
926
|
+
// where one exists, is still preferred (`callableViewPlan`'s `guarded`).
|
|
927
|
+
const checkedFrameNarrowingFor = (source, target) => {
|
|
928
|
+
const downcast = assertedClassDowncastFor(source, target);
|
|
929
|
+
if (downcast !== null)
|
|
930
|
+
return downcast;
|
|
931
|
+
if (source.kind !== 'tagged-union' || target.kind !== 'class-ref')
|
|
932
|
+
return null;
|
|
933
|
+
const targetKey = representationKey(target);
|
|
934
|
+
const homed = source.arms.some((arm) => representationKey(arm.value) === targetKey ||
|
|
935
|
+
(arm.value.kind !== 'dynamic' && recipeIsMaterializableWithoutPriorSourceGuard(nodeFor(arm.value, target), nodeById)));
|
|
936
|
+
return homed ? liveArmDispatchFor(source, target, 'frame-argument') : null;
|
|
937
|
+
};
|
|
898
938
|
const nullishOptionals = new Map();
|
|
899
939
|
const nullishOptionalFor = (source, target) => {
|
|
900
940
|
if (source.kind !== 'dynamic' || source.reason === 'untyped-callable' || target.kind !== 'optional' || target.absence !== 'undefined')
|
|
@@ -1027,6 +1067,13 @@ const isArmViewPair = (source, target) => {
|
|
|
1027
1067
|
export const ASSERTED_UNION_MATERIALIZER = 'gea::host::assertedUnion';
|
|
1028
1068
|
/** The asserted-union node that may rebuild an `Array<any>` arm as a copy. */
|
|
1029
1069
|
export const ASSERTED_UNION_COPY_MATERIALIZER = 'gea::host::assertedUnionCopy';
|
|
1070
|
+
/**
|
|
1071
|
+
* The live-arm dispatch of a union ARGUMENT a callable adapter frame hands to a
|
|
1072
|
+
* body declaring one of its classes (`nodes.ts`'s `checkedFrameNarrowingFor`):
|
|
1073
|
+
* `assertedUnionFor`'s dispatch, but a boxed arm is admitted by a class check
|
|
1074
|
+
* and a value that is no instance is a catchable `TypeError`, not an abort.
|
|
1075
|
+
*/
|
|
1076
|
+
export const FRAME_ARGUMENT_UNION_MATERIALIZER = 'gea::host::frameArgumentUnion';
|
|
1030
1077
|
/** The materializer id every asserted-view node carries; the printer dispatches its recipe on it. */
|
|
1031
1078
|
export const ASSERTED_VIEW_MATERIALIZER = 'gea::host::assertedView';
|
|
1032
1079
|
/** A structural record carrier: a value that can be a view of a class allocation only through its origin. */
|
package/dist/identity/ids.d.ts
CHANGED
|
@@ -176,4 +176,8 @@ export declare const isRegionId: (owner: FunctionId | RegionId) => owner is Regi
|
|
|
176
176
|
export declare const fileIdentityOf: (owner: FunctionId | RegionId | DeclarationId) => string;
|
|
177
177
|
/** The role an already-minted result fills. */
|
|
178
178
|
export declare const roleOfResult: (result: SemanticResultId) => ResultRole;
|
|
179
|
+
/** A lexical cell associated with a declaration, distinct from its source
|
|
180
|
+
* declaration identity. Role slots are assigned by the owning language rule.
|
|
181
|
+
*/
|
|
182
|
+
export declare const lexicalCellDeclarationId: (owner: DeclarationId, slot: number) => DeclarationId;
|
|
179
183
|
export {};
|
package/dist/identity/ids.js
CHANGED
|
@@ -210,3 +210,7 @@ export const roleOfResult = (result) => {
|
|
|
210
210
|
throw new Error(`semantic result ${result} does not carry a known result role`);
|
|
211
211
|
return known;
|
|
212
212
|
};
|
|
213
|
+
/** A lexical cell associated with a declaration, distinct from its source
|
|
214
|
+
* declaration identity. Role slots are assigned by the owning language rule.
|
|
215
|
+
*/
|
|
216
|
+
export const lexicalCellDeclarationId = (owner, slot) => `lexical-cell|${encode(owner)}|${slot}`;
|
package/dist/ir/build.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NativeIterableReceipt } from '../semantics/model/native-iterable.js';
|
|
1
2
|
import type { DeclarationId, FunctionId, IrValueId, PhysicalBodyId, RegionId, SemanticResultId } from '../identity/ids.js';
|
|
2
3
|
import type { CallableAbi, Representation } from '../representation/model.js';
|
|
3
4
|
import type { ConstantLiteral } from '../semantics/model/operands.js';
|
|
@@ -113,7 +114,7 @@ export interface IrBodyBuilder {
|
|
|
113
114
|
readonly allocateArrayObject: (block: IrBlockId, lineage: SemanticResultId, elements: readonly IrArrayElement[], representation: Representation) => IrValueId;
|
|
114
115
|
readonly allocateCallable: (block: IrBlockId, lineage: SemanticResultId, functionId: FunctionId, captures: readonly IrOperand[], representation: Representation, callableOwnPrototype?: boolean) => IrValueId;
|
|
115
116
|
readonly bindCallable: (block: IrBlockId, lineage: SemanticResultId, source: IrOperand, sourceFunctionId: FunctionId | null, sourceAbi: CallableAbi, thisArgument: IrOperand | null, receiver: IrOperand | null, bound: readonly IrOperand[], representation: Representation, unboxedMethod?: UnboxedMethodAssumption, shadowGuarded?: true) => IrValueId;
|
|
116
|
-
readonly allocateConstructor: (block: IrBlockId, lineage: SemanticResultId, declaration: DeclarationId, captures: readonly IrOperand[], representation: Representation, heritage?: IrOperand) => IrValueId;
|
|
117
|
+
readonly allocateConstructor: (block: IrBlockId, lineage: SemanticResultId, declaration: DeclarationId, captures: readonly IrOperand[], representation: Representation, heritage?: IrOperand, constructionDeferred?: true) => IrValueId;
|
|
117
118
|
readonly allocateProxy: (block: IrBlockId, lineage: SemanticResultId, target: IrOperand, handler: IrOperand, representation: Representation) => IrValueId;
|
|
118
119
|
readonly proxyPart: (block: IrBlockId, lineage: SemanticResultId, proxy: IrOperand, part: 'target' | 'handler', representation: Representation) => IrValueId;
|
|
119
120
|
readonly proxyTrapCheck: (block: IrBlockId, lineage: SemanticResultId, trap: 'set' | 'deleteProperty', answer: IrOperand) => void;
|
|
@@ -130,11 +131,11 @@ export interface IrBodyBuilder {
|
|
|
130
131
|
readonly elementChild: (block: IrBlockId, lineage: SemanticResultId, node: IrOperand, child: IrOperand, textLeaf: boolean) => void;
|
|
131
132
|
/** `ToBoolean` of a value, for the conditional that has to branch on it. The result is a boolean scalar by construction. */
|
|
132
133
|
readonly test: (block: IrBlockId, lineage: SemanticResultId, value: IrOperand, predicate?: 'to-boolean' | 'is-present' | 'is-defined') => IrValueId;
|
|
133
|
-
readonly convert: (block: IrBlockId, lineage: SemanticResultId, conversionUse: ConversionUseId, source: IrOperand, representation: Representation, rebuild?: 'unshared-array', nativeCallableSource?: import('./native-callable-argument.js').NativeCallableSourceProof, nativeObjectSample?: import('./native-object-sample.js').NativeObjectSampleReceipt) => IrValueId;
|
|
134
|
+
readonly convert: (block: IrBlockId, lineage: SemanticResultId, conversionUse: ConversionUseId, source: IrOperand, representation: Representation, rebuild?: 'unshared-array' | 'unshared-dictionary', nativeCallableSource?: import('./native-callable-argument.js').NativeCallableSourceProof, nativeObjectSample?: import('./native-object-sample.js').NativeObjectSampleReceipt, releasesSource?: true) => IrValueId;
|
|
134
135
|
/** See `MergeLiveArmRebuildOperation` -- the control-flow-proven live-arm sibling of representation-global `convert`. */
|
|
135
136
|
readonly mergeLiveArmRebuild: (block: IrBlockId, lineage: SemanticResultId, source: IrOperand, representation: Representation, liveArms: readonly number[], sourceAbsenceLive: boolean, conversions: ConversionCensus) => IrValueId;
|
|
136
137
|
readonly deadLogicalMergeValue: (block: IrBlockId, lineage: SemanticResultId, source: IrOperand, representation: Representation) => IrValueId;
|
|
137
|
-
readonly getIterator: (block: IrBlockId, lineage: SemanticResultId, protocol: GetIteratorOperation['protocol'], receiver: IrOperand, method: IrOperand | null, representation: Representation) => IrValueId;
|
|
138
|
+
readonly getIterator: (block: IrBlockId, lineage: SemanticResultId, protocol: GetIteratorOperation['protocol'], receiver: IrOperand, method: IrOperand | null, representation: Representation, nativeIterable?: NativeIterableReceipt) => IrValueId;
|
|
138
139
|
readonly iteratorNext: (block: IrBlockId, lineage: SemanticResultId, iterator: IrOperand, value: IrOperand | null, representation: Representation, settlesValue?: boolean) => IrValueId;
|
|
139
140
|
/** `IteratorResult`'s `done` half -- see `IteratorDoneOperation`'s own comment (ir/model.ts) for why this is a separate op rather than a second result on `iteratorNext`. */
|
|
140
141
|
readonly iteratorDone: (block: IrBlockId, lineage: SemanticResultId, iterator: IrOperand, representation: Representation) => IrValueId;
|
package/dist/ir/build.js
CHANGED
|
@@ -386,9 +386,17 @@ export const createIrBodyBuilder = (owner, sourceOwner, abi, constructAbi = null
|
|
|
386
386
|
});
|
|
387
387
|
return result.id;
|
|
388
388
|
};
|
|
389
|
-
const allocateConstructor = (block, lineage, declaration, captures, representation, heritage) => {
|
|
389
|
+
const allocateConstructor = (block, lineage, declaration, captures, representation, heritage, constructionDeferred) => {
|
|
390
390
|
const result = mintResult(representation);
|
|
391
|
-
append(block, {
|
|
391
|
+
append(block, {
|
|
392
|
+
kind: 'allocate-constructor',
|
|
393
|
+
lineage,
|
|
394
|
+
declaration,
|
|
395
|
+
captures,
|
|
396
|
+
...(heritage ? { heritage } : {}),
|
|
397
|
+
...(constructionDeferred ? { constructionDeferred } : {}),
|
|
398
|
+
result
|
|
399
|
+
});
|
|
392
400
|
return result.id;
|
|
393
401
|
};
|
|
394
402
|
const allocateProxy = (block, lineage, target, handler, representation) => {
|
|
@@ -446,7 +454,7 @@ export const createIrBodyBuilder = (owner, sourceOwner, abi, constructAbi = null
|
|
|
446
454
|
append(block, { kind: 'test', lineage, predicate, value, result });
|
|
447
455
|
return result.id;
|
|
448
456
|
};
|
|
449
|
-
const convert = (block, lineage, conversionUse, source, representation, rebuild, nativeCallableSource, nativeObjectSample) => {
|
|
457
|
+
const convert = (block, lineage, conversionUse, source, representation, rebuild, nativeCallableSource, nativeObjectSample, releasesSource) => {
|
|
450
458
|
const result = mintResult(representation);
|
|
451
459
|
append(block, {
|
|
452
460
|
kind: 'convert',
|
|
@@ -455,6 +463,7 @@ export const createIrBodyBuilder = (owner, sourceOwner, abi, constructAbi = null
|
|
|
455
463
|
source,
|
|
456
464
|
result,
|
|
457
465
|
...(rebuild ? { rebuild } : {}),
|
|
466
|
+
...(rebuild === 'unshared-array' && releasesSource ? { releasesSource } : {}),
|
|
458
467
|
...(nativeCallableSource ? { nativeCallableSource } : {}),
|
|
459
468
|
...(nativeObjectSample ? { nativeObjectSample } : {})
|
|
460
469
|
});
|
|
@@ -479,9 +488,9 @@ export const createIrBodyBuilder = (owner, sourceOwner, abi, constructAbi = null
|
|
|
479
488
|
append(block, { kind: 'dead-logical-merge-value', lineage, source, result });
|
|
480
489
|
return result.id;
|
|
481
490
|
};
|
|
482
|
-
const getIterator = (block, lineage, protocol, receiver, method, representation) => {
|
|
491
|
+
const getIterator = (block, lineage, protocol, receiver, method, representation, nativeIterable) => {
|
|
483
492
|
const result = mintResult(representation);
|
|
484
|
-
append(block, { kind: 'get-iterator', lineage, protocol, receiver, method, result });
|
|
493
|
+
append(block, { kind: 'get-iterator', lineage, protocol, receiver, method, result, ...(nativeIterable ? { nativeIterable } : {}) });
|
|
485
494
|
return result.id;
|
|
486
495
|
};
|
|
487
496
|
const iteratorNext = (block, lineage, iterator, value, representation, settlesValue) => {
|