@geastack/compiler 1.0.48 → 1.0.62
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 +57 -19
- package/dist/cli.js +2 -1
- package/dist/compiler.d.ts +1 -1
- package/dist/compiler.js +13 -6
- package/dist/conversion/derive.js +5 -0
- package/dist/conversion/native-field-view.d.ts +7 -0
- package/dist/conversion/native-field-view.js +50 -0
- package/dist/conversion/native-record-products.js +1 -0
- package/dist/conversion/native-view-origins.d.ts +1 -1
- package/dist/conversion/native-view-origins.js +5 -4
- package/dist/conversion/nodes.d.ts +9 -0
- package/dist/conversion/nodes.js +18 -0
- package/dist/conversion/record-view.d.ts +25 -1
- package/dist/conversion/record-view.js +61 -2
- package/dist/conversion/structural-plan.js +7 -6
- package/dist/ir/borrowed-field-reads.d.ts +30 -0
- package/dist/ir/borrowed-field-reads.js +218 -0
- package/dist/ir/borrowed-window-cells.d.ts +35 -0
- package/dist/ir/borrowed-window-cells.js +117 -0
- package/dist/ir/call-dispatch.js +21 -4
- package/dist/ir/callable-class-flow.js +269 -43
- package/dist/ir/captures.js +18 -1
- package/dist/ir/certify.js +14 -1
- package/dist/ir/construction-only-fields.d.ts +15 -1
- package/dist/ir/construction-only-fields.js +71 -3
- package/dist/ir/dead-logical-merge.d.ts +4 -0
- package/dist/ir/dead-logical-merge.js +89 -18
- package/dist/ir/dense-loops.d.ts +38 -4
- package/dist/ir/dense-loops.js +112 -17
- package/dist/ir/dense-read-windows.d.ts +42 -0
- package/dist/ir/dense-read-windows.js +137 -0
- package/dist/ir/facts.d.ts +12 -0
- package/dist/ir/facts.js +18 -2
- package/dist/ir/field-read-reuse.d.ts +71 -0
- package/dist/ir/field-read-reuse.js +430 -0
- package/dist/ir/hoist.d.ts +19 -2
- package/dist/ir/hoist.js +143 -24
- package/dist/ir/lower-narrow.js +19 -1
- package/dist/ir/model.d.ts +19 -0
- package/dist/ir/native-field-view-domains.d.ts +12 -2
- package/dist/ir/native-field-view-domains.js +51 -15
- package/dist/ir/native-field-view-facts.js +5 -2
- package/dist/ir/native-method-frames.js +15 -2
- package/dist/ir/plain-field-read.d.ts +31 -0
- package/dist/ir/plain-field-read.js +51 -0
- package/dist/ir/program-facts.d.ts +14 -0
- package/dist/ir/program-facts.js +85 -2
- package/dist/ir/proven-branches.js +8 -1
- package/dist/ir/publish-conversion-recipes.js +5 -1
- package/dist/ir/short-circuit-threading.d.ts +12 -4
- package/dist/ir/short-circuit-threading.js +124 -12
- package/dist/ir/stable-cell-reads.d.ts +24 -1
- package/dist/ir/stable-cell-reads.js +65 -42
- package/dist/ir/write-effects.d.ts +42 -0
- package/dist/ir/write-effects.js +208 -0
- package/dist/plugins/gea/contract.d.ts +3 -2
- package/dist/plugins/gea/contract.js +3 -1
- package/dist/plugins/gea/host.d.ts +7 -2
- package/dist/plugins/gea/host.js +25 -5
- package/dist/project-preparation.d.ts +11 -0
- package/dist/project-preparation.js +44 -0
- package/dist/projection/classes.d.ts +8 -0
- package/dist/projection/classes.js +112 -12
- package/dist/projection/dispatch.d.ts +24 -4
- package/dist/projection/dispatch.js +71 -2
- package/dist/projection/fields.js +2 -2
- package/dist/representation/model.d.ts +3 -0
- package/dist/representation/model.js +3 -0
- package/dist/representation/value-records.js +22 -0
- package/dist/semantics/frontend-timing.d.ts +9 -0
- package/dist/semantics/frontend-timing.js +43 -2
- package/dist/semantics/frontend.js +103 -7
- package/dist/semantics/model/operations.d.ts +7 -0
- package/dist/semantics/normalize/binding-fixpoint.js +7 -2
- package/dist/semantics/normalize/callable-data-write.js +6 -2
- package/dist/semantics/normalize/field-bindings.js +151 -111
- package/dist/semantics/normalize/flow/callable-reach.js +27 -0
- package/dist/semantics/normalize/flow/component-solver.js +23 -5
- package/dist/semantics/normalize/flow/source-record-data.js +6 -2
- package/dist/semantics/normalize/flow/source-value-session.d.ts +13 -0
- package/dist/semantics/normalize/flow/source-value-session.js +207 -65
- package/dist/semantics/normalize/global-host-mutations.js +162 -1
- package/dist/semantics/normalize/parameter-bindings.js +16 -1
- package/dist/semantics/normalize/producers/class-lifecycle.js +2 -1
- package/dist/semantics/normalize/producers/erasure.js +13 -8
- package/dist/semantics/subclass-member-overlay-transform.d.ts +3 -2
- package/dist/semantics/subclass-member-overlay-transform.js +416 -316
- package/dist/semantics/typescript-tsgo.d.ts +20 -0
- package/dist/semantics/typescript-tsgo.js +832 -0
- package/dist/semantics/typescript.d.ts +0 -9
- package/dist/semantics/typescript.js +4 -1
- package/dist/targets/cpp/borrowed-call-entry.d.ts +9 -0
- package/dist/targets/cpp/borrowed-call-entry.js +12 -2
- package/dist/targets/cpp/captures.js +4 -0
- package/dist/targets/cpp/class-properties/computed-method-value.d.ts +1 -1
- package/dist/targets/cpp/class-properties/computed-method-value.js +17 -7
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +8 -0
- package/dist/targets/cpp/class-properties/emit-class-properties.js +62 -2
- package/dist/targets/cpp/class-properties/native-method-read.js +12 -1
- package/dist/targets/cpp/conversions.js +1 -0
- package/dist/targets/cpp/emit-arrays.d.ts +5 -0
- package/dist/targets/cpp/emit-arrays.js +60 -10
- package/dist/targets/cpp/emit-binding-reference.d.ts +19 -6
- package/dist/targets/cpp/emit-binding-reference.js +26 -8
- package/dist/targets/cpp/emit-bindings.js +22 -0
- package/dist/targets/cpp/emit-callable.js +133 -16
- package/dist/targets/cpp/emit-carrier-members.d.ts +6 -0
- package/dist/targets/cpp/emit-carrier-members.js +24 -2
- package/dist/targets/cpp/emit-context.d.ts +97 -1
- package/dist/targets/cpp/emit-context.js +52 -0
- package/dist/targets/cpp/emit-equality.js +3 -0
- package/dist/targets/cpp/emit-narrowing.js +9 -0
- package/dist/targets/cpp/emit-native-field-view.d.ts +24 -0
- package/dist/targets/cpp/emit-native-field-view.js +87 -8
- package/dist/targets/cpp/emit-properties.js +139 -16
- package/dist/targets/cpp/emit-record-view.js +49 -22
- package/dist/targets/cpp/emit-return.js +5 -1
- package/dist/targets/cpp/emit-tonumber.js +4 -1
- package/dist/targets/cpp/emit-union-properties.js +1 -1
- package/dist/targets/cpp/emit.d.ts +4 -1
- package/dist/targets/cpp/emit.js +148 -6
- package/dist/targets/cpp/reactive-dependencies.js +100 -28
- package/dist/targets/cpp/translation-unit.js +71 -17
- package/dist/targets/cpp/virtual-methods.d.ts +2 -2
- package/dist/targets/cpp/virtual-methods.js +11 -3
- package/package.json +1 -1
- package/src/targets/cpp/runtime/gea_runtime.h +400 -21
|
@@ -47,6 +47,9 @@ import { cppAbiParameterType, cppAbiType, cppStringLiteral, cppBodyName, cppCall
|
|
|
47
47
|
import { buildHostMethodAliasIndex } from './host/host-method-aliases.js';
|
|
48
48
|
import { constructionOnlyFieldsOf, reflectiveFieldWritesOf } from '../../ir/construction-only-fields.js';
|
|
49
49
|
import { cppRecursiveContainerDeclarations, cppRecursiveContainerTraceEdges } from './recursive-containers.js';
|
|
50
|
+
import { plainFieldReadOf } from '../../ir/plain-field-read.js';
|
|
51
|
+
import { codeFreeFieldReadOf } from '../../ir/field-read-reuse.js';
|
|
52
|
+
import { writeEffectsOf } from '../../ir/write-effects.js';
|
|
50
53
|
/**
|
|
51
54
|
* One C++ translation unit, assembled from what earlier stages sealed.
|
|
52
55
|
*
|
|
@@ -369,6 +372,44 @@ const coroutineEnvironmentPrologueOf = (body, captures) => body.abi && captures.
|
|
|
369
372
|
* behaviour, which is exactly why no gate above this one could have caught it.
|
|
370
373
|
*/
|
|
371
374
|
const borrowsReceiver = (body) => body.abi?.receiver != null && cppRefcountedReceiver(body.abi.receiver) && !isCoroutineBody(body);
|
|
375
|
+
/**
|
|
376
|
+
* Whether every return of this method hands back the receiver it was called
|
|
377
|
+
* on, so each of its entries returns the caller's own handle by reference.
|
|
378
|
+
*
|
|
379
|
+
* `v.set(x, y, z).add(w)` chains three's vector methods, and each returned
|
|
380
|
+
* `this` by value: a retain inside the callee and a release in the caller for
|
|
381
|
+
* a result that is the caller's own receiver, discarded or immediately called
|
|
382
|
+
* on. The receiver formal is a `const&` bound to an object the caller keeps
|
|
383
|
+
* alive past the call (`borrowsReceiver`), so a reference to it is valid for
|
|
384
|
+
* the caller's whole full-expression; a caller that keeps the result copies it
|
|
385
|
+
* as before, and a thunk returns by value.
|
|
386
|
+
*
|
|
387
|
+
* Constructible bodies are excluded (a constructor completes with its
|
|
388
|
+
* receiver too, through its own protocol), and so is a body with a try
|
|
389
|
+
* statement, whose returned value a finally clause may still read.
|
|
390
|
+
*/
|
|
391
|
+
const returnsOwnReceiver = (body) => {
|
|
392
|
+
const abi = body.abi;
|
|
393
|
+
if (abi === null || abi.receiver === null || body.construct !== null || body.tryRegions.length > 0 || !borrowsReceiver(body))
|
|
394
|
+
return false;
|
|
395
|
+
if (representationKey(abi.result) !== representationKey(abi.receiver))
|
|
396
|
+
return false;
|
|
397
|
+
const receivers = new Set();
|
|
398
|
+
for (const block of body.blocks.values())
|
|
399
|
+
for (const operation of allOperationsOf(block))
|
|
400
|
+
if (operation.kind === 'receiver')
|
|
401
|
+
receivers.add(operation.result.id);
|
|
402
|
+
let returns = 0;
|
|
403
|
+
for (const block of body.blocks.values()) {
|
|
404
|
+
const terminator = block.terminator;
|
|
405
|
+
if (terminator.kind !== 'return')
|
|
406
|
+
continue;
|
|
407
|
+
if (terminator.value === null || terminator.value === undefined || !receivers.has(terminator.value.value))
|
|
408
|
+
return false;
|
|
409
|
+
returns += 1;
|
|
410
|
+
}
|
|
411
|
+
return returns > 0;
|
|
412
|
+
};
|
|
372
413
|
/**
|
|
373
414
|
* The struct one body's captured declarations share (`CaptureFrame`).
|
|
374
415
|
*
|
|
@@ -748,7 +789,9 @@ const signatureOf = (body, captures, narrowed = new Set(), narrowedResult = fals
|
|
|
748
789
|
? `gea::Task<${cppResultTypeOf(effectiveAbi.result.value)}>`
|
|
749
790
|
: narrowedResult
|
|
750
791
|
? cppNarrowedIntegerType
|
|
751
|
-
:
|
|
792
|
+
: returnsOwnReceiver(body)
|
|
793
|
+
? `const ${cppResultTypeOf(effectiveAbi.result)}&`
|
|
794
|
+
: cppResultTypeOf(effectiveAbi.result);
|
|
752
795
|
const formals = bodyFormalsOf(cppEnvironmentStructOf(captures, body.sourceOwner), effectiveAbi, admission, narrowed, borrowsReceiver(body), borrowed, isCoroutineBody(body));
|
|
753
796
|
return `${result} ${name}(${formals.join(', ')})`;
|
|
754
797
|
};
|
|
@@ -787,7 +830,7 @@ const thunkOf = (body, captures, narrowed, narrowedResult, linkage, taskResult =
|
|
|
787
830
|
// can name, so they are stable actuals for the borrowed entry: entering it
|
|
788
831
|
// directly binds them in place, where the owning entry moved each one into a
|
|
789
832
|
// formal of its own and released the emptied shell on the way out.
|
|
790
|
-
const borrowedEntry = stableEntry !== undefined && !hasEnvironment && !isCoroutineBody(body) ? stableEntry : undefined;
|
|
833
|
+
const borrowedEntry = stableEntry !== undefined && (!hasEnvironment || stableEntry.environment) && !isCoroutineBody(body) ? stableEntry : undefined;
|
|
791
834
|
const call = `${borrowedEntry?.name ?? cppBodyName(body.sourceOwner)}(${[
|
|
792
835
|
...(hasEnvironment ? [isCoroutineBody(body) ? `*${cppEnvironmentLocalName}` : cppEnvironmentLocalName] : []),
|
|
793
836
|
...receiverActual,
|
|
@@ -1416,7 +1459,9 @@ const renderTranslationUnitSession = (input) => {
|
|
|
1416
1459
|
for (const [declaration, layout] of input.classes)
|
|
1417
1460
|
if (layout.constructor !== null && !unsafeForStoreSink.has(declaration))
|
|
1418
1461
|
storeSinkConstructors.add(String(layout.constructor));
|
|
1419
|
-
const
|
|
1462
|
+
const plainFieldRead = plainFieldReadOf(input.classes, input.deriver);
|
|
1463
|
+
const codeFreeFieldRead = codeFreeFieldReadOf(input.bodies, input.classes, input.deriver);
|
|
1464
|
+
const { callableMemberCandidates, callableFlowCandidates, repeatedConstructors, dyingArguments, formalsBorrowedIn, bodyCallsUnsafeKnownCallee, callableIdentityDemand, nativeIntegrityRestricted, fixedFieldStateConstant, singleEvaluationClasses, definitionCells, allocationCells } = programFactsOf(input.bodies, directCallables, input.placements, {
|
|
1420
1465
|
captureFree: (functionId) => captures.of(functionId).kind === 'none',
|
|
1421
1466
|
isBoxed: (declaration) => captures.isBoxed(declaration),
|
|
1422
1467
|
isCoroutineBody,
|
|
@@ -1424,18 +1469,7 @@ const renderTranslationUnitSession = (input) => {
|
|
|
1424
1469
|
isStoreSinkConstructor: (body) => storeSinkConstructors.has(String(body.sourceOwner)),
|
|
1425
1470
|
classInstanceOf: (declaration) => input.classes.get(declaration)?.instance ?? null,
|
|
1426
1471
|
shapeLayoutOf: (shapeId) => input.deriver.layoutOf(shapeId),
|
|
1427
|
-
plainFieldRead
|
|
1428
|
-
if (receiver.kind === 'class-ref') {
|
|
1429
|
-
// A class over a host base reads its members through the host's
|
|
1430
|
-
// protocol; only a wholly projected class has plain member loads.
|
|
1431
|
-
if (input.classes.get(receiver.declaration)?.nativeBase !== null)
|
|
1432
|
-
return false;
|
|
1433
|
-
return classMemberOf(input.classes, receiver.declaration, key)?.kind === 'field';
|
|
1434
|
-
}
|
|
1435
|
-
if (receiver.kind === 'record')
|
|
1436
|
-
return receiver.fields.some((field) => field.key === key) && !receiver.accessors.some((accessor) => accessor.key === key);
|
|
1437
|
-
return false;
|
|
1438
|
-
},
|
|
1472
|
+
plainFieldRead,
|
|
1439
1473
|
isPrivateLocal: (body, declaration) => {
|
|
1440
1474
|
const placement = input.placements.get(declaration);
|
|
1441
1475
|
return (placement?.storage.kind === 'local' &&
|
|
@@ -1670,6 +1704,15 @@ const renderTranslationUnitSession = (input) => {
|
|
|
1670
1704
|
// class whose reflection demand can write a field -- a boxed instance's
|
|
1671
1705
|
// `obj[k] = v`, `Reflect.set`, `Object.assign` -- keeps that field's copy;
|
|
1672
1706
|
// a missing census writes every field of every class.
|
|
1707
|
+
// Field keys each body can store, through the bodies it calls (`ir/write-effects.ts`).
|
|
1708
|
+
const writeEffects = writeEffectsOf(input.bodies, plainFieldRead, (receiver, key) => {
|
|
1709
|
+
if (receiver.kind !== 'class-ref')
|
|
1710
|
+
return plainFieldRead(receiver, key);
|
|
1711
|
+
if (input.classes.get(receiver.declaration)?.nativeBase !== null)
|
|
1712
|
+
return false;
|
|
1713
|
+
const member = classMemberOf(input.classes, receiver.declaration, key)?.kind;
|
|
1714
|
+
return member === 'field' || member === 'method';
|
|
1715
|
+
});
|
|
1673
1716
|
const constructionOnlyFields = constructionOnlyFieldsOf(input.bodies, classConstructions, input.reflection === undefined || input.reflection === null
|
|
1674
1717
|
? [...input.classes.keys()].map((declaration) => [declaration, 'all'])
|
|
1675
1718
|
: [...input.reflection.classes].map(([declaration, demand]) => [declaration, reflectiveFieldWritesOf(demand)]));
|
|
@@ -1945,6 +1988,15 @@ const renderTranslationUnitSession = (input) => {
|
|
|
1945
1988
|
const physicalCounts = new Map();
|
|
1946
1989
|
for (const body of input.bodies)
|
|
1947
1990
|
physicalCounts.set(String(body.sourceOwner), (physicalCounts.get(String(body.sourceOwner)) ?? 0) + 1);
|
|
1991
|
+
// A closure's environment is a plain pointer its thunk unpacks before entering
|
|
1992
|
+
// the body, so its borrowed entry can take that pointer first the way the
|
|
1993
|
+
// owning entry does. A captured receiver is forwarded out of the environment
|
|
1994
|
+
// and an accessor's environment is unpacked differently; both keep their
|
|
1995
|
+
// owning entry only.
|
|
1996
|
+
const closesOverPlainEnvironment = (owner) => {
|
|
1997
|
+
const admission = captures.of(owner);
|
|
1998
|
+
return admission.kind === 'ok' && admission.layout.receiver === null && !captures.isAccessorEnvironment(owner);
|
|
1999
|
+
};
|
|
1948
2000
|
const stableEntryOf = (body, dying) => isRegionId(body.sourceOwner) || constructorBodies.has(String(body.sourceOwner))
|
|
1949
2001
|
? null
|
|
1950
2002
|
: stableBorrowEntryOf(body, body.sourceOwner, (declaration) => {
|
|
@@ -1953,7 +2005,8 @@ const renderTranslationUnitSession = (input) => {
|
|
|
1953
2005
|
? placement.representation
|
|
1954
2006
|
: null;
|
|
1955
2007
|
}, formalsBorrowedIn(body.sourceOwner), dying, {
|
|
1956
|
-
captureFree: captures.of(body.sourceOwner).kind === 'none',
|
|
2008
|
+
captureFree: captures.of(body.sourceOwner).kind === 'none' || closesOverPlainEnvironment(body.sourceOwner),
|
|
2009
|
+
environment: closesOverPlainEnvironment(body.sourceOwner),
|
|
1957
2010
|
synchronous: !isCoroutineBody(body),
|
|
1958
2011
|
singleBody: physicalCounts.get(String(body.sourceOwner)) === 1,
|
|
1959
2012
|
narrowedNumericAbi: formalsNarrowedIn(body.sourceOwner).size > 0 || resultNarrowedIn(body.sourceOwner)
|
|
@@ -2109,7 +2162,7 @@ const renderTranslationUnitSession = (input) => {
|
|
|
2109
2162
|
// The formals this body's signature takes by reference: their objects
|
|
2110
2163
|
// outlive the call, which `emit.ts`'s stable field reads rely on.
|
|
2111
2164
|
const borrowed = stableEntry?.formals ?? formalsBorrowedIn(body.sourceOwner);
|
|
2112
|
-
const sections = emitBody(promiseView ?? body, input.placements, input.classes, hosts, deriver, input.wellKnownSymbols, captures, symbolKeys, templateObjects, directCallables, virtuals.dispatched, narrowedStorage.factsOf(body.sourceOwner), formalsNarrowedIn(body.sourceOwner), repeatedConstructors, borrowDying, instantiation, (callable) => abiByBody.get(String(callable)) ?? null, functionFacts, constructEntries, hostMethodAliases, callableMemberCandidates, callableFlowCandidates.get(body.owner) ?? new Map(), borrowableMemberBodies, stableBorrowEntries, printerDrift, input.conversions, selectionHelpers, callableIdentityDemand, nativeIntegrityRestricted, fixedFieldStateConstant, definitionCells, constructionOnlyFields, keyOrderUnobserved, debugSource, borrowed, asyncResults.taskResults, programSite.conversionIsCertified, input.programConversionRecipes, structs.classIndexProtocols);
|
|
2165
|
+
const sections = emitBody(promiseView ?? body, input.placements, input.classes, hosts, deriver, input.wellKnownSymbols, captures, symbolKeys, templateObjects, directCallables, virtuals.dispatched, narrowedStorage.factsOf(body.sourceOwner), formalsNarrowedIn(body.sourceOwner), repeatedConstructors, borrowDying, instantiation, (callable) => abiByBody.get(String(callable)) ?? null, functionFacts, constructEntries, hostMethodAliases, callableMemberCandidates, callableFlowCandidates.get(body.owner) ?? new Map(), borrowableMemberBodies, stableBorrowEntries, printerDrift, input.conversions, selectionHelpers, callableIdentityDemand, nativeIntegrityRestricted, fixedFieldStateConstant, definitionCells, constructionOnlyFields, keyOrderUnobserved, debugSource, borrowed, asyncResults.taskResults, programSite.conversionIsCertified, input.programConversionRecipes, structs.classIndexProtocols, writeEffects, promiseView === null && returnsOwnReceiver(body), allocationCells, codeFreeFieldRead);
|
|
2113
2166
|
const commonJsScope = [
|
|
2114
2167
|
...coroutineEnvironmentPrologueOf(promiseView ?? body, captures),
|
|
2115
2168
|
...(commonJsOwner === null || commonJsOwner.nativeRecord
|
|
@@ -2145,6 +2198,7 @@ const renderTranslationUnitSession = (input) => {
|
|
|
2145
2198
|
// it forwards unchanged: never moved (the receiver formal
|
|
2146
2199
|
// above is never in `narrowed`/moved sets) and never boxed.
|
|
2147
2200
|
`return ${stableEntry.name}(${[
|
|
2201
|
+
...(stableEntry.environment ? [cppEnvironmentLocalName] : []),
|
|
2148
2202
|
...(stableEntry.abi.receiver !== null ? [cppReceiverName] : []),
|
|
2149
2203
|
...stableEntry.abi.parameters.map((_, ordinal) => stableEntry.formals.has(ordinal) ? cppFormalName(ordinal) : `std::move(${cppFormalName(ordinal)})`)
|
|
2150
2204
|
].join(', ')});`),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DeclarationId, FunctionId } from '../../identity/ids.js';
|
|
2
2
|
import { type CallableAbi } from '../../representation/model.js';
|
|
3
3
|
import type { ClassLayout } from '../../projection/classes.js';
|
|
4
|
-
import { extendsClass, virtualDispatchKey, virtualMethodFamiliesOf, type VirtualDispatchVerdict, type VirtualFamilyRefusal, type VirtualFamilyVerdict, type VirtualMemberRole, type VirtualMethodFamily, type VirtualMethodImplementor } from '../../projection/dispatch.js';
|
|
5
|
-
export { extendsClass, virtualDispatchKey, virtualMethodFamiliesOf, type VirtualDispatchVerdict, type VirtualFamilyRefusal, type VirtualFamilyVerdict, type VirtualMemberRole, type VirtualMethodFamily, type VirtualMethodImplementor };
|
|
4
|
+
import { extendsClass, virtualDispatchKey, classAbstractMemberMissesAt, virtualMethodFamiliesOf, type VirtualDispatchVerdict, type VirtualFamilyRefusal, type VirtualFamilyVerdict, type VirtualMemberRole, type VirtualMethodFamily, type VirtualMethodImplementor } from '../../projection/dispatch.js';
|
|
5
|
+
export { extendsClass, virtualDispatchKey, classAbstractMemberMissesAt, virtualMethodFamiliesOf, type VirtualDispatchVerdict, type VirtualFamilyRefusal, type VirtualFamilyVerdict, type VirtualMemberRole, type VirtualMethodFamily, type VirtualMethodImplementor };
|
|
6
6
|
import { type ConversionSite } from './emit-narrowing.js';
|
|
7
7
|
/**
|
|
8
8
|
* Dispatch for a method the program overrides.
|
|
@@ -2,8 +2,8 @@ import { representationKey } from '../../representation/model.js';
|
|
|
2
2
|
import { nativeClassReferenceTransportMatches } from '../../conversion/native-class-reference.js';
|
|
3
3
|
import { isNativeCallableCarrier } from '../../representation/callable-object.js';
|
|
4
4
|
import { prototypeSetterValue, virtualConversionOwnerOf } from '../../ir/program-conversions.js';
|
|
5
|
-
import { extendsClass, virtualDispatchKey, virtualMethodFamiliesOf } from '../../projection/dispatch.js';
|
|
6
|
-
export { extendsClass, virtualDispatchKey, virtualMethodFamiliesOf };
|
|
5
|
+
import { extendsClass, virtualDispatchKey, classAbstractMemberMissesAt, virtualMethodFamiliesOf } from '../../projection/dispatch.js';
|
|
6
|
+
export { extendsClass, virtualDispatchKey, classAbstractMemberMissesAt, virtualMethodFamiliesOf };
|
|
7
7
|
import { cppFormalName } from './emit-context.js';
|
|
8
8
|
import { nativeFieldPolicyType, switchedByKeyLength, wellKnownSymbolEnumNameOf } from './records.js';
|
|
9
9
|
import { cppAbiParameterType, cppBodyName, cppCallableDeclarationTagName, cppClassName, cppRecordFieldKeyIsSymbol, cppRecordFieldName, cppResultTypeOf, cppStringLiteral, cppTypeOf, cppUndefinedIn } from './types.js';
|
|
@@ -149,7 +149,15 @@ export const virtualMethodEmission = (site, classes, abiOf, verdict, reparentTar
|
|
|
149
149
|
// already proves every concrete subclass overrides this, so the
|
|
150
150
|
// definition is unreachable and says so instead of returning a value it
|
|
151
151
|
// would have to invent.
|
|
152
|
-
|
|
152
|
+
// A method, though, can be reached: an abstract constructor runs at run
|
|
153
|
+
// time, and an observer holding an instance can recover it from the
|
|
154
|
+
// prototype chain (`class-allocation-domain.ts`). Such an instance has
|
|
155
|
+
// no own or inherited member under the key, so the call is JavaScript's
|
|
156
|
+
// call of `undefined`. A root that does have a body, only not at this
|
|
157
|
+
// convention copy, is no such miss and stays unreachable.
|
|
158
|
+
const failure = family.role === 'call' && classAbstractMemberMissesAt(classes, family.root, family.key)
|
|
159
|
+
? `gea::host::throwRuntimeError("TypeError", "${family.key} is not a function");`
|
|
160
|
+
: `std::fprintf(stderr, "gea: abstract method ${String(family.root)}.${family.key} has no implementation\\n"); std::abort();`;
|
|
153
161
|
membersByStruct.set(cppClassName(family.root), [
|
|
154
162
|
...(membersByStruct.get(cppClassName(family.root)) ?? []),
|
|
155
163
|
` virtual ${result} ${cppVirtualMemberName(family.key, family.role, family.copy)}(${formals});`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/compiler",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.62",
|
|
4
4
|
"description": "The geastack TypeScript-to-C++ compiler: one semantic spine, no source-shaped authority, no boxing of statically typed values.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|