@geastack/compiler 1.0.33 → 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.
Files changed (215) hide show
  1. package/README.md +1 -1
  2. package/dist/cli-coverage.js +2 -4
  3. package/dist/cli-emit.js +1 -1
  4. package/dist/cli-module-graph.js +1 -1
  5. package/dist/cli.js +2 -1
  6. package/dist/compiler.js +14 -6
  7. package/dist/conversion/array-view.js +9 -0
  8. package/dist/conversion/build.js +15 -8
  9. package/dist/conversion/dictionary-view.js +2 -2
  10. package/dist/conversion/nodes.d.ts +7 -0
  11. package/dist/conversion/nodes.js +58 -11
  12. package/dist/identity/ids.d.ts +4 -0
  13. package/dist/identity/ids.js +4 -0
  14. package/dist/ir/build.d.ts +4 -3
  15. package/dist/ir/build.js +14 -5
  16. package/dist/ir/call-dispatch.js +67 -7
  17. package/dist/ir/call-entry.js +1 -1
  18. package/dist/ir/callable-class-flow.d.ts +4 -0
  19. package/dist/ir/callable-class-flow.js +123 -1
  20. package/dist/ir/certify/parallel-region.js +698 -20
  21. package/dist/ir/certify.d.ts +3 -0
  22. package/dist/ir/certify.js +44 -9
  23. package/dist/ir/class-allocation-domain.js +2 -2
  24. package/dist/ir/class-construction-status.d.ts +10 -0
  25. package/dist/ir/class-construction-status.js +36 -0
  26. package/dist/ir/convert-carriers.d.ts +10 -1
  27. package/dist/ir/convert-carriers.js +18 -1
  28. package/dist/ir/dynamic-constructor-conversions.js +4 -2
  29. package/dist/ir/finite-iterator-close.d.ts +14 -0
  30. package/dist/ir/finite-iterator-close.js +50 -0
  31. package/dist/ir/host-template-conversions.js +9 -0
  32. package/dist/ir/lower-allocation.js +1 -1
  33. package/dist/ir/lower-flow.js +24 -3
  34. package/dist/ir/lower-operands.js +88 -7
  35. package/dist/ir/lower-protocol.js +1 -1
  36. package/dist/ir/lower.js +9 -4
  37. package/dist/ir/model.d.ts +39 -1
  38. package/dist/ir/native-accessor-definition.d.ts +3 -2
  39. package/dist/ir/native-accessor-definition.js +29 -10
  40. package/dist/ir/native-array-transport.js +2 -2
  41. package/dist/ir/native-field-view-domains.d.ts +23 -0
  42. package/dist/ir/native-field-view-domains.js +115 -9
  43. package/dist/ir/native-field-view-facts.d.ts +46 -2
  44. package/dist/ir/native-field-view-facts.js +159 -4
  45. package/dist/ir/native-iterable.d.ts +17 -0
  46. package/dist/ir/native-iterable.js +72 -0
  47. package/dist/ir/native-key-query.js +1 -1
  48. package/dist/ir/operation-conversions.js +15 -3
  49. package/dist/ir/program-conversions.js +2 -2
  50. package/dist/ir/publish-native-field-view-facts.js +9 -4
  51. package/dist/ir/pure-conversion-reuse.d.ts +58 -0
  52. package/dist/ir/pure-conversion-reuse.js +263 -0
  53. package/dist/ir/queries.js +1 -0
  54. package/dist/ir/reflection-demand.js +70 -18
  55. package/dist/ir/shake.js +2 -2
  56. package/dist/ir/unobserved-callable-inputs.d.ts +37 -0
  57. package/dist/ir/unobserved-callable-inputs.js +111 -0
  58. package/dist/native-signatures.d.ts +1 -1
  59. package/dist/native-signatures.js +27 -2
  60. package/dist/plugins/gea/component-classes.d.ts +2 -1
  61. package/dist/plugins/gea/component-classes.js +3 -3
  62. package/dist/plugins/gea/contract.d.ts +26 -3
  63. package/dist/plugins/gea/contract.js +42 -43
  64. package/dist/plugins/gea/host.d.ts +9 -0
  65. package/dist/plugins/gea/host.js +25 -4
  66. package/dist/plugins/gea/plugin.js +12 -6
  67. package/dist/plugins/gea/producer.d.ts +2 -2
  68. package/dist/plugins/gea/producer.js +2 -2
  69. package/dist/plugins/load.js +18 -1
  70. package/dist/plugins/model.d.ts +5 -0
  71. package/dist/plugins/native-iterable-providers.d.ts +18 -0
  72. package/dist/plugins/native-iterable-providers.js +51 -0
  73. package/dist/project-preparation.d.ts +8 -0
  74. package/dist/project-preparation.js +49 -7
  75. package/dist/projection/bindings.d.ts +13 -0
  76. package/dist/projection/bindings.js +20 -1
  77. package/dist/projection/classes.d.ts +4 -2
  78. package/dist/projection/classes.js +12 -5
  79. package/dist/representation/collections.js +2 -0
  80. package/dist/representation/derive.js +1 -0
  81. package/dist/representation/model.d.ts +2 -0
  82. package/dist/representation/model.js +1 -0
  83. package/dist/representation/policies.d.ts +2 -0
  84. package/dist/representation/primitive-domain.d.ts +1 -1
  85. package/dist/representation/primitive-domain.js +1 -1
  86. package/dist/representation/unassigned-binding-cells.js +6 -1
  87. package/dist/representation/union.js +6 -6
  88. package/dist/semantics/frontend.d.ts +2 -0
  89. package/dist/semantics/frontend.js +34 -5
  90. package/dist/semantics/host-methods.js +4 -1
  91. package/dist/semantics/jsx-runtime-provider.d.ts +5 -0
  92. package/dist/semantics/jsx-runtime-provider.js +16 -0
  93. package/dist/semantics/model/native-iterable.d.ts +14 -0
  94. package/dist/semantics/model/native-iterable.js +7 -0
  95. package/dist/semantics/model/operands.d.ts +30 -0
  96. package/dist/semantics/model/operations.d.ts +15 -0
  97. package/dist/semantics/model/primitive-domain.d.ts +15 -0
  98. package/dist/semantics/model/primitive-domain.js +27 -4
  99. package/dist/semantics/module-resolution.js +13 -2
  100. package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
  101. package/dist/semantics/normalize/callback-parameter-contracts.d.ts +32 -4
  102. package/dist/semantics/normalize/callback-parameter-contracts.js +66 -6
  103. package/dist/semantics/normalize/census.d.ts +3 -0
  104. package/dist/semantics/normalize/census.js +17 -12
  105. package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +4 -1
  106. package/dist/semantics/normalize/deferred-intrinsic-protocols.js +29 -9
  107. package/dist/semantics/normalize/flow/callable-reach.js +94 -3
  108. package/dist/semantics/normalize/flow/component-solver.js +144 -55
  109. package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +9 -0
  110. package/dist/semantics/normalize/flow/member-call-forwarding.js +30 -4
  111. package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +2 -0
  112. package/dist/semantics/normalize/flow/proof-hypotheses.js +27 -0
  113. package/dist/semantics/normalize/flow/source-callable-own-data.js +87 -14
  114. package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +2 -0
  115. package/dist/semantics/normalize/flow/source-commonjs-exports.js +2 -0
  116. package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +17 -0
  117. package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +125 -0
  118. package/dist/semantics/normalize/flow/source-native-origin.d.ts +6 -0
  119. package/dist/semantics/normalize/flow/source-native-origin.js +38 -0
  120. package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +37 -0
  121. package/dist/semantics/normalize/flow/source-proxy-operation.js +201 -0
  122. package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +20 -0
  123. package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +73 -0
  124. package/dist/semantics/normalize/flow/source-value-session.d.ts +50 -1
  125. package/dist/semantics/normalize/flow/source-value-session.js +596 -57
  126. package/dist/semantics/normalize/flow/value-flow.d.ts +17 -0
  127. package/dist/semantics/normalize/flow/value-flow.js +84 -0
  128. package/dist/semantics/normalize/fresh-dictionary-storage.js +2 -2
  129. package/dist/semantics/normalize/fresh-table-last-use.d.ts +52 -0
  130. package/dist/semantics/normalize/fresh-table-last-use.js +129 -0
  131. package/dist/semantics/normalize/gating.js +5 -1
  132. package/dist/semantics/normalize/global-host-mutations.js +190 -13
  133. package/dist/semantics/normalize/identities.js +20 -1
  134. package/dist/semantics/normalize/local-bindings.js +2 -2
  135. package/dist/semantics/normalize/parameter-bindings.js +10 -1
  136. package/dist/semantics/normalize/producer-context.d.ts +5 -0
  137. package/dist/semantics/normalize/producers/binding-kind.js +2 -0
  138. package/dist/semantics/normalize/producers/cited-value-type.d.ts +2 -2
  139. package/dist/semantics/normalize/producers/cited-value-type.js +2 -2
  140. package/dist/semantics/normalize/producers/class-lifecycle.js +39 -9
  141. package/dist/semantics/normalize/producers/computations.js +36 -5
  142. package/dist/semantics/normalize/producers/conditional-guard.d.ts +6 -0
  143. package/dist/semantics/normalize/producers/conditional-guard.js +5 -0
  144. package/dist/semantics/normalize/producers/control.js +7 -1
  145. package/dist/semantics/normalize/producers/destructuring.js +8 -9
  146. package/dist/semantics/normalize/producers/invocations.js +55 -2
  147. package/dist/semantics/normalize/producers/properties.d.ts +13 -0
  148. package/dist/semantics/normalize/producers/properties.js +21 -3
  149. package/dist/semantics/normalize/producers/references.js +8 -4
  150. package/dist/semantics/normalize/reachability.d.ts +15 -3
  151. package/dist/semantics/normalize/reachability.js +128 -20
  152. package/dist/semantics/normalize/return-bindings.js +3 -3
  153. package/dist/semantics/normalize/source-native-iterable.d.ts +19 -0
  154. package/dist/semantics/normalize/source-native-iterable.js +74 -0
  155. package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
  156. package/dist/semantics/normalize/structural-declarations.js +1 -1
  157. package/dist/semantics/normalize/structural-indexed-access.js +9 -0
  158. package/dist/semantics/normalize/structural.js +11 -0
  159. package/dist/semantics/normalize/unshared-array-result.d.ts +42 -0
  160. package/dist/semantics/normalize/unshared-array-result.js +269 -0
  161. package/dist/semantics/package-sources.js +3 -2
  162. package/dist/semantics/program.d.ts +8 -0
  163. package/dist/semantics/program.js +55 -0
  164. package/dist/semantics/source-transform-exports.d.ts +8 -0
  165. package/dist/semantics/source-transform-exports.js +145 -0
  166. package/dist/semantics/source-transform-protocol.d.ts +22 -0
  167. package/dist/semantics/this-constructor-source-transform.js +19 -1
  168. package/dist/targets/cpp/class-layout.d.ts +2 -0
  169. package/dist/targets/cpp/class-layout.js +35 -1
  170. package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +11 -1
  171. package/dist/targets/cpp/class-properties/emit-class-properties.js +33 -4
  172. package/dist/targets/cpp/conversions.js +6 -3
  173. package/dist/targets/cpp/emit-callable.js +73 -7
  174. package/dist/targets/cpp/emit-context.d.ts +23 -9
  175. package/dist/targets/cpp/emit-context.js +19 -8
  176. package/dist/targets/cpp/emit-equality.js +41 -1
  177. package/dist/targets/cpp/emit-exceptions.js +29 -11
  178. package/dist/targets/cpp/emit-iterator-object-view.js +2 -2
  179. package/dist/targets/cpp/emit-iterator.js +33 -9
  180. package/dist/targets/cpp/emit-live-field-view.js +6 -1
  181. package/dist/targets/cpp/emit-narrowing.d.ts +11 -3
  182. package/dist/targets/cpp/emit-narrowing.js +58 -18
  183. package/dist/targets/cpp/emit-native-field-view.d.ts +3 -1
  184. package/dist/targets/cpp/emit-native-field-view.js +84 -8
  185. package/dist/targets/cpp/emit-properties.d.ts +1 -0
  186. package/dist/targets/cpp/emit-properties.js +26 -7
  187. package/dist/targets/cpp/emit-protocol-iterator.js +5 -2
  188. package/dist/targets/cpp/emit-record-view.js +14 -2
  189. package/dist/targets/cpp/emit-tostring.js +23 -1
  190. package/dist/targets/cpp/emit-union-properties.js +1 -1
  191. package/dist/targets/cpp/emit.d.ts +1 -1
  192. package/dist/targets/cpp/emit.js +99 -13
  193. package/dist/targets/cpp/host/emit-host-invoke.js +2 -2
  194. package/dist/targets/cpp/host/emit-host-object.js +28 -2
  195. package/dist/targets/cpp/host/emit-host-properties.js +9 -1
  196. package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
  197. package/dist/targets/cpp/host/emit-host-value.js +8 -6
  198. package/dist/targets/cpp/host/host-members.js +2 -1
  199. package/dist/targets/cpp/prototype/emit-prototype-array.js +69 -5
  200. package/dist/targets/cpp/prototype/emit-prototype-invoke.js +9 -9
  201. package/dist/targets/cpp/prototype/emit-prototype-iterator.js +2 -2
  202. package/dist/targets/cpp/prototype/emit-prototype-promise.js +7 -7
  203. package/dist/targets/cpp/records.d.ts +1 -0
  204. package/dist/targets/cpp/records.js +16 -7
  205. package/dist/targets/cpp/translation-unit.js +30 -16
  206. package/package.json +8 -7
  207. package/src/targets/cpp/runtime/gea_dynamic_proxy.h +42 -3
  208. package/src/targets/cpp/runtime/gea_eval.h +3 -0
  209. package/src/targets/cpp/runtime/gea_runtime.h +2399 -676
  210. package/dist/representation/any-null-record-members.d.ts +0 -41
  211. package/dist/representation/any-null-record-members.js +0 -115
  212. package/dist/semantics/any-null-member-declarations.d.ts +0 -32
  213. package/dist/semantics/any-null-member-declarations.js +0 -90
  214. package/dist/semantics/normalize/fresh-array-result.d.ts +0 -32
  215. package/dist/semantics/normalize/fresh-array-result.js +0 -125
