@yabgu_gm/tensionscript 0.13.1 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6734,25 +6734,75 @@ declare module "types:tensionscript/src/compiler" {
6734
6734
  * Compiles an array literal into one operand per element leaf, starting at
6735
6735
  * `at`, and returns how many were written.
6736
6736
  *
6737
- * Shared by the call site (`expandSroaArrayArgument`) and the return
6738
- * (`compileMultivalueReturnStatement`) so the two positions accept the same
6739
- * shapes and refuse the same ones by the same rule, instead of by two copies
6740
- * of it. `verb` is `"passing"` or `"returning"` — the only word the two
6741
- * refusals disagree on.
6742
- *
6743
- * Three rules:
6744
- *
6745
- * - A **record element** is several leaves and no literal names them, so it is
6746
- * refused by name; building the array field-by-field in a local is the
6747
- * working route in both positions.
6748
- * - A **short** literal zero-fills. The slot exists either way, and a WASM
6749
- * operand cannot be left out.
6750
- * - A **long** literal is an arity error rather than a write past the operand
6751
- * block — `sum([1, 2, 3, 4, 5])` into a `[u32 * 4]` parameter reached
6752
- * Binaryen with five operands for four slots and crashed the compiler, so
6753
- * this bound is a guard, not a formality.
6737
+ * The operand sink of `emitSroaArrayLiteralLeaves`: the walk yields the leaves
6738
+ * and this places them, then fills any element the literal omitted — a WASM
6739
+ * operand cannot be left out, even when a local could (`fillSroaArrayFromLiteral`,
6740
+ * where zero is free).
6754
6741
  */
6755
6742
  private pushSroaArrayLiteralOperands;
6743
+ /**
6744
+ * Compiles an array literal into one **leaf expression per leaf**, appended to
6745
+ * `leaves` in element-major order.
6746
+ *
6747
+ * **The one array-literal element walk.** Three positions use it: the call site
6748
+ * (`pushSroaArrayLiteralOperands`), the return
6749
+ * (`compileMultivalueReturnStatement`), and the local declaration
6750
+ * (`fillSroaArrayFromLiteral`). A value-form array's elements are leaves, and
6751
+ * the positions differ only in what they do with them — push operands, make a
6752
+ * tuple, or `local.set` — so the rules for *reading* a literal live here once.
6753
+ *
6754
+ * `verb` is `"passing"`, `"returning"` or `"initializing"`; it only chooses
6755
+ * the wording of the refusals.
6756
+ *
6757
+ * The elements a literal omits are **not** produced here: a WASM local starts
6758
+ * at zero, so a local declaration needs no stores for them, while an argument
6759
+ * or a return needs an operand and the caller fills it (`makeZero` per leaf
6760
+ * type). Two different destinations, one walk.
6761
+ *
6762
+ * A **long** literal is an arity error rather than a write past the leaf
6763
+ * block — `sum([1, 2, 3, 4, 5])` into a `[u32 * 4]` parameter reached Binaryen
6764
+ * with five operands for four slots and crashed the compiler, so this bound is
6765
+ * a guard, not a formality.
6766
+ *
6767
+ * A **record** element is several leaves, so it is read one leaf per field: an
6768
+ * object literal (`{ x: 1.5, y: 2.5 }`) compiles straight to them
6769
+ * (`emitSroaObjectElementLeaves`), and anything else — a record local, a call —
6770
+ * is refused by name, because a local there is a pointer, not the leaves.
6771
+ */
6772
+ private emitSroaArrayLiteralLeaves;
6773
+ /**
6774
+ * Compiles one **object literal** element of a `[T * N]` array literal into
6775
+ * that element's field leaves, in declaration order.
6776
+ *
6777
+ * `{ x: 10.5, y: 20.5 }` is the natural way to write a record element, and for
6778
+ * an `@unmanaged struct` it can be compiled straight to leaves — no heap
6779
+ * record, no constructor, no pointer. The class path (`compileObjectLiteral`)
6780
+ * cannot be reused for it: that one requires a class, takes a temp local of
6781
+ * that class, and returns one reference, because it has to produce an
6782
+ * *address*. Measured on the same spelling: `const p: P = { x: 10.5 }` emits
6783
+ * `P#constructor` plus `__alloc(16)` and setters — a heap record, not a value.
6784
+ *
6785
+ * Policies, each measured against the class path so the two spellings agree:
6786
+ *
6787
+ * - **Declaration order.** Fields are emitted in the record's declaration
6788
+ * order, not the literal's, because the leaves are positional.
6789
+ * - **Last duplicate wins** — `{ x: 1.0, x: 2.0 }` is `2.0`, as measured for
6790
+ * `const p: P = { x: 1.0, x: 2.0 }`.
6791
+ * - **An unknown name is an error** at the name, matching
6792
+ * `compileObjectLiteral`'s `TS2339`.
6793
+ * - **An omitted field takes its declared default**, matching the constructor
6794
+ * the class path runs: measured, `{ x: 10.0 }` on `{ x = 5.0; y = 7.0 }`
6795
+ * yielded `y = 7.0`, not `0`. Only a **constant** default is reproduced
6796
+ * here; one that needs the record instance (`y = this.x * 2.0`) is refused
6797
+ * by name, because a leaf emission has no instance to evaluate it against.
6798
+ * - **A field left with no default is zero**, matching `{ x: 3.0 }` on a record
6799
+ * with no initialisers (measured: `y` came back `0`).
6800
+ *
6801
+ * A **nested** field (an `@inline struct` inside the record) is refused: its
6802
+ * value is a second set of leaves behind a second object literal, which is the
6803
+ * recursion this landing does not carry.
6804
+ */
6805
+ private emitSroaObjectElementLeaves;
6756
6806
  private expandSroaArgument;
6757
6807
  /**
6758
6808
  * The SROA local an expression names, or `null`.
@@ -6778,6 +6828,18 @@ declare module "types:tensionscript/src/compiler" {
6778
6828
  * carrying its own map, so the walk descends through it.
6779
6829
  */
6780
6830
  private pushSroaLeafOperands;
6831
+ /**
6832
+ * Collects a `fieldLocals` tree's leaves into `out`, depth first.
6833
+ *
6834
+ * **The one definition of leaf order.** A nested value is a placeholder
6835
+ * (index `-1`) carrying its own map, so the walk descends through it rather
6836
+ * than yielding it. Every emitter that needs "the leaves of this value, in
6837
+ * order" goes through here — `pushSroaLeafOperands` for call operands, the
6838
+ * array-literal walk for literal elements, the local binder for stores — so
6839
+ * order is stated once instead of re-derived per site. It must agree with
6840
+ * `Signature.leafTypesOf`, which is the type-level twin.
6841
+ */
6842
+ private collectSroaLeafLocals;
6781
6843
  private resolveSroaReceiver;
6782
6844
  /** Size of the static call-temp region, in bytes. 4 KB is 256 slots at the
6783
6845
  * 16-byte fixture record size. Overflow aborts (see `makeSretCallBlock`);
@@ -7089,14 +7151,18 @@ declare module "types:tensionscript/src/compiler" {
7089
7151
  /**
7090
7152
  * Stores an array literal's elements into a value-form array's leaves.
7091
7153
  *
7092
- * A scalar element is compiled straight into its leaf. A **record** element is
7093
- * several leaves and a literal cannot name them one at a time, so it is
7094
- * refused by name here rather than compiled: the object-literal spelling
7095
- * (`{ x: 1.5, y: 2.5 }`) goes through the class path and *allocates* — measured,
7096
- * `const p: P = { x: 1.5 }` emitted `P#constructor` plus setters and needed
7097
- * `env.abort`, i.e. a heap record behind a pointer, which is not a value.
7098
- * Initialising the elements field by field (`arr[0].x = 10.5`) is the working
7099
- * route, and it is what the diagnostic says.
7154
+ * The **local-declaration sink** of `emitSroaArrayLiteralLeaves`: the walk
7155
+ * yields one expression per leaf in element-major order, and this local's
7156
+ * leaves were created in the same order (`fillSroaArrayLocals` keys them
7157
+ * `"0"`, `"1"`, ...), so the two line up positionally and a `local.set` per
7158
+ * pair is the whole job. No zero-fill: a WASM local starts at zero, so an
7159
+ * omitted element needs no store — which is why the walk does not produce one.
7160
+ *
7161
+ * A scalar element is one leaf. A **record** element is several, and the walk
7162
+ * refuses it by name: the object-literal spelling (`{ x: 1.5, y: 2.5 }`) goes
7163
+ * through the class path and *allocates* — measured, `const p: P = { x: 1.5 }`
7164
+ * emitted `P#constructor` plus setters and needed `env.abort`, i.e. a heap
7165
+ * record behind a pointer, which is not a value.
7100
7166
  */
7101
7167
  private fillSroaArrayFromLiteral;
7102
7168
  /**