@geastack/compiler 1.0.33 → 1.0.35
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 +14 -6
- 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 +9 -4
- package/dist/ir/model.d.ts +39 -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.js +6 -1
- 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 +99 -13
- 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 +83 -22
- 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 +2399 -676
- package/dist/representation/any-null-record-members.d.ts +0 -41
- package/dist/representation/any-null-record-members.js +0 -115
- package/dist/semantics/any-null-member-declarations.d.ts +0 -32
- package/dist/semantics/any-null-member-declarations.js +0 -90
- package/dist/semantics/normalize/fresh-array-result.d.ts +0 -32
- package/dist/semantics/normalize/fresh-array-result.js +0 -125
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, readFileSync, mkdirSync, writeFileSync, realpathSync, readdirSync, rmSync } from 'node:fs';
|
|
2
|
-
import { dirname, resolve, isAbsolute, join } from 'node:path';
|
|
2
|
+
import { dirname, resolve, isAbsolute, join, sep } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
@@ -42,13 +42,20 @@ const ownPackageName = () => {
|
|
|
42
42
|
return undefined;
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
+
// npm is npm.cmd on Windows, which only a shell can start: spawned directly it
|
|
46
|
+
// fails with ENOENT, and every package source fetch fell back to the installed
|
|
47
|
+
// JavaScript. cmd.exe takes one command line, so each argument is quoted for it
|
|
48
|
+
// here rather than concatenated unescaped.
|
|
49
|
+
const quoteForCmd = (value) => value !== '' && !/[\s"^&|<>()!,;=]/.test(value) ? value : `"${value.replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, '$1$1')}"`;
|
|
45
50
|
const run = (command, args, cwd) => {
|
|
46
|
-
const
|
|
51
|
+
const viaShell = process.platform === 'win32' && command === 'npm';
|
|
52
|
+
const result = spawnSync(viaShell ? [command, ...args].map(quoteForCmd).join(' ') : command, viaShell ? [] : [...args], {
|
|
47
53
|
cwd,
|
|
48
54
|
encoding: 'utf8',
|
|
49
55
|
timeout: 120000,
|
|
50
56
|
maxBuffer: 16 * 1024 * 1024,
|
|
51
|
-
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' }
|
|
57
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
58
|
+
shell: viaShell
|
|
52
59
|
});
|
|
53
60
|
if (result.error)
|
|
54
61
|
throw result.error;
|
|
@@ -228,10 +235,34 @@ const fetchAttestations = async (url) => {
|
|
|
228
235
|
throw new Error(`Provenance request failed (${response.status})`);
|
|
229
236
|
return object(await response.json());
|
|
230
237
|
};
|
|
231
|
-
|
|
238
|
+
// Git for Windows refuses paths over MAX_PATH unless asked per command; a
|
|
239
|
+
// package's sources sit deep under node_modules/.cache, and some repositories
|
|
240
|
+
// have long paths of their own.
|
|
241
|
+
const longPaths = process.platform === 'win32' ? ['-c', 'core.longpaths=true'] : [];
|
|
242
|
+
/** Whether `destination` holds a finished checkout of `commit`. */
|
|
243
|
+
const checkedOut = (destination, commit) => {
|
|
244
|
+
if (!existsSync(join(destination, '.git')))
|
|
245
|
+
return false;
|
|
246
|
+
try {
|
|
247
|
+
return (run('git', [...longPaths, 'rev-parse', 'HEAD'], destination) === commit &&
|
|
248
|
+
run('git', [...longPaths, 'status', '--porcelain'], destination) === '');
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
export const checkout = (identity, destination) => {
|
|
255
|
+
// A finished checkout of this commit (another package of the same
|
|
256
|
+
// repository) is reused. Anything else in the destination is what an
|
|
257
|
+
// interrupted attempt left -- files a fresh checkout would refuse to
|
|
258
|
+
// overwrite ("untracked working tree files would be overwritten") -- so the
|
|
259
|
+
// attempt starts from an empty directory.
|
|
260
|
+
if (checkedOut(destination, identity.commit))
|
|
261
|
+
return;
|
|
262
|
+
rmSync(destination, { recursive: true, force: true });
|
|
232
263
|
mkdirSync(destination, { recursive: true });
|
|
233
264
|
run('git', ['init', '--quiet', destination], destination);
|
|
234
|
-
const args = ['-c', 'core.hooksPath=/dev/null', '-c', 'protocol.file.allow=never', '-c', 'protocol.ext.allow=never'];
|
|
265
|
+
const args = ['-c', 'core.hooksPath=/dev/null', '-c', 'protocol.file.allow=never', '-c', 'protocol.ext.allow=never', ...longPaths];
|
|
235
266
|
run('git', [...args, 'fetch', '--quiet', '--depth=1', '--no-tags', identity.url, identity.commit], destination);
|
|
236
267
|
// This is a newly created compiler-owned cache, never a user checkout.
|
|
237
268
|
run('git', [...args, 'checkout', '--quiet', '--detach', identity.commit], destination);
|
|
@@ -298,7 +329,8 @@ const provideDevelopmentTypes = (packageRoot, origin, files, fetch) => {
|
|
|
298
329
|
seen.add(typesName);
|
|
299
330
|
const described = describedPackageOf(typesName);
|
|
300
331
|
const installed = installedPackage(described, origin, files);
|
|
301
|
-
|
|
332
|
+
// In the host's separators: `\node_modules\@scope\name` on Windows.
|
|
333
|
+
if (!installed || !installed.endsWith(`${sep}${join('node_modules', described)}`))
|
|
302
334
|
continue;
|
|
303
335
|
if (shipsDeclarations(installed, manifestAt(installed, files), files))
|
|
304
336
|
continue;
|
|
@@ -390,11 +422,21 @@ const checkoutPackageRoot = (destination, directory, manifest, files) => {
|
|
|
390
422
|
}
|
|
391
423
|
throw new Error('Checkout package identity does not match the installed package');
|
|
392
424
|
};
|
|
425
|
+
/**
|
|
426
|
+
* The manifest `npm view <name>@<version> --json` printed. npm 11 prints the
|
|
427
|
+
* one matching version's manifest as an object; npm 12 prints an array of the
|
|
428
|
+
* matching versions' manifests, which for an exact version holds one. Anything
|
|
429
|
+
* else is no manifest (`{}`), which the version check below refuses.
|
|
430
|
+
*/
|
|
431
|
+
export const registryManifest = (json) => {
|
|
432
|
+
const parsed = JSON.parse(json);
|
|
433
|
+
return object(Array.isArray(parsed) && parsed.length === 1 ? parsed[0] : parsed);
|
|
434
|
+
};
|
|
393
435
|
/** Acquire missing typed sources at the installed version; plain JS remains usable. */
|
|
394
436
|
export const preparePackageSources = async (root, options = {}) => {
|
|
395
437
|
const files = options.files ?? disk;
|
|
396
438
|
const log = options.log ?? console.error;
|
|
397
|
-
const metadata = options.metadata ?? (async (name, version, cwd) =>
|
|
439
|
+
const metadata = options.metadata ?? (async (name, version, cwd) => registryManifest(run('npm', ['view', `${name}@${version}`, '--json'], cwd)));
|
|
398
440
|
const attestations = options.attestations ?? (async (url) => fetchAttestations(url));
|
|
399
441
|
const sources = [];
|
|
400
442
|
const visited = new Set();
|
|
@@ -166,6 +166,19 @@ export interface BindingPlacement {
|
|
|
166
166
|
/** The carrier the plan selected for the value this cell holds, or `null` when the introduction published none. */
|
|
167
167
|
readonly representation: Representation | null;
|
|
168
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* The one spelling of a host declaration file that the per-file host tables
|
|
171
|
+
* (`hostFunctionsByDeclaration` and its siblings) and their lookups share.
|
|
172
|
+
*
|
|
173
|
+
* TypeScript names every source file with `/` separators on every platform,
|
|
174
|
+
* while a plugin builds its keys with `node:path` -- `C:\...\index.d.ts` on
|
|
175
|
+
* Windows. Matched verbatim, no Windows key ever matched: a plugin's claimed
|
|
176
|
+
* host functions (`@geastack/parallel`'s `tasks`) silently stayed unclaimed
|
|
177
|
+
* there, and with them every parallel region went uncertified as a region.
|
|
178
|
+
*/
|
|
179
|
+
export declare const hostDeclarationFileKey: (file: string) => string;
|
|
180
|
+
/** A per-declaration-file host table with every key in `hostDeclarationFileKey` spelling. */
|
|
181
|
+
export declare const hostDeclarationFileTable: <T>(entries: Iterable<readonly [string, T]>) => Map<string, T>;
|
|
169
182
|
export interface BindingPlacementInput {
|
|
170
183
|
readonly graph: SemanticGraph;
|
|
171
184
|
readonly plan: SealedRepresentationPlan;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { resultOf } from '../semantics/model/operands.js';
|
|
2
|
+
/**
|
|
3
|
+
* The one spelling of a host declaration file that the per-file host tables
|
|
4
|
+
* (`hostFunctionsByDeclaration` and its siblings) and their lookups share.
|
|
5
|
+
*
|
|
6
|
+
* TypeScript names every source file with `/` separators on every platform,
|
|
7
|
+
* while a plugin builds its keys with `node:path` -- `C:\...\index.d.ts` on
|
|
8
|
+
* Windows. Matched verbatim, no Windows key ever matched: a plugin's claimed
|
|
9
|
+
* host functions (`@geastack/parallel`'s `tasks`) silently stayed unclaimed
|
|
10
|
+
* there, and with them every parallel region went uncertified as a region.
|
|
11
|
+
*/
|
|
12
|
+
export const hostDeclarationFileKey = (file) => file.replace(/\\/g, '/');
|
|
13
|
+
/** A per-declaration-file host table with every key in `hostDeclarationFileKey` spelling. */
|
|
14
|
+
export const hostDeclarationFileTable = (entries) => {
|
|
15
|
+
const table = new Map();
|
|
16
|
+
for (const [file, value] of entries)
|
|
17
|
+
table.set(hostDeclarationFileKey(file), value);
|
|
18
|
+
return table;
|
|
19
|
+
};
|
|
2
20
|
/**
|
|
3
21
|
* The storage a host claims for a name, or `null` when no host claims it.
|
|
4
22
|
*
|
|
@@ -38,7 +56,8 @@ const hostStorageOf = (input, declaration, linkageName, representation) => {
|
|
|
38
56
|
// this program actually resolved to says which was meant. Computed once and
|
|
39
57
|
// reused below, since it is the same file for every one of these questions
|
|
40
58
|
// about the same declaration.
|
|
41
|
-
const
|
|
59
|
+
const recorded = input.externalFiles?.get(declaration);
|
|
60
|
+
const file = recorded === undefined ? undefined : hostDeclarationFileKey(recorded);
|
|
42
61
|
const declaredConstant = file === undefined ? undefined : input.hostConstantsByDeclaration?.get(file)?.get(linkageName);
|
|
43
62
|
if (declaredConstant !== undefined)
|
|
44
63
|
return { kind: 'host-constant', linkageName, emit: declaredConstant };
|
|
@@ -96,6 +96,8 @@ export interface ClassAccessor {
|
|
|
96
96
|
export interface ClassLayout {
|
|
97
97
|
/** Proven layout demand with no reachable class evaluation/construction. */
|
|
98
98
|
readonly layoutOnly?: boolean;
|
|
99
|
+
/** Class definition runs, but the source construction inventory is empty. */
|
|
100
|
+
readonly constructionDeferred?: boolean;
|
|
99
101
|
readonly nativeStorage?: NativeClassStorage;
|
|
100
102
|
/** Typed own-property shadows, initially absent; prototype methods remain methods. */
|
|
101
103
|
readonly methodOverrides?: readonly RecordField[];
|
|
@@ -232,7 +234,7 @@ export declare const classLayoutOfCopy: (classes: ReadonlyMap<DeclarationId, Cla
|
|
|
232
234
|
* it names the source function -- the root every copy is cut from -- while a
|
|
233
235
|
* generic class's layout names the copy body it kept. Every copy of one class
|
|
234
236
|
* that folds onto one struct keeps ONE body, so no per-copy spelling at the
|
|
235
|
-
* site could name it either:
|
|
237
|
+
* site could name it either: a database driver's `new FindCursor(...)` in
|
|
236
238
|
* `Collection.find` names `fn|decl|f166|167` against a layout whose seven
|
|
237
239
|
* copies kept `fn|decl|f166|167@6`, and exact equality read that as a
|
|
238
240
|
* contradictory implementation, left the construction open and pulled the
|
|
@@ -337,7 +339,7 @@ export declare const publishClassMethodOverrides: (layouts: ReadonlyMap<Declarat
|
|
|
337
339
|
/**
|
|
338
340
|
* Whether an object literal can be laid out as this class without being its
|
|
339
341
|
* instance: TypeScript accepts `{ w: 0 }` where a `WriteConcern` is declared
|
|
340
|
-
* because a class type is structural, and
|
|
342
|
+
* because a class type is structural, and a database driver writes exactly that. The
|
|
341
343
|
* literal takes the class's native layout but none of its behaviour, so the
|
|
342
344
|
* layout may be shared only where the class HAS no behaviour a read could
|
|
343
345
|
* reach -- no prototype method or accessor (the literal inherits neither), no
|
|
@@ -48,7 +48,7 @@ const copyIndexes = new WeakMap();
|
|
|
48
48
|
* it names the source function -- the root every copy is cut from -- while a
|
|
49
49
|
* generic class's layout names the copy body it kept. Every copy of one class
|
|
50
50
|
* that folds onto one struct keeps ONE body, so no per-copy spelling at the
|
|
51
|
-
* site could name it either:
|
|
51
|
+
* site could name it either: a database driver's `new FindCursor(...)` in
|
|
52
52
|
* `Collection.find` names `fn|decl|f166|167` against a layout whose seven
|
|
53
53
|
* copies kept `fn|decl|f166|167@6`, and exact equality read that as a
|
|
54
54
|
* contradictory implementation, left the construction open and pulled the
|
|
@@ -188,7 +188,7 @@ const genericRootOf = (declaration) => {
|
|
|
188
188
|
* The result was a class whose members were published under an id no consumer
|
|
189
189
|
* ever asks about. `classMemberOf` looked up the carrier's root, found
|
|
190
190
|
* nothing, and `emit-class-properties.ts` refused with "whose members no class
|
|
191
|
-
* evaluation published" -- for
|
|
191
|
+
* evaluation published" -- for an HTTP framework's context and application classes, whose every method
|
|
192
192
|
* read (`c.text`, `c.json`, `c.req`, `app.fetch`) died on it.
|
|
193
193
|
*
|
|
194
194
|
* So the copy id is re-keyed onto the root, and ONLY when the root has exactly
|
|
@@ -310,6 +310,7 @@ const collapseSpecializations = (layouts, physicalOf) => {
|
|
|
310
310
|
merged.set(root, {
|
|
311
311
|
declaration: root,
|
|
312
312
|
...(group.every((layout) => layout.layoutOnly) ? { layoutOnly: true } : {}),
|
|
313
|
+
...(group.every((layout) => layout.constructionDeferred) ? { constructionDeferred: true } : {}),
|
|
313
314
|
base: group.find((layout) => layout.base !== null)?.base ?? null,
|
|
314
315
|
...(group.find((layout) => layout.base !== null)?.prototypeBase ? { prototypeBase: true } : {}),
|
|
315
316
|
...(group.every((layout) => layout.uninstantiable) ? { uninstantiable: true } : {}),
|
|
@@ -471,6 +472,7 @@ export const projectClasses = (input) => {
|
|
|
471
472
|
const instances = new Map();
|
|
472
473
|
const constructors = new Map();
|
|
473
474
|
const layoutOnly = new Set();
|
|
475
|
+
const constructionDeferred = new Set();
|
|
474
476
|
const bases = new Map();
|
|
475
477
|
// The copy id a heritage expression's binding read names, per class id.
|
|
476
478
|
const baseCopies = new Map();
|
|
@@ -596,9 +598,13 @@ export const projectClasses = (input) => {
|
|
|
596
598
|
const allocated = operation.classDeclaration === undefined ? null : genericRootOf(operation.classDeclaration);
|
|
597
599
|
const members = carrier?.kind === 'constructor-family' ? carrier.members : [];
|
|
598
600
|
for (const member of members.filter((one) => allocated === null || members.length === 1 || genericRootOf(one) === allocated)) {
|
|
599
|
-
|
|
601
|
+
if (operation.classConstructionDeferred)
|
|
602
|
+
constructionDeferred.add(member);
|
|
603
|
+
constructs.set(member, operation.classConstructionDeferred ? null : abi);
|
|
600
604
|
instances.set(member, abi?.result ?? null);
|
|
601
|
-
constructors.set(member,
|
|
605
|
+
constructors.set(member, operation.classConstructionDeferred
|
|
606
|
+
? null
|
|
607
|
+
: (constructorBodies.get(member) ?? constructorBodyOfCopy(operation) ?? constructorBodyOfRoot(member)));
|
|
602
608
|
}
|
|
603
609
|
if (operation.classDeclaration !== undefined && operation.functionName !== undefined)
|
|
604
610
|
names.set(operation.classDeclaration, operation.functionName);
|
|
@@ -766,6 +772,7 @@ export const projectClasses = (input) => {
|
|
|
766
772
|
layouts.set(declaration, {
|
|
767
773
|
declaration,
|
|
768
774
|
...(layoutOnly.has(declaration) ? { layoutOnly: true } : {}),
|
|
775
|
+
...(constructionDeferred.has(declaration) ? { constructionDeferred: true } : {}),
|
|
769
776
|
base: bases.get(declaration) ?? null,
|
|
770
777
|
...(prototypeBases.has(declaration) && bases.has(declaration) ? { prototypeBase: true } : {}),
|
|
771
778
|
...(input.uninstantiable?.has(declaration) ? { uninstantiable: true } : {}),
|
|
@@ -1077,7 +1084,7 @@ export const publishClassMethodOverrides = (layouts, input) => {
|
|
|
1077
1084
|
/**
|
|
1078
1085
|
* Whether an object literal can be laid out as this class without being its
|
|
1079
1086
|
* instance: TypeScript accepts `{ w: 0 }` where a `WriteConcern` is declared
|
|
1080
|
-
* because a class type is structural, and
|
|
1087
|
+
* because a class type is structural, and a database driver writes exactly that. The
|
|
1081
1088
|
* literal takes the class's native layout but none of its behaviour, so the
|
|
1082
1089
|
* layout may be shared only where the class HAS no behaviour a read could
|
|
1083
1090
|
* reach -- no prototype method or accessor (the literal inherits neither), no
|
|
@@ -35,6 +35,8 @@ export const hasReferenceIdentity = (representation) => {
|
|
|
35
35
|
if (representation.kind === 'tagged-union')
|
|
36
36
|
return representation.arms.every((arm) => hasReferenceIdentity(arm.value));
|
|
37
37
|
switch (representation.kind) {
|
|
38
|
+
case 'native-handle':
|
|
39
|
+
return representation.native !== null && representation.referenceIdentity === true;
|
|
38
40
|
case 'class-ref':
|
|
39
41
|
case 'record':
|
|
40
42
|
case 'record-with-index':
|
|
@@ -2667,6 +2667,7 @@ unwrittenMembers = new Map()) => {
|
|
|
2667
2667
|
protocol: bound.protocol,
|
|
2668
2668
|
version: bound.version,
|
|
2669
2669
|
native: bound.native,
|
|
2670
|
+
referenceIdentity: binding.referenceIdentityOf?.(bound.native) === true,
|
|
2670
2671
|
bases: binding.basesOf(bound.native),
|
|
2671
2672
|
viewsFrom: binding.viewsInto?.(bound.native) ?? new Map(),
|
|
2672
2673
|
call,
|
|
@@ -402,6 +402,8 @@ export type Representation =
|
|
|
402
402
|
* that share one runtime type share one claim and one member table.
|
|
403
403
|
*/
|
|
404
404
|
readonly native: string | null;
|
|
405
|
+
/** Host promises identity() with an owner retained by native carrier copies. */
|
|
406
|
+
readonly referenceIdentity?: boolean;
|
|
405
407
|
/**
|
|
406
408
|
* Every host carrier this one derives from, transitively, as the host
|
|
407
409
|
* states it (`PluginCapabilities.nativeBases`) -- nearest base first,
|
|
@@ -307,6 +307,7 @@ const buildRepresentationKey = (representation) => {
|
|
|
307
307
|
// collide under one key, which is exactly the "one value, two carriers"
|
|
308
308
|
// case `representationKey` exists to catch.
|
|
309
309
|
return (`native-handle(${representation.protocol}@${representation.version}` +
|
|
310
|
+
`${representation.referenceIdentity === true ? ';identity=owner' : ''}` +
|
|
310
311
|
`;call=${representation.call ? abiKey(representation.call) : '-'}` +
|
|
311
312
|
`;construct=${representation.construct ? abiKey(representation.construct) : '-'})`);
|
|
312
313
|
case 'record':
|
|
@@ -125,6 +125,8 @@ export interface HostBindingPolicy {
|
|
|
125
125
|
*/
|
|
126
126
|
readonly basesOf: (native: string | null) => readonly string[];
|
|
127
127
|
readonly viewsInto?: (native: string | null) => ReadonlyMap<string, string>;
|
|
128
|
+
/** Explicit host contract, never inferred from a native type name. */
|
|
129
|
+
readonly referenceIdentityOf?: (native: string | null) => boolean;
|
|
128
130
|
}
|
|
129
131
|
/** No bindings installed: every declared type falls through to its structural answer, unchanged. */
|
|
130
132
|
export declare const defaultHostBindingPolicy: HostBindingPolicy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { primitiveDomainOf, sharedPrimitiveDomainOf } from '../semantics/model/primitive-domain.js';
|
|
1
|
+
export { joinedPrimitiveDomainOf, primitiveDomainOf, sharedPrimitiveDomainOf } from '../semantics/model/primitive-domain.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { primitiveDomainOf, sharedPrimitiveDomainOf } from '../semantics/model/primitive-domain.js';
|
|
1
|
+
export { joinedPrimitiveDomainOf, primitiveDomainOf, sharedPrimitiveDomainOf } from '../semantics/model/primitive-domain.js';
|
|
@@ -19,7 +19,12 @@ export const unassignedBindingAbsenceOf = (graph) => {
|
|
|
19
19
|
if (operation.external || operation.commonJs)
|
|
20
20
|
continue;
|
|
21
21
|
const value = resultOf(operation, 'value');
|
|
22
|
-
|
|
22
|
+
// A declared type that already admits undefined (`let x: T | undefined`)
|
|
23
|
+
// states the initial absence itself: its carrier holds it, and each read's
|
|
24
|
+
// checker type is sound as published. Forcing the absence onto such a cell's
|
|
25
|
+
// reads would undo the narrowing of a guarded read, so `if (x) take(x)` would
|
|
26
|
+
// hand an optional to a position that states `T`.
|
|
27
|
+
if (value && !includesUndefined(value.type))
|
|
23
28
|
declared.set(operation.declaration, { owner: ownerOf(operation.caller), result: value.id });
|
|
24
29
|
}
|
|
25
30
|
const declarations = new Set();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { primitiveDomainOf } from './primitive-domain.js';
|
|
1
|
+
import { joinedPrimitiveDomainOf, primitiveDomainOf } from './primitive-domain.js';
|
|
2
2
|
import { representationKey } from './model.js';
|
|
3
3
|
import { optionalOf } from './optional.js';
|
|
4
4
|
import { primitiveCarrier, storedCarrier, unresolved } from './primitives.js';
|
|
@@ -292,11 +292,11 @@ export const createUnionDeriver = (context) => {
|
|
|
292
292
|
// A union of literals of one primitive is that primitive: the arms differ in
|
|
293
293
|
// value, not in carrier, so a sum would add a tag that discriminates nothing.
|
|
294
294
|
// `primitiveDomainOf` is the one authority for "these values are all this
|
|
295
|
-
// primitive" -- `value-records.ts` asks it of a record's field
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const carrier =
|
|
295
|
+
// primitive" -- `value-records.ts` asks it of a record's field -- and
|
|
296
|
+
// `joinedPrimitiveDomainOf` for "these Numbers are one Number carrier".
|
|
297
|
+
const primitive = joinedPrimitiveDomainOf(new Set(present.map((member) => primitiveDomainOf(shapeOf(member)))));
|
|
298
|
+
if (primitive !== null) {
|
|
299
|
+
const carrier = primitiveCarrier(primitive);
|
|
300
300
|
if (carrier)
|
|
301
301
|
return carrier;
|
|
302
302
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NativeIterableProvider } from '../plugins/native-iterable-providers.js';
|
|
1
2
|
import type { PackageSource } from './package-sources.js';
|
|
2
3
|
import type { CommonJsWrapperDeclaration, HostNativeTypeDeclaration, HostOwnedDeclaration, NativeHostFunctionDeclaration } from '../plugins/model.js';
|
|
3
4
|
import { type NativeFunctionSignatureCensus } from './native-function-signatures.js';
|
|
@@ -54,6 +55,7 @@ export interface FrontendInput {
|
|
|
54
55
|
* this file behaves exactly as it did.
|
|
55
56
|
*/
|
|
56
57
|
readonly nativeTypes?: ReadonlyMap<string, string>;
|
|
58
|
+
readonly nativeIterableProviders?: ReadonlyMap<string, NativeIterableProvider>;
|
|
57
59
|
/** Exact host-owned native type declarations; see `PluginCapabilities.nativeTypesByDeclaration`. */
|
|
58
60
|
readonly nativeTypesByDeclaration?: ReadonlyMap<string, HostNativeTypeDeclaration>;
|
|
59
61
|
/** Exact host-owned singleton declarations; see `PluginCapabilities.hostSingletonDeclarations`. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { sourceNativeIterableOf } from './normalize/source-native-iterable.js';
|
|
2
|
+
import { sourceConstructorSelectionsOf } from './normalize/flow/member-call-forwarding.js';
|
|
1
3
|
import { withSharedArrayStorage } from './normalize/shared-array-storage.js';
|
|
2
4
|
import { deadEventCallsOf } from './normalize/dead-event-emissions.js';
|
|
3
5
|
import { censusNativeFunctionSignatures } from './native-function-signatures.js';
|
|
@@ -36,7 +38,7 @@ import { createCensusComputedKeysOf } from './normalize/host-mutation-computed-k
|
|
|
36
38
|
import { closedCallableAuthorityOf } from './normalize/flow/callable-reach.js';
|
|
37
39
|
import { sourceDescriptorOwnProtocolOf } from './normalize/flow/source-descriptor-protocol.js';
|
|
38
40
|
import { sourceAccessorDescriptorOf, sourceAccessorDescriptorOwnNamesOf } from './normalize/flow/source-accessor-descriptor.js';
|
|
39
|
-
import { retireSourceValueSession, sourceValueSessionOf } from './normalize/flow/source-value-session.js';
|
|
41
|
+
import { retireSourceValueSession, shareSourceValueSession, sourceValueSessionOf } from './normalize/flow/source-value-session.js';
|
|
40
42
|
import { sourceNativeClassAliasTypeAt } from './normalize/flow/source-native-class-alias.js';
|
|
41
43
|
import { createSpecializedSourceFrames } from './normalize/specialized-source-frames.js';
|
|
42
44
|
import { attachDeferredIntrinsicProtocolLedger, createDeferredIntrinsicProtocolLedger, failedIntrinsicProtocolRequirements, intrinsicProtocolRequirementKind } from './normalize/deferred-intrinsic-protocols.js';
|
|
@@ -56,14 +58,15 @@ import { withLocalBindings } from './normalize/local-bindings.js';
|
|
|
56
58
|
import { withFieldBindings } from './normalize/field-bindings.js';
|
|
57
59
|
import { censusCollectionBindings } from './normalize/collection-bindings.js';
|
|
58
60
|
import { censusObjectBagBindings, emptyObjectBagCensus } from './normalize/object-bag-bindings.js';
|
|
59
|
-
import { indexValueFlow } from './normalize/flow/value-flow.js';
|
|
61
|
+
import { indexValueFlow, sameValueFlowContent } from './normalize/flow/value-flow.js';
|
|
60
62
|
import { attachClosedScriptScope, attachStatedModuleSet } from './normalize/flow/targets.js';
|
|
61
63
|
import { censusRefusalCounts } from './normalize/census-refusal.js';
|
|
62
64
|
import { createCellPolicyRegistry, defaultCellEvidencePolicies, buildCellFactsTable, publishCellFacts } from './normalize/cells/index.js';
|
|
63
65
|
import { settleBindingCensus } from './normalize/binding-fixpoint.js';
|
|
64
66
|
import { withJsDocTypeNames } from './normalize/jsdoc-type-names.js';
|
|
65
|
-
import { censusReachability, fileEvaluates, moduleEvaluationOrder, nodeIsReachable } from './normalize/reachability.js';
|
|
67
|
+
import { censusReachability, wholeProgram, fileEvaluates, moduleEvaluationOrder, nodeIsReachable } from './normalize/reachability.js';
|
|
66
68
|
import { createProgram, defaultCompilerOptions } from './program.js';
|
|
69
|
+
import { createJsxRuntimeModuleResolver } from './jsx-runtime-provider.js';
|
|
67
70
|
import { createFrontendTiming } from './frontend-timing.js';
|
|
68
71
|
import { deadMethodCopiesOf } from './normalize/dead-method-copies.js';
|
|
69
72
|
import { classCopyHeritageOf, classHeritageOf, nativeCollectionOverridesOf, nativeErrorOverridesOf } from './class-heritage.js';
|
|
@@ -306,9 +309,16 @@ export const runFrontend = (input) => {
|
|
|
306
309
|
// walked the file set compiled a different program than the one that runs.
|
|
307
310
|
// See `reachability.ts` for what it refuses to prune and why; nothing here
|
|
308
311
|
// changes what a type *means*, only which declarations are censused.
|
|
312
|
+
let constructionFlow;
|
|
309
313
|
const reachable = censusReachability({
|
|
310
314
|
checker: compiled.checker,
|
|
311
315
|
files: compiled.sourceFiles,
|
|
316
|
+
runtimeExportOf: (file, name) => compiled.runtimeExportOf(file.fileName, name),
|
|
317
|
+
constructorTargetsOf: (expression) => {
|
|
318
|
+
constructionFlow ??= indexValueFlow(compiled.checker, compiled.sourceFiles, wholeProgram);
|
|
319
|
+
const selected = sourceConstructorSelectionsOf(compiled.checker, constructionFlow, expression);
|
|
320
|
+
return selected?.every(ts.isClassDeclaration) ? selected : null;
|
|
321
|
+
},
|
|
312
322
|
// A CommonJS module is not an ESM entry: it runs only from its record's
|
|
313
323
|
// `require`, so it must not join `moduleEvaluationOrder`. Its body still
|
|
314
324
|
// has to be censused and lowered for that record to invoke, which is why
|
|
@@ -503,10 +513,23 @@ export const runFrontend = (input) => {
|
|
|
503
513
|
const valueFlow = upstream && !process.env['GEA_FLOW_CENSUS_OFF']
|
|
504
514
|
? indexValueFlow(compiled.checker, compiled.sourceFiles, reachable, censusTypeVia(upstream), upstream.callDeclarationAt, upstream.callTargetsAt, buildIsStrict, upstream.explicitThisAt)
|
|
505
515
|
: baseValueFlow;
|
|
516
|
+
// The round that settles the fixpoint rebuilds the very index the round
|
|
517
|
+
// before it built (its census inputs no longer move), and that round's
|
|
518
|
+
// solver already holds every answer a fresh one would derive again from
|
|
519
|
+
// nothing -- on a large program, the most expensive work a round does.
|
|
520
|
+
// Only the session is carried over, never the index itself: other caches
|
|
521
|
+
// keyed on an index may hold answers that also depend on the round's
|
|
522
|
+
// census, while a session depends on nothing but its index
|
|
523
|
+
// (`shareSourceValueSession`). `GEA_SESSION_SHARE_OFF` keeps the
|
|
524
|
+
// rebuild, so the claim stays checkable from one build.
|
|
525
|
+
const sharedFrom = process.env['GEA_SESSION_SHARE_OFF'] === undefined
|
|
526
|
+
? roundFlows.find((earlier) => earlier !== valueFlow && sameValueFlowContent(earlier, valueFlow) && shareSourceValueSession(earlier, valueFlow))
|
|
527
|
+
: undefined;
|
|
506
528
|
// A round's solver is asked nothing once the next round's index replaces
|
|
507
|
-
// it (`retireSourceValueSession`); keeping it cost ~1 GB per round.
|
|
529
|
+
// it (`retireSourceValueSession`); keeping it cost ~1 GB per round. A
|
|
530
|
+
// solver handed on above is the new round's own, and stays.
|
|
508
531
|
for (const earlier of roundFlows)
|
|
509
|
-
if (earlier !== valueFlow)
|
|
532
|
+
if (earlier !== valueFlow && earlier !== sharedFrom)
|
|
510
533
|
retireSourceValueSession(earlier);
|
|
511
534
|
roundFlows.length = 0;
|
|
512
535
|
roundFlows.push(valueFlow);
|
|
@@ -948,6 +971,11 @@ export const runFrontend = (input) => {
|
|
|
948
971
|
actualArgumentSites.add(site);
|
|
949
972
|
const settledArgumentsObjects = { ...argumentsObjects, actualFrameOf: (node) => actualArgumentSites.has(node) };
|
|
950
973
|
const context = {
|
|
974
|
+
nativeIterableAt: (source, consumer) => {
|
|
975
|
+
if (!hostMutationFactsSealed)
|
|
976
|
+
return null;
|
|
977
|
+
return sourceNativeIterableOf(context, valueFlow, input.nativeIterableProviders ?? new Map(), source, consumer);
|
|
978
|
+
},
|
|
951
979
|
installedGlobalPropertyBindingAt: (node) => ts.isPropertyAccessExpression(node) ? (installedGlobalProperties.get(node) ?? null) : null,
|
|
952
980
|
ownsInstalledGlobalProperty: (declaration) => ownedGlobalProperties.has(declaration),
|
|
953
981
|
nativeCollectionOverrides,
|
|
@@ -1039,6 +1067,7 @@ export const runFrontend = (input) => {
|
|
|
1039
1067
|
runtimeModuleTargetOf: compiled.runtimeModuleTargetOf,
|
|
1040
1068
|
absentRequirePackageOf: compiled.absentRequirePackageOf,
|
|
1041
1069
|
sourceFileOf: compiled.sourceFileOf,
|
|
1070
|
+
jsxRuntimeModuleOf: createJsxRuntimeModuleResolver(compiled),
|
|
1042
1071
|
absentGlobals: absent,
|
|
1043
1072
|
argumentsObjects: settledArgumentsObjects,
|
|
1044
1073
|
unresolvableNames,
|
|
@@ -119,7 +119,10 @@ packageDeclarationNameOf) => {
|
|
|
119
119
|
// Every declaration is still accounted for. Coverage is an explicit host
|
|
120
120
|
// fact anchored to a primary declaration, not permission to ignore another
|
|
121
121
|
// overload. A caller augmentation in any other file remains unclaimed.
|
|
122
|
-
if (!inherited.every((declaration) => claimed.some((claim) => claim.inheritedDeclarations?.some((coverage) =>
|
|
122
|
+
if (!inherited.every((declaration) => claimed.some((claim) => claim.inheritedDeclarations?.some((coverage) =>
|
|
123
|
+
// Resolved on both sides: a host names the file as Node resolved it
|
|
124
|
+
// (`C:\...` on Windows), TypeScript as `C:/...`.
|
|
125
|
+
resolve(coverage.declarationFileName) === resolve(declaration.declarationFileName) &&
|
|
123
126
|
coverage.owner === declaration.owner &&
|
|
124
127
|
coverage.member === declaration.member))))
|
|
125
128
|
return null;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import type { CompiledProgram } from './program.js';
|
|
3
|
+
/** Project-selected automatic JSX runtime, using the Program's existing module
|
|
4
|
+
* authority. This does not assign any rendering semantics to that provider. */
|
|
5
|
+
export declare const createJsxRuntimeModuleResolver: (compiled: Pick<CompiledProgram, "program" | "runtimeModuleTargetOf" | "sourceFileOf">) => ((containingFile: string) => ts.SourceFile | null);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
/** Project-selected automatic JSX runtime, using the Program's existing module
|
|
3
|
+
* authority. This does not assign any rendering semantics to that provider. */
|
|
4
|
+
export const createJsxRuntimeModuleResolver = (compiled) => (containingFile) => {
|
|
5
|
+
const options = compiled.program.getCompilerOptions();
|
|
6
|
+
const source = compiled.sourceFileOf(containingFile);
|
|
7
|
+
// Per-file overrides require their own frontend projection. Refusing an
|
|
8
|
+
// ambiguous witness is preferable to attributing it to the project provider.
|
|
9
|
+
if (source === null || /@jsx(?:ImportSource|Runtime)\b/.test(source.text))
|
|
10
|
+
return null;
|
|
11
|
+
if ((options.jsx !== ts.JsxEmit.ReactJSX && options.jsx !== ts.JsxEmit.ReactJSXDev) || !options.jsxImportSource)
|
|
12
|
+
return null;
|
|
13
|
+
const specifier = `${options.jsxImportSource}/${options.jsx === ts.JsxEmit.ReactJSXDev ? 'jsx-dev-runtime' : 'jsx-runtime'}`;
|
|
14
|
+
const target = compiled.runtimeModuleTargetOf(specifier, containingFile, 'import');
|
|
15
|
+
return target === null ? null : compiled.sourceFileOf(target);
|
|
16
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DeclarationId, SemanticResultId, StructuralTypeId } from '../../identity/ids.js';
|
|
2
|
+
/** Target-neutral transport of a closed source native iteration proof.
|
|
3
|
+
* Factory templates remain in installed host metadata, never in semantics.
|
|
4
|
+
*/
|
|
5
|
+
export interface NativeIterableReceipt {
|
|
6
|
+
readonly protocol: 'host-sync-iterable@1';
|
|
7
|
+
readonly receiverNative: string;
|
|
8
|
+
readonly method: DeclarationId;
|
|
9
|
+
readonly source: SemanticResultId;
|
|
10
|
+
readonly iterator: StructuralTypeId;
|
|
11
|
+
readonly element: StructuralTypeId;
|
|
12
|
+
readonly returnMethod: 'absent';
|
|
13
|
+
}
|
|
14
|
+
export declare const nativeIterableReceiptsEqual: (left: NativeIterableReceipt, right: NativeIterableReceipt) => boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const nativeIterableReceiptsEqual = (left, right) => left.protocol === right.protocol &&
|
|
2
|
+
left.receiverNative === right.receiverNative &&
|
|
3
|
+
left.method === right.method &&
|
|
4
|
+
left.source === right.source &&
|
|
5
|
+
left.iterator === right.iterator &&
|
|
6
|
+
left.element === right.element &&
|
|
7
|
+
left.returnMethod === right.returnMethod;
|
|
@@ -134,6 +134,36 @@ export interface SemanticOperand {
|
|
|
134
134
|
* ordinary store into a collection slot may not.
|
|
135
135
|
*/
|
|
136
136
|
readonly nativeBaseView?: true;
|
|
137
|
+
/**
|
|
138
|
+
* A `return`'s value that names a fresh local array no other reference can
|
|
139
|
+
* observe again (`unshared-array-result.ts`'s `unsharedReturnedArray`, the
|
|
140
|
+
* array kind of `fresh-table-last-use.ts`): a `const` local built from an
|
|
141
|
+
* array literal, filled and read in place, returned as its last use. Its
|
|
142
|
+
* elements may be moved ONCE into the slot's element carrier
|
|
143
|
+
* (`ConvertOperation.rebuild`'s `unshared-array`, releasing the source),
|
|
144
|
+
* which for an array another alias could reach would lose that alias's
|
|
145
|
+
* writes.
|
|
146
|
+
*/
|
|
147
|
+
readonly unsharedFreshArray?: true;
|
|
148
|
+
/**
|
|
149
|
+
* A call argument naming a local array the caller alone holds, bound to a
|
|
150
|
+
* formal the callee only READS (`unshared-array-result.ts`'s
|
|
151
|
+
* `readOnlyArrayArgumentAt`): the callee can neither write it, keep it nor
|
|
152
|
+
* compare it, and nothing else reaches it while the callee runs, so it
|
|
153
|
+
* cannot tell the caller's array from an element-wise copy. The argument
|
|
154
|
+
* may be rebuilt at the formal's element carrier, each element crossing by
|
|
155
|
+
* identity; the caller's array is left as it was.
|
|
156
|
+
*/
|
|
157
|
+
readonly readOnlyArrayArgument?: true;
|
|
158
|
+
/**
|
|
159
|
+
* A store's `value` operand that names a fresh open table no other
|
|
160
|
+
* reference can observe again (`fresh-table-last-use.ts`): a `const` local
|
|
161
|
+
* built from an object literal, filled through keyed writes, and stored
|
|
162
|
+
* here as its last use. Its entries may be copied ONCE into the slot's
|
|
163
|
+
* entry carrier (`ConvertOperation.rebuild`'s `unshared-dictionary`), which
|
|
164
|
+
* for a table another alias could reach would lose that alias's writes.
|
|
165
|
+
*/
|
|
166
|
+
readonly unsharedFreshTable?: true;
|
|
137
167
|
}
|
|
138
168
|
/** One result an operation publishes, keyed by the role it fills. */
|
|
139
169
|
export interface SemanticResult {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NativeIterableReceipt } from './native-iterable.js';
|
|
1
2
|
import type { DeclarationId, FunctionId, OperationId, RegionId, SemanticResultId, StructuralTypeId } from '../../identity/ids.js';
|
|
2
3
|
import type { SemanticOperationBase } from './operands.js';
|
|
3
4
|
import type { InvocationResultDivergence, SelectedSignature } from './selected-signature.js';
|
|
@@ -365,6 +366,14 @@ export interface InvocationOperation extends SemanticOperationBase {
|
|
|
365
366
|
* array, whose members these are.
|
|
366
367
|
*/
|
|
367
368
|
readonly freshIntrinsicArrayResult?: true;
|
|
369
|
+
/**
|
|
370
|
+
* The call is the intact intrinsic `Array.from(...)` or `Array.of(...)`,
|
|
371
|
+
* which answers an array it just created (ECMA-262 ArrayCreate) and holds
|
|
372
|
+
* no reference to: unshared exactly as `freshIntrinsicArrayResult`'s
|
|
373
|
+
* result is. `Array.from({ length }, () => [])` typed `never[][]` entering
|
|
374
|
+
* a `T[][]` binding is the case.
|
|
375
|
+
*/
|
|
376
|
+
readonly freshIntrinsicArrayFactory?: true;
|
|
368
377
|
/**
|
|
369
378
|
* An event emission no listener can observe, whose own result is unread
|
|
370
379
|
* (`normalize/dead-event-emissions.ts`): lowered to the `false` an emit
|
|
@@ -523,6 +532,8 @@ export interface AllocationOperation extends SemanticOperationBase {
|
|
|
523
532
|
readonly classDeclaration?: DeclarationId;
|
|
524
533
|
/** The class whose written constructor body this function allocation implements. */
|
|
525
534
|
readonly classConstructorBodyOf?: DeclarationId;
|
|
535
|
+
/** Definition retained, but no reachable evaluation constructs this class. */
|
|
536
|
+
readonly classConstructionDeferred?: boolean;
|
|
526
537
|
}
|
|
527
538
|
/** The one role target an operation published, if this producer owns one. */
|
|
528
539
|
export declare const conversionRoleTargetOf: (operation: SemanticOperationBase, role: string, ordinal: number, owner: ConversionRoleTarget["owner"]) => ConversionRoleTarget | undefined;
|
|
@@ -563,6 +574,8 @@ export interface ClassLifecycleOperation extends SemanticOperationBase {
|
|
|
563
574
|
readonly syntheticSubclassMemberOverlay?: boolean;
|
|
564
575
|
/** A layout demand, not evaluation or allocation of this class's constructor. */
|
|
565
576
|
readonly classLayoutOnly?: boolean;
|
|
577
|
+
/** Definition effects remain; constructor/instance initializer execution is absent. */
|
|
578
|
+
readonly classConstructionDeferred?: boolean;
|
|
566
579
|
}
|
|
567
580
|
/** A property descriptor as the language defines it. */
|
|
568
581
|
export interface PropertyDescriptorShape {
|
|
@@ -622,6 +635,8 @@ export interface ControlOperation extends SemanticOperationBase {
|
|
|
622
635
|
* needs both: the source to walk and the receiver to write into.
|
|
623
636
|
*/
|
|
624
637
|
export interface ProtocolOperation extends SemanticOperationBase {
|
|
638
|
+
/** Present only with independently retained source iteration authority. */
|
|
639
|
+
readonly nativeIterable?: NativeIterableReceipt;
|
|
625
640
|
readonly family: 'protocol';
|
|
626
641
|
readonly protocol: 'iterator' | 'async-iterator' | 'spread' | 'enumerate' | 'dispose' | 'async-dispose';
|
|
627
642
|
readonly step: 'get-method' | 'get-iterator' | 'next' | 'close' | 'return' | 'throw';
|
|
@@ -24,3 +24,18 @@ export declare const primitiveDomainOf: (shape: StructuralShape | null | undefin
|
|
|
24
24
|
* caller with a field of unknown shape needs only this.
|
|
25
25
|
*/
|
|
26
26
|
export declare const sharedPrimitiveDomainOf: (shapeOf: (id: StructuralTypeId) => StructuralShape | null | undefined, shape: StructuralShape | null | undefined) => string | null;
|
|
27
|
+
/**
|
|
28
|
+
* The one domain a set of member domains joins to, or `null` when they join to
|
|
29
|
+
* none.
|
|
30
|
+
*
|
|
31
|
+
* One domain is itself. Several join only when every one is a Number: `int`
|
|
32
|
+
* and `i32` are Numbers the program opted into holding as machine integers
|
|
33
|
+
* (`declared-integers.ts`), so `0 | int` -- what TypeScript infers for a
|
|
34
|
+
* callback returning `0` on one path and an `int` on another -- names Number
|
|
35
|
+
* values of one carrier, not a sum. A sum of `double` and `int64_t` arms has
|
|
36
|
+
* no runtime test that could tell its arms apart, and the emitter has no `+`
|
|
37
|
+
* over it. Every member a declared integer joins to the widest of them; any
|
|
38
|
+
* other Number member (`number`, a literal) joins to `number`, the carrier
|
|
39
|
+
* that holds every value of each.
|
|
40
|
+
*/
|
|
41
|
+
export declare const joinedPrimitiveDomainOf: (domains: ReadonlySet<string | null>) => string | null;
|