@@ -1,3 +1,4 @@
1
+ import type { NativeIterableReceipt } from '../semantics/model/native-iterable.js';
1
2
  import type { DeclarationId, FunctionId, IrValueId, OperationId, 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';
@@ -435,6 +436,21 @@ export interface CallOperation extends IrOperationBase {
435
436
  * render time.
436
437
  */
437
438
  readonly target?: CallDispatchTarget;
439
+ /**
440
+ * A class method call `target` left `unresolved` ONLY because the receiver's
441
+ * class reserves an own-property slot that could shadow the method
442
+ * (`classMethodOverrideOf`): the body named here is what the call reaches
443
+ * whenever that slot is empty, which is the overwhelmingly common case
444
+ * (a computed-key write anywhere in the program reserves the slot for every
445
+ * method of the class). The emitter tests the slot's presence flag and calls
446
+ * this body by name, keeping the ordinary method-value call for an instance
447
+ * that does own the key. Set only when the held convention equals the body's,
448
+ * so both branches take the same arguments and produce the same result.
449
+ */
450
+ readonly ownShadowGuard?: {
451
+ readonly functionId: FunctionId;
452
+ readonly key: string;
453
+ };
438
454
  /**
439
455
  * The compiler-owned body identity of this call's callee, when the same
440
456
  * producer/member resolution used by `target` proved it without requiring
@@ -1035,6 +1051,8 @@ export interface BindCallableOperation extends IrOperationBase {
1035
1051
  export interface AllocateConstructorOperation extends IrOperationBase {
1036
1052
  readonly kind: 'allocate-constructor';
1037
1053
  readonly declaration: DeclarationId;
1054
+ /** Exact semantic proof: this evaluation needs identity/static state but no construct entry. */
1055
+ readonly constructionDeferred?: true;
1038
1056
  /** Same status as `AllocateCallableOperation.captures` -- see its comment. */
1039
1057
  readonly captures: readonly IrOperand[];
1040
1058
  /** The evaluated superclass object, whose prototype belongs to that evaluation rather than its declaration. */
@@ -1198,8 +1216,25 @@ export interface ConvertOperation extends IrOperationBase {
1198
1216
  * array-to-array pair has a node of its own and this is carried here, on
1199
1217
  * the one instruction whose source was proven unshared, rather than on the
1200
1218
  * pair.
1219
+ *
1220
+ * `'unshared-dictionary'` is the same fact for an open string table: a fresh
1221
+ * local table stored as its last use (`SemanticOperand.unsharedFreshTable`)
1222
+ * into a slot of another entry carrier -- that table, or an `optional` of it
1223
+ * -- rebuilt entry by entry in creation order, `conversionUse` naming the
1224
+ * ENTRY conversion.
1225
+ */
1226
+ readonly rebuild?: 'unshared-array' | 'unshared-dictionary';
1227
+ /**
1228
+ * On an `unshared-array` rebuild only: the source array is CONSUMED here --
1229
+ * a fresh factory result, or a local returned as its last use -- so each
1230
+ * element is moved out of it into its conversion rather than copied. An
1231
+ * element the source alone held then reaches its conversion with no other
1232
+ * holder, which is what lets an inner `never[]` (`Array.from({ length }, ()
1233
+ * => [])`) become its own fresh array rather than the shared sentinel
1234
+ * (`gea::emptyArraySentinel`'s unshared test). Absent for a borrowed source,
1235
+ * an array its holder still reads afterwards.
1201
1236
  */
1202
- readonly rebuild?: 'unshared-array';
1237
+ readonly releasesSource?: true;
1203
1238
  }
1204
1239
  /** A value demanded only on the impossible falsy edge of an exact source-proven object && left.
1205
1240
  * @semanticCategory generic-primitive
@@ -1274,6 +1309,7 @@ export interface MergeLiveArmRebuildOperation extends IrOperationBase {
1274
1309
  * `array-object` receiver this shape is reached with.
1275
1310
  */
1276
1311
  export interface GetIteratorOperation extends IrOperationBase {
1312
+ readonly nativeIterable?: NativeIterableReceipt;
1277
1313
  readonly kind: 'get-iterator';
1278
1314
  /** GetIterator captures next once on the returned iterator, before the first step. */
1279
1315
  readonly nativeNextMethodRead?: import('./native-iterator-field-views.js').NativeIteratorFieldRead;
@@ -1725,6 +1761,8 @@ export interface IrIteratorCloseRegion {
1725
1761
  readonly dismissTargets: readonly IrBlockId[];
1726
1762
  /** Finite patterns close only if no step has already observed exhaustion. */
1727
1763
  readonly onlyIfOpen: boolean;
1764
+ /** Certified finite pattern: IteratorStepValue abrupt completion marks record done. */
1765
+ readonly completeOnStepAbrupt?: true;
1728
1766
  /**
1729
1767
  * Where the loop BODY starts, or `null` for a finite pattern.
1730
1768
  *
@@ -25,7 +25,7 @@ export interface NativeAccessorHalfRecipe {
25
25
  * the native one already (a dynamic carrier) or no dynamic access exists. */
26
26
  readonly observe: ConversionNodeId | null;
27
27
  }
28
- /** Exact literal storage and Function provenance, independently replayed
28
+ /** Exact descriptor storage and Function provenance, independently replayed
29
29
  * before installation or any future accessor invocation.
30
30
  * @semanticCategory generic-primitive
31
31
  */
@@ -33,7 +33,8 @@ export interface NativeAccessorDefinitionRecipe {
33
33
  readonly receiver: IrValueId;
34
34
  readonly descriptor: IrValueId;
35
35
  readonly key: IrValueId;
36
- readonly keyText: string;
36
+ /** null authenticates only this SSA key, never a fixed-key reflection. */
37
+ readonly keyText: string | null;
37
38
  readonly halves: readonly NativeAccessorHalfRecipe[];
38
39
  }
39
40
  /** A reflected half is an adapted view of the original Function. The exact
@@ -98,12 +98,24 @@ export const nativeAccessorDefinitionOf = (operation, semantic, input, definitio
98
98
  const descriptorSource = operandOf(semantic, 'argument', 2);
99
99
  const semanticKey = operandOf(semantic, 'argument', 1);
100
100
  const keySource = definitionOf(key.value);
101
- if (descriptorSource?.source.kind !== 'result' ||
102
- keySource?.kind !== 'constant' ||
103
- keySource.literal !== 'string' ||
104
- semanticKey?.source.kind !== 'constant' ||
105
- semanticKey.source.literal !== 'string' ||
106
- semanticKey.source.text !== keySource.text)
101
+ const literalKey = keySource?.kind === 'constant' &&
102
+ keySource.literal === 'string' &&
103
+ semanticKey?.source.kind === 'constant' &&
104
+ semanticKey.source.literal === 'string' &&
105
+ semanticKey.source.text === keySource.text;
106
+ // A real declared-any string dictionary already owns arbitrary string slots.
107
+ // This additional installation route authenticates the actual argument SSA;
108
+ // it supplies no fixed-key/field proof to native records or later reflection.
109
+ // Native Functions remain native: only the dictionary's genuinely dynamic
110
+ // read/write boundary receives its separately certified observation frame.
111
+ const dictionaryKey = !literalKey &&
112
+ receiver.representation.kind === 'dictionary' &&
113
+ receiver.representation.key === 'string' &&
114
+ receiver.representation.value.kind === 'dynamic' &&
115
+ receiver.representation.value.reason === 'declared-any-never-narrowed' &&
116
+ key.representation.kind === 'string' &&
117
+ intrinsicCallArgumentMatches(operation, semantic, 1, definitionOf);
118
+ if (descriptorSource?.source.kind !== 'result' || (!literalKey && !dictionaryKey))
107
119
  return null;
108
120
  const fields = descriptorLayout.fields;
109
121
  if (!fields.some((field) => field.key === 'get' || field.key === 'set') ||
@@ -274,12 +286,12 @@ export const nativeAccessorDefinitionOf = (operation, semantic, input, definitio
274
286
  producer.lineage !== source.result.id ||
275
287
  origins.get(producer.lineage) !== source.callable)
276
288
  return null;
277
- const half = nativeAccessorHalfOf(field.key, held, source.callable, input, receiver.representation.kind === 'dynamic');
289
+ const half = nativeAccessorHalfOf(field.key, held, source.callable, input, receiver.representation.kind === 'dynamic' || dictionaryKey);
278
290
  if (half === null)
279
291
  return null;
280
292
  halves.push(half);
281
293
  }
282
- return { receiver: receiver.value, descriptor: descriptor.value, key: key.value, keyText: keySource.text, halves };
294
+ return { receiver: receiver.value, descriptor: descriptor.value, key: key.value, keyText: literalKey ? keySource.text : null, halves };
283
295
  };
284
296
  export const nativeAccessorDefinitionMatches = (expected, actual) => expected !== null &&
285
297
  expected.receiver === actual.receiver &&
@@ -363,7 +375,11 @@ export const nativeAccessorObservationNeedsReceipt = (operation, semantic, input
363
375
  .some((candidate) => {
364
376
  if (candidate.kind !== 'call' || !candidate.nativeAccessorDefinition)
365
377
  return false;
366
- if (observedKey !== null && candidate.nativeAccessorDefinition.keyText !== observedKey)
378
+ // An SSA-key installation might have installed this literal key too; do
379
+ // not misclassify it as absent. Only a known, different key is excluded.
380
+ if (observedKey !== null &&
381
+ candidate.nativeAccessorDefinition.keyText !== null &&
382
+ candidate.nativeAccessorDefinition.keyText !== observedKey)
367
383
  return false;
368
384
  // The ambient descriptor's own `get(): any` / `set(v: any)` halves call
369
385
  // the installed Function through its dynamic frame with an undefined
@@ -444,7 +460,10 @@ export const nativeAccessorObservationOf = (operation, semantic, input, definiti
444
460
  return false;
445
461
  const source = semanticOf(input.graph, candidate);
446
462
  const held = source?.family === 'invocation' ? operandOf(source, 'argument', 0) : undefined;
447
- return (candidate.nativeAccessorDefinition.keyText === keySource.text &&
463
+ return (
464
+ // SSA-key installation alone never authenticates a fixed-key view.
465
+ candidate.nativeAccessorDefinition.keyText !== null &&
466
+ candidate.nativeAccessorDefinition.keyText === keySource.text &&
448
467
  held?.source.kind === 'result' &&
449
468
  census.origins.get(held.source.result) === owner);
450
469
  });
@@ -36,7 +36,7 @@ export const nativeArrayTransportOf = (operation, constantKey) => {
36
36
  // index enters this path. A runtime STRING key is rendered as an element
37
37
  // access through CanonicalNumericIndexString (`arrayIndexFromKeyText` in
38
38
  // `emit-carrier-members.ts`/`emit-properties.ts`) -- the `for (const i in
39
- // array)` key hono's RegExpRouter indexes back with -- so it reaches no
39
+ // array)` key a regular-expression router indexes back with -- so it reaches no
40
40
  // field protocol either.
41
41
  const indexed = constantKey !== null
42
42
  ? canonicalIndexLiteral(constantKey) !== null
@@ -55,7 +55,7 @@ export const nativeArrayTransportOf = (operation, constantKey) => {
55
55
  * A numeric index read off a union whose every arm is an Array reads each
56
56
  * arm's own element storage, exactly as the single-Array read above does, and
57
57
  * injects it into the result's arm for that element: no field protocol, no
58
- * adaptation. Hono's `compose` reads `middleware[i]` off
58
+ * adaptation. An HTTP framework's `compose` reads `middleware[i]` off
59
59
  * `[[Function, unknown], unknown][] | [[Function]][]`; as a computed key it
60
60
  * published every handler tuple the router holds.
61
61
  */
@@ -1,4 +1,5 @@
1
1
  import type { ConversionNode } from '../conversion/algebra.js';
2
+ import { type NativeFieldViewPlan } from '../conversion/native-field-view.js';
2
3
  import type { RepresentationDeriver } from '../representation/derive.js';
3
4
  import { type CallableAbi, type Representation } from '../representation/model.js';
4
5
  import type { FunctionId } from '../identity/ids.js';
@@ -38,6 +39,28 @@ export interface NativeFieldViewDomains {
38
39
  */
39
40
  readonly absentRoutesOf: (receiver: Representation, key: string | null) => readonly NativeFieldStorageDomain[] | null;
40
41
  }
42
+ /** The identity of one receiver's store of a forwarded key no source declares (`NativeCallableFlow.nativeFieldViewForwardedWrites`). */
43
+ export declare const nativeFieldViewForwardedWriteKey: (receiver: string, key: string) => string;
44
+ /** The installed live plans by target shape, as `nativeFieldViewDomainsOf` indexes them. */
45
+ export declare const nativeFieldViewPlansByTargetOf: (nodes: Iterable<ConversionNode>) => ReadonlyMap<string, readonly NativeFieldViewPlan[]>;
46
+ /**
47
+ * Where a store of a runtime key outside every named descriptor lands, for a
48
+ * value carried as `receiver` (`data[key] = v` over a live view target): the
49
+ * record carriers whose own expando takes it -- the plain allocation itself
50
+ * and, through each installed live plan, its original source -- or null when
51
+ * some allocation behind the carrier has no certified home for an undeclared
52
+ * key. An installed Document view stores the key as its own entry, and an
53
+ * indexed record's plain allocation in its index sidecar; neither is an
54
+ * expando home. A class instance, a native base, a view whose source keeps
55
+ * undeclared keys in an index sidecar, and any union are homes this proof
56
+ * does not cover, so the store stays refused there. `named` is every key a
57
+ * slot, accessor or installed descriptor along the way declares: a store of
58
+ * one of those takes its route, never a home.
59
+ */
60
+ export declare const nativeFieldViewOpenWriteHomesOf: (receiver: Representation, plans: ReadonlyMap<string, readonly NativeFieldViewPlan[]>, layoutOf: Pick<RepresentationDeriver, "layoutOf"> | null | undefined) => {
61
+ readonly homes: readonly Representation[];
62
+ readonly named: ReadonlySet<string>;
63
+ } | null;
41
64
  /**
42
65
  * A callback's physical descriptor remains fixed when its Function identity
43
66
  * escapes. Enumerate only installed live allocation plans, plus the ordinary
@@ -6,6 +6,85 @@ import { abiOfCallee } from '../projection/callee.js';
6
6
  import { nativeDataPropertyOf } from '../representation/native-data-properties.js';
7
7
  const binaryViewDataKeys = ['buffer', 'byteLength', 'byteOffset', 'length', 'BYTES_PER_ELEMENT'];
8
8
  const isDocumentPlan = (plan) => plan.source.kind === 'dictionary' && plan.fields.every((field) => field.declaredAnyEntry === true);
9
+ /** The identity of one receiver's store of a forwarded key no source declares (`NativeCallableFlow.nativeFieldViewForwardedWrites`). */
10
+ export const nativeFieldViewForwardedWriteKey = (receiver, key) => JSON.stringify([receiver, key]);
11
+ /** The installed live plans by target shape, as `nativeFieldViewDomainsOf` indexes them. */
12
+ export const nativeFieldViewPlansByTargetOf = (nodes) => {
13
+ const plans = new Map();
14
+ for (const plan of nativeFieldViewPlansOf(nodes)) {
15
+ const entries = plans.get(plan.target.shapeId) ?? [];
16
+ if (!entries.includes(plan))
17
+ entries.push(plan);
18
+ plans.set(plan.target.shapeId, entries);
19
+ }
20
+ return plans;
21
+ };
22
+ /**
23
+ * Where a store of a runtime key outside every named descriptor lands, for a
24
+ * value carried as `receiver` (`data[key] = v` over a live view target): the
25
+ * record carriers whose own expando takes it -- the plain allocation itself
26
+ * and, through each installed live plan, its original source -- or null when
27
+ * some allocation behind the carrier has no certified home for an undeclared
28
+ * key. An installed Document view stores the key as its own entry, and an
29
+ * indexed record's plain allocation in its index sidecar; neither is an
30
+ * expando home. A class instance, a native base, a view whose source keeps
31
+ * undeclared keys in an index sidecar, and any union are homes this proof
32
+ * does not cover, so the store stays refused there. `named` is every key a
33
+ * slot, accessor or installed descriptor along the way declares: a store of
34
+ * one of those takes its route, never a home.
35
+ */
36
+ export const nativeFieldViewOpenWriteHomesOf = (receiver, plans, layoutOf) => {
37
+ if (receiver.kind === 'optional' || receiver.kind === 'borrowed-ref')
38
+ return nativeFieldViewOpenWriteHomesOf(receiver.kind === 'optional' ? receiver.payload : receiver.referent, plans, layoutOf);
39
+ if (receiver.kind !== 'record' && receiver.kind !== 'record-with-index' && receiver.kind !== 'native-record-ref')
40
+ return null;
41
+ if (receiver.ownership !== 'shared-refcount')
42
+ return null;
43
+ const installed = plans.get(receiver.shapeId);
44
+ if (!installed?.length)
45
+ return null;
46
+ const named = new Set();
47
+ const name = (keys) => {
48
+ for (const { key } of keys)
49
+ named.add(key);
50
+ };
51
+ if (receiver.kind === 'record-with-index') {
52
+ if (!installed.every(isDocumentPlan))
53
+ return null;
54
+ name(receiver.fields);
55
+ for (const plan of installed)
56
+ name(plan.fields);
57
+ return { homes: [], named };
58
+ }
59
+ const homes = [];
60
+ const pending = [receiver];
61
+ const seen = new Set();
62
+ while (pending.length > 0) {
63
+ const carrier = pending.pop();
64
+ const identity = representationKey(carrier);
65
+ if (seen.has(identity))
66
+ continue;
67
+ seen.add(identity);
68
+ if ((carrier.kind !== 'record' && carrier.kind !== 'native-record-ref') || carrier.ownership !== 'shared-refcount')
69
+ return null;
70
+ const ordinary = carrier.kind === 'native-record-ref'
71
+ ? carrier.native === null
72
+ ? layoutOf?.layoutOf(carrier.shapeId)
73
+ : null
74
+ : carrier;
75
+ if (ordinary?.kind !== 'record')
76
+ return null;
77
+ homes.push(carrier);
78
+ name(ordinary.fields);
79
+ name(ordinary.accessors);
80
+ for (const plan of plans.get(carrier.shapeId) ?? []) {
81
+ name(plan.fields);
82
+ if (!isDocumentPlan(plan))
83
+ pending.push(plan.source);
84
+ }
85
+ }
86
+ return { homes, named };
87
+ };
9
88
  /**
10
89
  * A callback's physical descriptor remains fixed when its Function identity
11
90
  * escapes. Enumerate only installed live allocation plans, plus the ordinary
@@ -72,6 +151,26 @@ expandoStoredOf = () => []) => {
72
151
  return false;
73
152
  return (plans.get(receiver.shapeId) ?? []).every((plan) => !plan.fields.some((field) => field.key === key) && keyAbsentIn(plan.source, key, seen));
74
153
  };
154
+ /**
155
+ * Whether a plain allocation of `source` stores `key` in its own slot or
156
+ * accessor. A forwarded key a source's layout does not declare is answered
157
+ * from that allocation's expando -- even when the source is itself a view
158
+ * target whose installed plans route the key: the plain allocation has no
159
+ * such route, and its expando may be empty.
160
+ */
161
+ const ordinaryDeclares = (source, key) => {
162
+ if (source.kind === 'optional' || source.kind === 'borrowed-ref')
163
+ return ordinaryDeclares(source.kind === 'optional' ? source.payload : source.referent, key);
164
+ const ordinary = source.kind === 'native-record-ref'
165
+ ? source.native === null
166
+ ? layoutOf?.layoutOf(source.shapeId)
167
+ : null
168
+ : source;
169
+ if (ordinary?.kind !== 'record' && ordinary?.kind !== 'record-with-index')
170
+ return true;
171
+ return (ordinary.fields.some((field) => field.key === key) ||
172
+ (ordinary.kind === 'record' && ordinary.accessors.some((accessor) => accessor.key === key)));
173
+ };
75
174
  const domainsOf = (receiver, ordinaryArm = false) => {
76
175
  const identity = `${representationKey(receiver)}:${ordinaryArm ? 'ordinary' : 'live'}`;
77
176
  if (cache.has(identity))
@@ -89,9 +188,10 @@ expandoStoredOf = () => []) => {
89
188
  const arms = objectArms.map((arm) => domainsOf(arm.value, true));
90
189
  if (!arms.length || arms.some((arm) => arm === null))
91
190
  return null;
92
- // A per-arm union, not an intersection: `(message as LogConvertible).toLog`
93
- // over `StartedEvent | LoggableSucceeded | LogConvertible` names a key only
94
- // one arm stores. Every other arm contributes the certified absence of
191
+ // A per-arm union, not an intersection: a key only one arm stores (a
192
+ // computed read, or a constant key some view-target arm declares --
193
+ // `unionReadNeedsReceipt` sends any other constant-key read to the
194
+ // ordinary per-arm dispatch). Every other arm contributes the certified absence of
95
195
  // its ordinary allocation -- a `get` answers its expando entry or
96
196
  // `undefined` -- and only where that absence is provable (`keyAbsentIn`);
97
197
  // one unprovable arm drops the key, exactly as the intersection did.
@@ -158,7 +258,7 @@ expandoStoredOf = () => []) => {
158
258
  // An accessor with no admitted ABI (a getter nothing calls has
159
259
  // no body) states no route for ITS key; it does not void the
160
260
  // class's other members. node-compat's `ResponseImpl` declares
161
- // every WHATWG attribute as a getter and hono reads only
261
+ // every WHATWG attribute as a getter and an HTTP framework reads only
162
262
  // `headers` off `Response | ResponseInit`.
163
263
  if (!getter ||
164
264
  getter.parameters.length !== 0 ||
@@ -222,10 +322,13 @@ expandoStoredOf = () => []) => {
222
322
  cache.set(identity, null);
223
323
  return null;
224
324
  }
225
- const forwarded = new Set((installed ?? []).flatMap((plan) => plan.fields.flatMap((field) => (field.descriptorForward ? [field.key] : []))));
325
+ // Every declared slot, a key a view forwards included: a plain allocation
326
+ // of this carrier holds it in its own C++ member whatever its views do.
327
+ // `createServer()`'s `options = {}` default and a caller's literal reach
328
+ // the same parameter as a `{}` viewed through it, and a receiver no heap
329
+ // proof covers reads with these routes alone.
226
330
  for (const field of ordinary.fields)
227
- if (!forwarded.has(field.key))
228
- add(field.key, { read: field.value, write: field.value });
331
+ add(field.key, { read: field.value, write: field.value });
229
332
  for (const accessor of ordinary.kind === 'record' ? ordinary.accessors : []) {
230
333
  const getter = accessor.getter === null ? null : abiOf(accessor.getter);
231
334
  const setter = accessor.setter === null ? null : abiOf(accessor.setter);
@@ -258,8 +361,11 @@ expandoStoredOf = () => []) => {
258
361
  add(field.key, field);
259
362
  // A forwarded key the source never stores answers from its expando
260
363
  // table, which without an own descriptor reads `undefined`, and
261
- // otherwise holds whatever native carrier a copy stored there.
262
- else if (inherited !== null && !inherited.has(field.key)) {
364
+ // otherwise holds whatever native carrier a copy stored there. The
365
+ // forward reads that expando and nothing else, so its answers do not
366
+ // depend on whether the source's own layout is known: an unresolved
367
+ // source still answers `undefined` for a key it never received.
368
+ else if (inherited === null || !inherited.has(field.key) || !ordinaryDeclares(plan.source, field.key)) {
263
369
  add(field.key, { read: { kind: 'undefined' }, write: null, sourceAbsent: true });
264
370
  if ('shapeId' in plan.source)
265
371
  for (const stored of expandoStoredOf(plan.source.shapeId, field.key))
@@ -7,6 +7,7 @@ import { type GetOperation, type SetOperation, type IrBody, type IrOperand } fro
7
7
  import { type NativeFieldViewPlan } from '../conversion/native-field-view.js';
8
8
  import type { ProgramConversionRecipe } from './program-conversions.js';
9
9
  import type { HostNamespaceCensus } from './host-namespace-reads.js';
10
+ import type { RepresentationDeriver } from '../representation/derive.js';
10
11
  export interface NativeFieldViewRead {
11
12
  readonly receiver: IrValueId;
12
13
  readonly carrier: string;
@@ -39,8 +40,34 @@ export interface NativeFieldViewWrite {
39
40
  readonly target: Representation | null;
40
41
  readonly conversion: ConversionNodeId | null;
41
42
  }[];
43
+ /**
44
+ * A runtime key a descriptor may not name: `keyDomain` is every key a live
45
+ * descriptor names (of the proven set, when there is one), each keeping its
46
+ * exact slot route, and any other key is
47
+ * stored on the allocation's own extension -- the original source's
48
+ * expando behind a view, an installed Document's entry, or the plain
49
+ * allocation's own expando or index sidecar (`nativeFieldViewOpenWriteHomesOf`).
50
+ */
51
+ readonly openKeys?: true;
52
+ /**
53
+ * The carrier an unnamed key keeps in an expando: the value's own, which the
54
+ * write threads to the runtime as its typed policy, with the certified Value
55
+ * materializer only a dynamic observer runs. Both are also `targets`, so the
56
+ * same adapter answers an expando, a Document entry, and every named slot.
57
+ */
58
+ readonly open?: {
59
+ readonly carrier: Representation;
60
+ readonly materializer: ConversionNodeId;
61
+ };
62
+ /**
63
+ * Named keys a live view forwards to an original source whose own layout
64
+ * does not declare them (a `sourceAbsent` descriptor): JavaScript creates
65
+ * the property on that source, so the write carries `open` as well and
66
+ * the source's expando keeps it, exactly as for an unnamed key.
67
+ */
68
+ readonly forwardedKeys?: readonly string[];
42
69
  }
43
- type FieldFlow = Pick<NativeCallableFlow, 'nativeFieldStorageValues' | 'nativeAccessorStorageValues' | 'nativeFieldMethodValues'> & Partial<Pick<NativeCallableFlow, 'nativeFieldViewStorageValues' | 'nativeFieldOperationStorageValues' | 'nativeFieldViewOrigins' | 'nativeFieldViewAbsentRoutesOf'>>;
70
+ type FieldFlow = Pick<NativeCallableFlow, 'nativeFieldStorageValues' | 'nativeAccessorStorageValues' | 'nativeFieldMethodValues'> & Partial<Pick<NativeCallableFlow, 'nativeFieldViewStorageValues' | 'nativeFieldOperationStorageValues' | 'nativeFieldViewOrigins' | 'nativeFieldViewAbsentRoutesOf' | 'nativeFieldViewOpenWriteValues' | 'nativeFieldViewForwardedWrites'>>;
44
71
  /** Reachability follows exact published receipts, including recipes created by an earlier publication pass. */
45
72
  export declare const nativeFieldViewCitationsOf: (operation: import("./model.js").IrOperation) => readonly ConversionNodeId[];
46
73
  export declare const nativeFieldViewBodyCitationsOf: (body: IrBody) => readonly ConversionNodeId[];
@@ -75,7 +102,9 @@ export declare const nativeFieldViewOpenDocumentRead: (operation: GetOperation |
75
102
  * the path itself as a value. The census is the one authority on which
76
103
  * values are paths; publication and certification both ask it here.
77
104
  */
78
- export declare const nativeFieldViewOperationNeedsReceipt: (operation: GetOperation | SetOperation, targets: ReadonlySet<string>, hostNamespaces: HostNamespaceCensus | undefined) => boolean;
105
+ export declare const nativeFieldViewOperationNeedsReceipt: (operation: GetOperation | SetOperation, targets: ReadonlySet<string>, hostNamespaces: HostNamespaceCensus | undefined,
106
+ /** The read's constant key, when it has one. */
107
+ key?: string | null, layoutOf?: Pick<RepresentationDeriver, "layoutOf"> | null) => boolean;
79
108
  export declare const nativeFieldViewCarrierNeedsReceipt: (value: Representation, targets: ReadonlySet<string>) => boolean;
80
109
  export declare const nativeFieldViewReadFor: (receiver: IrOperand, key: string, target: Representation, flow: FieldFlow, conversions: ConversionCensus, at?: GetOperation) => NativeFieldViewRead | null;
81
110
  export declare const nativeFieldViewReadOf: (operation: GetOperation, key: string, flow: FieldFlow, conversions: ConversionCensus) => NativeFieldViewRead | null;
@@ -92,6 +121,21 @@ export declare const nativeFieldViewReadSelectionOf: (operation: GetOperation, k
92
121
  export declare const nativeFieldViewOpenReadOf: (operation: GetOperation, flow: FieldFlow, conversions: ConversionCensus) => NativeFieldViewRead | null;
93
122
  export declare const nativeFieldViewWriteOf: (operation: SetOperation, key: string, flow: FieldFlow, conversions: ConversionCensus) => NativeFieldViewWrite | null;
94
123
  export declare const nativeFieldViewWriteSelectionOf: (operation: SetOperation, keys: readonly string[], flow: FieldFlow, conversions: ConversionCensus) => NativeFieldViewWrite | null;
124
+ /**
125
+ * `for (const key in parameters) data[key] = parameters[key]` over a live view
126
+ * target (three's `BufferGeometry.toJSON`): the write counterpart of
127
+ * `nativeFieldViewOpenReadOf`. Every named key keeps its exact slot route; a
128
+ * key outside them is created or overwritten where JavaScript would put it
129
+ * -- the original source's own expando behind a record view, an installed
130
+ * Document's entry, or the plain allocation's expando or index sidecar --
131
+ * and only where every allocation the carrier can hold has such a home
132
+ * (`nativeFieldViewOpenWriteValues`). The value keeps its own carrier there,
133
+ * so a carrier with no storage identity or no certified Value materializer
134
+ * (what a dynamic observer of the key would need) is refused.
135
+ */
136
+ export declare const nativeFieldViewOpenWriteOf: (operation: SetOperation, flow: FieldFlow, conversions: ConversionCensus,
137
+ /** A proven finite key set (`provenKeyTexts`): only its named members keep a slot route. */
138
+ proven?: readonly string[]) => NativeFieldViewWrite | null;
95
139
  /** Independent certification recalculates the complete slot set and each canonical leaf. */
96
140
  export declare const nativeFieldViewReceiptMatches: (expected: NativeFieldViewRead | NativeFieldViewWrite | null, actual: NativeFieldViewRead | NativeFieldViewWrite | undefined) => boolean;
97
141
  export {};