@yabgu_gm/tensionscript 0.11.0 → 0.11.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.
@@ -2045,7 +2045,9 @@ declare module "types:tensionscript/src/diagnosticMessages.generated" {
2045
2045
  _abi_align_0_the_alignment_must_be_a_power_of_two = 6407,
2046
2046
  _abi_align_0_is_less_than_the_field_type_s_natural_alignment_1_asking_for_less_is_a_lie_so_it_is_refused_rather_than_silently_ignored = 6408,
2047
2047
  _abi_align_0_is_too_large_the_maximum_is_1 = 6409,
2048
- Alignment_is_a_property_of_the_field_not_its_type_Place_abi_align_N_on_the_field_declaration = 6410
2048
+ Alignment_is_a_property_of_the_field_not_its_type_Place_abi_align_N_on_the_field_declaration = 6410,
2049
+ A_view_parameter_unmanaged_0_over_an_inline_type_cannot_appear_in_a_host_visible_signature_an_external_or_exported_parameter_is_supplied_by_the_host_and_a_view_is_an_address_this_compiler_did_not_materialise = 6411,
2050
+ Call_to_0_emits_1_operands_but_its_signature_declares_2 = 6412
2049
2051
  }
2050
2052
  /** Translates a diagnostic code to its respective string. */
2051
2053
  export function diagnosticCodeToString(code: DiagnosticCode): string;
@@ -2957,6 +2959,60 @@ declare module "types:tensionscript/src/resolver" {
2957
2959
  currentElementExpression: Expression | null;
2958
2960
  /** Whether a new override has been discovered. */
2959
2961
  discoveredOverride: boolean;
2962
+ /**
2963
+ * Whether a use-site `@unmanaged` over an `@inline` declaration is being
2964
+ * resolved as the **type argument of `changetype`**.
2965
+ *
2966
+ * That position is the one where the operand can supply the address the value
2967
+ * itself does not have, so the refusal's premise does not hold there (see
2968
+ * `checkMemoryModelOverride`). Every other position — a parameter, a local, a
2969
+ * field, a return type — still refuses with `TS6395`, which is what keeps the
2970
+ * function-parameter form (`Phase 2`) out of this change.
2971
+ *
2972
+ * The compiler sets this around the one `resolveTypeArguments` call it makes
2973
+ * for a `changetype` builtin (`Compiler#compileCallExpressionBuiltin`), and
2974
+ * resets it immediately: the flag is a scope, not a mode.
2975
+ */
2976
+ allowInlineView: boolean;
2977
+ /**
2978
+ * Whether a use-site `@unmanaged` over an `@inline` declaration is being
2979
+ * resolved in a **parameter position** — the cell where the caller supplies
2980
+ * the address, so `f(a: @unmanaged T)` with an inline `T` is a view parameter.
2981
+ *
2982
+ * Distinct from {@link allowInlineView} (Phase 1, `changetype`'s type
2983
+ * argument, where the operand supplies the address at the point of use).
2984
+ *
2985
+ * **Saved and restored, never blindly cleared.** Resolving one parameter's
2986
+ * type can resolve another function (a default value's call, a nested
2987
+ * signature), and a nested window that reset the flag to `false` on the way
2988
+ * out closed the outer window — measured: the owner's pattern reported TS6395
2989
+ * with both flags reading `false` while inside `resolveFunction`'s own loop.
2990
+ */
2991
+ allowInlineViewParam: boolean;
2992
+ /**
2993
+ * Call expressions that are **views of caller bytes**: an inline-typed
2994
+ * `changetype<@unmanaged T>(ptr)`.
2995
+ *
2996
+ * Marked here, at resolution, because the compiler asks this question while
2997
+ * compiling the *field access* — which happens before the `changetype` it
2998
+ * wraps is ever compiled. Recording it at codegen time (the first attempt)
2999
+ * produced a field read that never saw the mark and compiled to
3000
+ * `unreachable`.
3001
+ *
3002
+ * Keyed on the AST node rather than on the type, because the type is the
3003
+ * declaration's (`T` is still an `@inline struct`) and the model is the
3004
+ * *use's*: there is one `Type` per class, shared by every use.
3005
+ */
3006
+ private viewCalls;
3007
+ /**
3008
+ * Records `node` as a view call. The resolver marks the ones it resolves;
3009
+ * `Compiler#compileCallExpressionBuiltin` marks the ones it resolves itself,
3010
+ * because a builtin's type arguments are resolved on the *codegen* path and
3011
+ * never pass through `maybeInferCall`.
3012
+ */
3013
+ markViewCall(node: Expression): void;
3014
+ /** Whether `node` is an inline-typed `changetype<@unmanaged T>(...)`. */
3015
+ isViewCall(node: Expression): boolean;
2960
3016
  /** Constructs the resolver for the specified program. */
2961
3017
  constructor(
2962
3018
  /** The program to construct a resolver for. */
@@ -2984,10 +3040,14 @@ declare module "types:tensionscript/src/resolver" {
2984
3040
  * - **`@managed` over an `@unmanaged` declaration** — the collector traces a
2985
3041
  * reference through a header the record does not have. No emitter can
2986
3042
  * invent the header, so a use cannot confer provenance. (`TS6394`.)
2987
- * - **`@unmanaged`/`@managed` over an `@inline` declaration** — a value is
2988
- * stored as one local per field and has **no address** at all, so there is
2989
- * nothing to lend as a pointer and nothing a header could sit in front of.
2990
- * (`TS6395`.)
3043
+ * - **`@managed` over an `@inline` declaration** — a value has neither a
3044
+ * header nor an address, at any position. (`TS6395`.)
3045
+ * - **`@unmanaged` over an `@inline` declaration**, *except* where the use
3046
+ * supplies an address: `changetype`'s type argument (the operand supplies
3047
+ * it) and a parameter (the caller supplies it). Those two windows are
3048
+ * `allowInlineView` and `allowInlineViewParam`, and they are the whole
3049
+ * difference between a view and a claim. Every other position — a return
3050
+ * type, a local, a field — still has nothing to lend. (`TS6395`.)
2991
3051
  *
2992
3052
  * Everything else is left to the emitters: `@unmanaged` over `@managed` is
2993
3053
  * the identity cell (10.0a), `@inline` over a pointer declaration is the
@@ -3625,6 +3685,14 @@ declare module "types:tensionscript/src/program" {
3625
3685
  function fromUnaryPostfixToken(token: Token): OperatorKind;
3626
3686
  }
3627
3687
  /** Represents an AssemblyScript program. */
3688
+ /** How many WASM slots a parameter binding consumed — see
3689
+ * `Program#bindSroaParameterLeaves`. A one-field wrapper because this compiler
3690
+ * reports the count and the caller advances past it; a bare `i32` return would
3691
+ * be the same information with no name at the call site. */
3692
+ export class BindResult {
3693
+ leafCount: number;
3694
+ constructor(leafCount: number);
3695
+ }
3628
3696
  export class Program extends DiagnosticEmitter {
3629
3697
  /** Compiler options. */
3630
3698
  options: Options;
@@ -4341,6 +4409,17 @@ declare module "types:tensionscript/src/program" {
4341
4409
  * therefore cannot alias.
4342
4410
  */
4343
4411
  fieldLocals: Map<string, Local> | null;
4412
+ /**
4413
+ * Whether this local is a **view parameter**: `a: @unmanaged T` where `T` is
4414
+ * an inline type.
4415
+ *
4416
+ * Its `type` is still the inline record, because that is what makes `a.field`
4417
+ * resolve — every use of `T` shares one `Type`. Its *storage* is the one `i32`
4418
+ * WASM parameter holding the caller's address, which is why a field read goes
4419
+ * through `load` at the field's offset rather than through `fieldLocals`
4420
+ * (there are none: a view has no per-field locals to copy into).
4421
+ */
4422
+ isViewParam: boolean;
4344
4423
  /** Constructs a new local variable. */
4345
4424
  constructor(
4346
4425
  /** Simple name. */
@@ -4452,6 +4531,20 @@ declare module "types:tensionscript/src/program" {
4452
4531
  nextInlineId: number;
4453
4532
  /** Counting id of anonymous inner functions. */
4454
4533
  nextAnonymousId: number;
4534
+ /**
4535
+ * Binds an `@inline struct` parameter's **leaves** to the WASM parameters that
4536
+ * carry them, building the `fieldLocals` tree a read path walks.
4537
+ *
4538
+ * `localIndex` is the index of the parameter's first WASM slot; the walk
4539
+ * consumes one slot per leaf in the same depth-first order
4540
+ * `Signature.leafTypesOf` declares and the caller pushes operands in. Returns
4541
+ * how many slots were consumed, so the caller advances past them.
4542
+ *
4543
+ * A nested field gets a placeholder `Local` (index `-1`) carrying its own map,
4544
+ * exactly as `fillSroaFieldLocals` builds one for a local — the tree shape is
4545
+ * one structure regardless of where the leaves' storage came from.
4546
+ */
4547
+ bindSroaParameterLeaves(type: Type, path: string, into: Map<string, Local>, localIndex: number, flow: Flow): BindResult;
4455
4548
  /** Constructs a new concrete function. */
4456
4549
  constructor(
4457
4550
  /** Name incl. type parameters, i.e. `foo<i32>`. */
@@ -5159,6 +5252,21 @@ declare module "types:tensionscript/src/types" {
5159
5252
  * all of them.
5160
5253
  */
5161
5254
  static wasmParamCountOf(type: Type): number;
5255
+ /**
5256
+ * Appends the **leaf** types of an `@inline struct`, in declaration order,
5257
+ * depth first.
5258
+ *
5259
+ * A leaf is a field that occupies one WASM local: a scalar or a reference. A
5260
+ * field whose type is itself an `@inline struct` is not a leaf — it is several
5261
+ * locals behind a map — so the walk recurses into it. This is the type-level
5262
+ * twin of the `fieldLocals` tree the compiler builds
5263
+ * (`Compiler#fillSroaFieldLocals`), and the two must agree in **order** as
5264
+ * well as count: the callee binds WASM parameter *k* to the *k*th leaf, and
5265
+ * the caller pushes operands in the same walk.
5266
+ */
5267
+ static leafTypesOf(type: Type, out: Type[]): void;
5268
+ /** The number of leaf locals an `@inline struct` occupies. */
5269
+ static leafCountOf(type: Type): number;
5162
5270
  /**
5163
5271
  * How many WASM operands **this signature** spends on source parameter
5164
5272
  * `sourceIndex`.
@@ -5175,6 +5283,18 @@ declare module "types:tensionscript/src/types" {
5175
5283
  * the same source parameter.
5176
5284
  */
5177
5285
  wasmParamSlotCountOf(sourceIndex: number): number;
5286
+ /**
5287
+ * Whether source parameter `sourceIndex` is a **view**: `@unmanaged` at the
5288
+ * declaration over a type that is an `@inline struct`.
5289
+ *
5290
+ * The type still says *value* — every use of `MyStruct` shares one `Type`, and
5291
+ * that is what makes a member lookup work on the parameter — while the model
5292
+ * says this use is an address. One `i32` slot, no field locals, a load at the
5293
+ * field's offset: the same crossing an `@unmanaged struct` parameter already
5294
+ * takes, with the model recorded at the declaration instead of on a pointer
5295
+ * type.
5296
+ */
5297
+ isViewParam(sourceIndex: number): boolean;
5178
5298
  /**
5179
5299
  * Whether source parameter `sourceIndex` **crosses by value** — one `i32`
5180
5300
  * address instead of one WASM operand per field.
@@ -5188,8 +5308,12 @@ declare module "types:tensionscript/src/types" {
5188
5308
  * address, and the override asks for a copy of what is there — the same
5189
5309
  * copy, read from memory instead of from SROA locals.
5190
5310
  *
5191
- * The reverse is not a thing: `@unmanaged`/`@managed` over an `@inline`
5192
- * declaration is refused (`TS6395`), because a value has no address to lend.
5311
+ * The reverse is partly a thing now. `@unmanaged` over an `@inline`
5312
+ * declaration is legal where the use supplies an address — a parameter (a
5313
+ * view parameter, `isViewParam`) or `changetype`'s type argument — and a view
5314
+ * parameter crosses as a pointer, so it is asked before this predicate. Every
5315
+ * other cell still refuses (`TS6395`), and `@managed` over `@inline` refuses
5316
+ * at every position: a value has no GC header and no address to lend.
5193
5317
  */
5194
5318
  crossesByValueParam(sourceIndex: number): boolean;
5195
5319
  /**
@@ -5212,9 +5336,17 @@ declare module "types:tensionscript/src/types" {
5212
5336
  get byValPointerParams(): boolean;
5213
5337
  /** Whether `type` is an `@inline struct`. */
5214
5338
  static isInlineStructRef(type: Type): boolean;
5215
- /** The number of fields an `@inline struct` has (0 for a record with none).
5216
- * Distinct from `wasmParamCountOf`, which cannot express "one field" and
5217
- * "one operand" differently. */
5339
+ /**
5340
+ * How many **WASM slots** an `@inline struct` spends — its leaf count.
5341
+ *
5342
+ * Leaf count, not direct-field count: a nested inline field is several locals,
5343
+ * so `Outer1 { a: u32; inner: Inner{x,y} }` is 3, not 2. A record with no
5344
+ * members is 0.
5345
+ *
5346
+ * Callers that made sense of "direct fields" are listed in the Phase C audit
5347
+ * (`docs`); the one place that genuinely needs the direct count is layout, and
5348
+ * layout reads `members` itself rather than asking this.
5349
+ */
5218
5350
  static fieldCountOf(type: Type): number;
5219
5351
  /**
5220
5352
  * Whether a call to this signature passes a hidden destination pointer.
@@ -5377,6 +5509,7 @@ declare module "types:tensionscript/src/builtins" {
5377
5509
  const select = "~lib/builtins/select";
5378
5510
  const unreachable = "~lib/builtins/unreachable";
5379
5511
  const changetype = "~lib/builtins/changetype";
5512
+ const copyInto = "~lib/builtins/copyInto";
5380
5513
  const assert = "~lib/builtins/assert";
5381
5514
  const call_indirect = "~lib/builtins/call_indirect";
5382
5515
  const unchecked = "~lib/builtins/unchecked";
@@ -9811,7 +9944,7 @@ declare module "types:tensionscript/src/compiler" {
9811
9944
  import { Range, DiagnosticEmitter } from "types:tensionscript/src/diagnostics";
9812
9945
  import { Module, MemorySegment, ExpressionRef, TypeRef, GlobalRef } from "types:tensionscript/src/module";
9813
9946
  import { Feature, Target, Runtime } from "types:tensionscript/src/common";
9814
- import { Program, Class, Element, DeclaredElement, Enum, Function, Global, Property, VariableLikeElement, File } from "types:tensionscript/src/program";
9947
+ import { Program, Class, Element, DeclaredElement, Enum, Function, Global, Local, Property, VariableLikeElement, File } from "types:tensionscript/src/program";
9815
9948
  import { Flow, ConditionKind } from "types:tensionscript/src/flow";
9816
9949
  import { Resolver } from "types:tensionscript/src/resolver";
9817
9950
  import { Node, FunctionTypeNode, Statement, Expression } from "types:tensionscript/src/ast";
@@ -10297,6 +10430,18 @@ declare module "types:tensionscript/src/compiler" {
10297
10430
  private needToStack;
10298
10431
  /** Marks managed call operands for the shadow stack. */
10299
10432
  private operandsTostack;
10433
+ /**
10434
+ * Checks that the operands about to be passed match the WASM arity the callee
10435
+ * declares, and reports a clean diagnostic when they do not.
10436
+ *
10437
+ * The invariant is maintained by the default-argument filling in
10438
+ * `makeCallDirect`; this guard exists because when that filling misses — as it
10439
+ * did for an sret callee with an omitted optional argument — the mismatch
10440
+ * reached the WASM validator as `call* param number must match`, which names a
10441
+ * binaryen rule and never mentions the call that broke it. A wrong arity is a
10442
+ * compiler bug, so it should say so at the call site.
10443
+ */
10444
+ private checkCallArity;
10300
10445
  /** Creates a direct call to the specified function. */
10301
10446
  makeCallDirect(instance: Function, operands: ExpressionRef[] | null, reportNode: Node, immediatelyDropped?: boolean): ExpressionRef;
10302
10447
  /** Compiles an indirect call to a first-class function. */
@@ -10474,11 +10619,27 @@ declare module "types:tensionscript/src/compiler" {
10474
10619
  /**
10475
10620
  * The SROA local an expression names, or `null`.
10476
10621
  *
10477
- * Only a bare identifier can be one: `p.x.y` where `x` is itself an inline
10478
- * struct cannot happen this phase (a nested field is refused at declaration),
10479
- * so the receiver of a field access is either an SROA local or an ordinary
10480
- * expression that has an address.
10622
+ * The receiver is either an SROA local (base identifier) or a chain of field
10623
+ * accesses into one (`o.inner` in `o.inner.x`). The chain is walked from the
10624
+ * base outward, one hop per `fieldLocals` lookup: a nested inline field is
10625
+ * entered through the placeholder `Local` its creation installed
10626
+ * (`fillSroaFieldLocals`), so the walk and the tree are one structure rather
10627
+ * than two that could disagree.
10628
+ *
10629
+ * Returns the `Local` the final hop resolved to, or `null` when any step does
10630
+ * not hold — a non-local base, a field with no entry, or a leaf reached before
10631
+ * the chain ends. `null` is not an error here: the caller falls through to the
10632
+ * ordinary address paths, which refuse a value with no address.
10481
10633
  */
10634
+ /**
10635
+ * Pushes one operand per **leaf** of a `fieldLocals` tree, depth first.
10636
+ *
10637
+ * Shared by the call site (`expandSroaArgument`) so the operand order is the
10638
+ * one `Signature.leafTypesOf` declares and the binder indexes into — three
10639
+ * walks, one order. A nested field's entry is a placeholder (index `-1`)
10640
+ * carrying its own map, so the walk descends through it.
10641
+ */
10642
+ private pushSroaLeafOperands;
10482
10643
  private resolveSroaReceiver;
10483
10644
  /** Size of the static call-temp region, in bytes. 4 KB is 256 slots at the
10484
10645
  * 16-byte fixture record size. Overflow aborts (see `makeSretCallBlock`);
@@ -10568,6 +10729,15 @@ declare module "types:tensionscript/src/compiler" {
10568
10729
  /** `base + mark + extra`, freshly built. Callers must not share the node:
10569
10730
  * Binaryen's passes assume a single parent per expression. */
10570
10731
  private makeSretAddressPlus;
10732
+ /**
10733
+ * Stores a by-value argument's leaves into the static call-temp region.
10734
+ *
10735
+ * The same tree walk as `copyInto` (`emitSroaStores`) and `copySroaValue`:
10736
+ * leaves become stores at `tempAddress + field offset`, a nested field is
10737
+ * descended into. Keeping one recursion is what makes a nested value cross a
10738
+ * host boundary at the layout the C side expects.
10739
+ */
10740
+ emitTempArgumentLeaves(type: Type, fieldLocals: Map<string, Local>, base: number, markLocal: Local, baseOffset: number, stmts: ExpressionRef[]): void;
10571
10741
  /**
10572
10742
  * Materialises one `@inline struct` argument of an `@external` call on the
10573
10743
  * static call-temp stack and returns the address to pass.
@@ -10638,6 +10808,93 @@ declare module "types:tensionscript/src/compiler" {
10638
10808
  * Returns true when the declaration was handled here (the caller must not fall
10639
10809
  * through to the ordinary local path).
10640
10810
  */
10811
+ /**
10812
+ * Fills `into` with one entry per field of an `@inline struct` value.
10813
+ *
10814
+ * A **leaf** field (scalar, or a reference) gets one WASM local, named
10815
+ * `<path>$<field>` — a synthetic name keeps it out of user scope, so nothing
10816
+ * can look one up by accident.
10817
+ *
10818
+ * A field whose type is itself an `@inline struct` is **not a leaf**: it is
10819
+ * recursed into, and its entry is a placeholder `Local` (index `-1`) carrying
10820
+ * its own map. That makes `fieldLocals` a **tree** whose shape is the value's
10821
+ * nesting, which is what lets a read path walk `o.inner.x` a hop at a time
10822
+ * without a second representation. The placeholder is never `local.get`-ed:
10823
+ * the bare-read guard refuses a value read and the receiver walk descends to
10824
+ * a leaf before emitting anything.
10825
+ *
10826
+ * Returns `false` when a field was refused, having reported why. The refusal
10827
+ * is per **leaf**, so a nested value inherits exactly the rules the flat one
10828
+ * has — a `T[N]` field or a GC-reference field is refused at any depth.
10829
+ */
10830
+ private fillSroaFieldLocals;
10831
+ /**
10832
+ * Copies one SROA value's leaves into another's, following the tree.
10833
+ *
10834
+ * `from` and `to` are the two `fieldLocals` maps — the same shape
10835
+ * `fillSroaFieldLocals` builds, so a nested field is a placeholder on both
10836
+ * sides and the recursion descends through it rather than trying to move a
10837
+ * value that has no single representation.
10838
+ *
10839
+ * This is what makes `let q = p` and `q = p` **copies** rather than aliases:
10840
+ * one `local.set` per leaf, so a later write to `q` cannot be seen through
10841
+ * `p`. Both sides come from this compiler's own maps, so there is no aliasing
10842
+ * question to answer — the leaves are distinct locals by construction.
10843
+ */
10844
+ private copySroaValue;
10845
+ /**
10846
+ * Stores a `fieldLocals` tree's leaves into the hidden destination slot at
10847
+ * `destIndex`, one store per leaf.
10848
+ *
10849
+ * The third destination shape for the same recursion: `emitSroaStores` writes
10850
+ * to a compiled `usize`, `emitTempArgumentLeaves` to a call-temp address, and
10851
+ * this one to a **parameter** — the sret slot a `return p` fills. The address
10852
+ * is a fresh `local.get` per store, because Binaryen's passes assume one
10853
+ * parent per node.
10854
+ */
10855
+ emitSroaStoresToLocal(type: Type, fieldLocals: Map<string, Local>, destIndex: number, baseOffset: number, stmts: ExpressionRef[]): void;
10856
+ /**
10857
+ * Zeroes every **leaf** of an `@inline struct` in the destination slot.
10858
+ *
10859
+ * `return new P()` has no local to copy from — the value is all zeroes — but
10860
+ * the slot is stack space that a previous sret call may have filled, so the
10861
+ * bytes still have to be written. Walking the type rather than the direct
10862
+ * fields is what zeroes a nested field's leaves: measured before this,
10863
+ * `return new Outer1()` with `Inner{x,y}` stored only offset 0 and left
10864
+ * offsets 4 and 8 holding whatever was there.
10865
+ */
10866
+ emitSroaZerosToLocal(type: Type, destIndex: number, baseOffset: number, stmts: ExpressionRef[]): void;
10867
+ /**
10868
+ * Loads an `@inline struct`'s leaves out of the sret slot into a target's
10869
+ * field locals, one load per leaf.
10870
+ *
10871
+ * The mirror of {@link emitSroaStoresToLocal}: `let q = make()` reads the slot
10872
+ * back into the leaf locals a read path walks. A fresh slot address per load,
10873
+ * for the same one-parent-per-node reason.
10874
+ */
10875
+ emitSretLoadsInto(type: Type, fieldLocals: Map<string, Local>, base: number, markLocal: Local, baseOffset: number, stmts: ExpressionRef[]): void;
10876
+ /**
10877
+ * The `fieldLocals` tree behind an SROA-tracked expression, or `null`.
10878
+ *
10879
+ * The public face of {@link resolveSroaReceiver} for code outside this class —
10880
+ * today only the `copyInto` builtin, which needs the *tree* (to store its
10881
+ * leaves) rather than a single receiver.
10882
+ */
10883
+ sroaTreeOf(expression: Expression): Map<string, Local> | null;
10884
+ /**
10885
+ * Stores an inline value's leaves at `dest + offset`.
10886
+ *
10887
+ * The third leaf consumer, beside `copySroaValue` (local-to-local) and the
10888
+ * read path (local-to-stack): same tree, same recursion, an expression
10889
+ * reference instead of a destination map. The offsets come from the **type**
10890
+ * (`property.memoryOffset`, the layout the C side sees), so what lands in
10891
+ * memory is the wire layout, not a packing of the locals.
10892
+ *
10893
+ * Leaves whose local is missing are skipped rather than stored as `-1`: a
10894
+ * field refused at declaration was never part of the value (`isSroaFieldType`
10895
+ * has already reported why), and the caller has been told.
10896
+ */
10897
+ emitSroaStores(type: Type, fieldLocals: Map<string, Local>, dest: ExpressionRef, baseOffset: number, stmts: ExpressionRef[]): void;
10641
10898
  private compileSroaLocal;
10642
10899
  /**
10643
10900
  * The instance fields of an `@inline struct`, in declaration order, or `null`
package/dist/asc.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
7
  var le=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var cn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var nn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pe(t))!Ve.call(e,s)&&s!==n&&le(e,s,{get:()=>t[s],enumerable:!(r=Me(t,s))||r.enumerable});return e},Dn=(e,t,n)=>(se(e,t,"default"),n&&se(n,t,"default"));var ue={};nn(ue,{promises:()=>je});var je,fe=cn(()=>{"use strict";je={}});var ce={};nn(ce,{createRequire:()=>Ge});function Ge(){return function(t){throw new Error(`Cannot find module: '${t}'`)}}var de=cn(()=>{"use strict"});var kn={};nn(kn,{argv:()=>Ke,cwd:()=>In,exit:()=>qe,hrtime:()=>Ye,platform:()=>Xe,umask:()=>He});function In(){return"."}function He(){return 0}function qe(e=0){throw Error(`exit ${e}`)}function Ye(e){var t=We.call(xe),n=Math.floor(t*.001),r=Math.floor(t*1e6-n*1e9);return e&&(n-=e[0],r-=e[1],r<0&&(n--,r+=1e9)),[n,r]}var Xe,Ke,xe,We,On=cn(()=>{"use strict";Xe="linux";Ke=[];xe=globalThis.performance||{},We=xe.now||function(){return new Date().getTime()}});var Rn={};nn(Rn,{basename:()=>et,delimiter:()=>at,dirname:()=>nt,extname:()=>tt,format:()=>it,isAbsolute:()=>Ze,join:()=>Je,normalize:()=>he,parse:()=>rt,relative:()=>Qe,resolve:()=>dn,sep:()=>Ln,win32:()=>ot});function j(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function pe(e,t){for(var n="",r=0,s=-1,o=0,f,c=0;c<=e.length;++c){if(c<e.length)f=e.charCodeAt(c);else{if(f===47)break;f=47}if(f===47){if(!(s===c-1||o===1))if(s!==c-1&&o===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var p=n.lastIndexOf("/");if(p!==n.length-1){p===-1?(n="",r=0):(n=n.slice(0,p),r=n.length-1-n.lastIndexOf("/")),s=c,o=0;continue}}else if(n.length===2||n.length===1){n="",r=0,s=c,o=0;continue}}t&&(n.length>0?n+="/..":n="..",r=2)}else n.length>0?n+="/"+e.slice(s+1,c):n=e.slice(s+1,c),r=c-s-1;s=c,o=0}else f===46&&o!==-1?++o:o=-1}return n}function $e(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+e+r:r}function dn(){for(var e="",t=!1,n,r=arguments.length-1;r>=-1&&!t;r--){var s;r>=0?s=arguments[r]:(n===void 0&&(n=In()),s=n),j(s),s.length!==0&&(e=s+"/"+e,t=s.charCodeAt(0)===47)}return e=pe(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."}function he(e){if(j(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=pe(e,!t),e.length===0&&!t&&(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e}function Ze(e){return j(e),e.length>0&&e.charCodeAt(0)===47}function Je(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];j(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":he(e)}function Qe(e,t){if(j(e),j(t),e===t||(e=dn(e),t=dn(t),e===t))return"";if(e===".")return t;for(var n=1;n<e.length&&e.charCodeAt(n)===47;++n);for(var r=e.length,s=r-n,o=1;o<t.length&&t.charCodeAt(o)===47;++o);for(var f=t.length,c=f-o,p=s<c?s:c,b=-1,d=0;d<=p;++d){if(d===p){if(c>p){if(t.charCodeAt(o+d)===47)return t.slice(o+d+1);if(d===0)return t.slice(o+d)}else s>p&&(e.charCodeAt(n+d)===47?b=d:d===0&&(b=0));break}var g=e.charCodeAt(n+d),y=t.charCodeAt(o+d);if(g!==y)break;g===47&&(b=d)}var m="";for(d=n+b+1;d<=r;++d)(d===r||e.charCodeAt(d)===47)&&(m.length===0?m+="..":m+="/..");return m.length>0?m+t.slice(o+b):(o+=b,t.charCodeAt(o)===47&&++o,t.slice(o))}function nt(e){if(j(e),e.length===0)return".";for(var t=e.charCodeAt(0),n=t===47,r=-1,s=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!s){r=o;break}}else s=!1;return r===-1?n?"/":".":n&&r===1?"//":e.slice(0,r)}function et(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');j(e);var n=0,r=-1,s=!0,o;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var f=t.length-1,c=-1;for(o=e.length-1;o>=0;--o){var p=e.charCodeAt(o);if(p===47){if(!s){n=o+1;break}}else c===-1&&(s=!1,c=o+1),f>=0&&(p===t.charCodeAt(f)?--f===-1&&(r=o):(f=-1,r=c))}return n===r?r=c:r===-1&&(r=e.length),e.slice(n,r)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!s){n=o+1;break}}else r===-1&&(s=!1,r=o+1);return r===-1?"":e.slice(n,r)}}function tt(e){j(e);for(var t=-1,n=0,r=-1,s=!0,o=0,f=e.length-1;f>=0;--f){var c=e.charCodeAt(f);if(c===47){if(!s){n=f+1;break}continue}r===-1&&(s=!1,r=f+1),c===46?t===-1?t=f:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||r===-1||o===0||o===1&&t===r-1&&t===n+1?"":e.slice(t,r)}function it(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return $e("/",e)}function rt(e){j(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),r=n===47,s;r?(t.root="/",s=1):s=0;for(var o=-1,f=0,c=-1,p=!0,b=e.length-1,d=0;b>=s;--b){if(n=e.charCodeAt(b),n===47){if(!p){f=b+1;break}continue}c===-1&&(p=!1,c=b+1),n===46?o===-1?o=b:d!==1&&(d=1):o!==-1&&(d=-1)}return o===-1||c===-1||d===0||d===1&&o===c-1&&o===f+1?c!==-1&&(f===0&&r?t.base=t.name=e.slice(1,c):t.base=t.name=e.slice(f,c)):(f===0&&r?(t.name=e.slice(1,o),t.base=e.slice(1,c)):(t.name=e.slice(f,o),t.base=e.slice(f,c)),t.ext=e.slice(o,c)),f>0?t.dir=e.slice(0,f-1):r&&(t.dir="/"),t}var Ln,at,ot,Nn=cn(()=>{"use strict";On();Ln="/",at=":",ot=null});var ge={};nn(ge,{pathToFileURL:()=>lt});function st(e){return e.replace(/%/g,"%25").replace(/\\/g,"%5C").replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/\t/g,"%09")}function lt(e){let t=dn(e);e.charCodeAt(e.length-1)===47&&t[t.length-1]!==Ln&&(t+="/");let n=new URL("file://");return n.pathname=st(t),n}var me=cn(()=>{"use strict";Nn()});var Wn={};nn(Wn,{Stats:()=>Cn,checkDiagnostics:()=>Tn,compileString:()=>Dt,configToArguments:()=>qn,createMemoryStream:()=>Hn,default:()=>Wn,defaultOptimizeLevel:()=>we,defaultShrinkLevel:()=>Se,definitionFiles:()=>St,libraryFiles:()=>G,libraryPrefix:()=>L,main:()=>De,options:()=>wt,tscOptions:()=>It,version:()=>Xn});var ut=Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]",X,sn,v,P,xn;ut?(X=await import("fs"),sn=await import("module"),v=await import("path"),P=globalThis.process,xn=await import("url")):(X=await Promise.resolve().then(()=>(fe(),ue)),sn=await Promise.resolve().then(()=>(de(),ce)),v=await Promise.resolve().then(()=>(Nn(),Rn)),P=await Promise.resolve().then(()=>(On(),kn)),xn=await Promise.resolve().then(()=>(me(),ge)));var En=typeof process<"u"&&process||{},ft=En.env&&"CI"in En.env,ct="\x1B[90m",dt="\x1B[91m",xt="\x1B[92m",pt="\x1B[93m",ht="\x1B[94m",gt="\x1B[95m",mt="\x1B[96m",bt="\x1B[97m",W="\x1B[0m",en=class{constructor(t){this.stream=t,this.enabled=!!(this.stream&&this.stream.isTTY||ft)}gray(t){return this.enabled?ct+t+W:t}red(t){return this.enabled?dt+t+W:t}green(t){return this.enabled?xt+t+W:t}yellow(t){return this.enabled?pt+t+W:t}blue(t){return this.enabled?ht+t+W:t}magenta(t){return this.enabled?gt+t+W:t}cyan(t){return this.enabled?mt+t+W:t}white(t){return this.enabled?bt+t+W:t}},An=new en(En.stdout),Lt=new en(En.stderr);function yt(e){for(var t=0,n=0,r=e.length;n<r;++n){let s=e.charCodeAt(n);s<128?t+=1:s<2048?t+=2:(s&64512)===55296&&n+1<r&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3}return t}function Ft(e,t,n){var r=n-t;if(r<1)return"";for(var s=null,o=[],f=0,c;t<n;)c=e[t++],c<128?o[f++]=c:c>191&&c<224?o[f++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,o[f++]=55296+(c>>10),o[f++]=56320+(c&1023)):o[f++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,f>=8192&&((s||(s=[])).push(String.fromCharCode(...o)),f=0);return s?(f&&s.push(String.fromCharCode(...o.slice(0,f))),s.join("")):String.fromCharCode(...o.slice(0,f))}function vt(e,t,n){for(var r=n,s=0,o=e.length;s<o;++s){let f=e.charCodeAt(s),c;f<128?t[n++]=f:f<2048?(t[n++]=f>>6|192,t[n++]=f&63|128):(f&64512)===55296&&s+1<o&&((c=e.charCodeAt(s+1))&64512)===56320?(f=65536+((f&1023)<<10)+(c&1023),++s,t[n++]=f>>18|240,t[n++]=f>>12&63|128,t[n++]=f>>6&63|128,t[n++]=f&63|128):(t[n++]=f>>12|224,t[n++]=f>>6&63|128,t[n++]=f&63|128)}return n-r}var _n={length:yt,read:Ft,write:vt};var be=sn.createRequire(import.meta.url);function Fe(e,t,n=!0){var r={},s=[],o=[],f=[],c={};Object.keys(t).forEach(d=>{if(!d.startsWith(" ")){var g=t[d];g.alias!=null&&(typeof g.alias=="string"?c[g.alias]=d:Array.isArray(g.alias)&&g.alias.forEach(y=>c[y]=d)),n&&g.default!=null&&(r[d]=g.default)}});for(var p=0,b=(e=e.slice()).length;p<b;++p){let d=e[p];if(d=="--"){++p;break}let g=/^(?:(-\w)(?:=(.*))?|(--\w{2,})(?:=(.*))?)$/.exec(d),y,m;if(g)t[d]?y=t[m=d]:g[1]!=null?(y=t[m=c[g[1].substring(1)]],y&&g[2]!=null&&(e[p--]=g[2])):g[3]!=null&&(y=t[m=g[3].substring(2)],y&&g[4]!=null&&(e[p--]=g[4]));else if(d.charCodeAt(0)==45)y=t[m=d];else{o.push(d);continue}if(y)if(y.value)Object.keys(y.value).forEach(a=>r[a]=y.value[a]);else if(y.type==null||y.type==="b")r[m]=!0;else if(p+1<e.length&&e[p+1].charCodeAt(0)!=45)switch(y.type){case"i":r[m]=parseInt(e[++p],10);break;case"I":r[m]=(r[m]||[]).concat(parseInt(e[++p],10));break;case"f":r[m]=parseFloat(e[++p]);break;case"F":r[m]=(r[m]||[]).concat(parseFloat(e[++p]));break;case"s":r[m]=String(e[++p]);break;case"S":r[m]=(r[m]||[]).concat(e[++p].split(","));break;default:s.push(d),--p}else switch(y.type){case"i":case"f":r[m]=y.default||0;break;case"s":r[m]=y.default||"";break;case"I":case"F":case"S":r[m]=y.default||[];break;default:s.push(d)}else s.push(d)}for(;p<b;)f.push(e[p++]);return n&&Mn(t,r),{options:r,unknown:s,arguments:o,trailing:f}}function ve(e,t){t||(t={});var n=t.indent||2,r=t.padding||24,s=t.eol||`
8
- `,o={},f=[];Object.keys(e).forEach(b=>{var d=e[b];if(d.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,d.alias&&(g+=", -"+d.alias);g.length<r;)g+=" ";var y;!t.noCategories&&d.category?(y=o[d.category])||(o[d.category]=y=[]):y=f,Array.isArray(d.description)?y.push(g+d.description[0]+d.description.slice(1).map(m=>{for(let a=0;a<r;++a)m=" "+m;return s+m}).join("")):y.push(g+d.description)}});var c=[],p=!1;return Object.keys(o).forEach(b=>{p=!0,c.push(s+" "+An.gray(b)+s),c.push(o[b].join(s))}),p&&f.length&&c.push(s+" "+An.gray("Other")+s),c.push(f.join(s)),c.join(s)}function ye(e,t){if(e!=null)switch(t){case void 0:case"b":return!!e;case"i":return Math.trunc(e)||0;case"f":return Number(e)||0;case"s":return e===!0?"":e===!1?null:String(e);case"I":return Array.isArray(e)||(e=[e]),e.map(n=>Math.trunc(n)||0);case"F":return Array.isArray(e)||(e=[e]),e.map(n=>Number(n)||0);case"S":return Array.isArray(e)||(e=[e]),e.map(String)}}function Un(e,t,n,r){let s={};for(let[o,{type:f,mutuallyExclusive:c,isPath:p,useNodeResolution:b,cliOnly:d}]of Object.entries(e)){let g=ye(t[o],f),y=ye(n[o],f);if(g==null){if(y!=null){if(d)continue;if(Array.isArray(y)){let m;p&&(y=y.map(a=>tn(a,r,b))),c!=null&&(m=t[c])?s[o]=y.filter(a=>!m.includes(a)):s[o]=y.slice()}else p&&(y=tn(y,r,b)),s[o]=y}}else if(y==null)Array.isArray(g)?s[o]=g.slice():s[o]=g;else if(Array.isArray(g)){if(d){s[o]=g.slice();continue}let m;p&&(y=y.map(a=>tn(a,r,b))),c!=null&&(m=t[c])?s[o]=[...g,...y.filter(a=>!g.includes(a)&&!m.includes(a))]:s[o]=[...g,...y.filter(a=>!g.includes(a))]}else s[o]=g}return s}function Et(e){let t=v.parse(e);return t.root||(t.root="./"),v.format(t)}function tn(e,t,n=!1){return v.isAbsolute(e)?e:n&&!e.startsWith(".")&&be.resolve?be.resolve(e,{paths:[t]}):Et(v.join(t,e))}function Mn(e,t){for(let[n,{default:r}]of Object.entries(e))t[n]==null&&r!=null&&(t[n]=r)}var Ee="0.11.0",Y={version:{category:"General",description:"Prints just the compiler's version and exits.",type:"b",alias:"v"},help:{category:"General",description:"Prints this message and exits.",type:"b",alias:"h"},config:{category:"General",description:"Configuration file to apply. CLI arguments take precedence.",type:"s",cliOnly:!0},target:{category:"General",description:"Configuration file target to use. Defaults to 'release'.",type:"s",cliOnly:!0},optimize:{category:"Optimization",description:["Optimizes the module. Typical shorthands are:",""," Default optimizations -O"," Make a release build -O --noAssert"," Make a debug build --debug"," Optimize for speed -Ospeed"," Optimize for size -Osize",""],type:"b",alias:"O"},optimizeLevel:{category:"Optimization",description:"How much to focus on optimizing code. [0-3]",type:"i"},shrinkLevel:{category:"Optimization",description:"How much to focus on shrinking code size. [0-2, s=1, z=2]",type:"i"},converge:{category:"Optimization",description:"Re-optimizes until no further improvements can be made.",type:"b",default:!1},noAssert:{category:"Optimization",description:"Replaces assertions with just their value without trapping.",type:"b",default:!1},outFile:{category:"Output",description:"Specifies the WebAssembly output file (.wasm).",type:"s",alias:"o",isPath:!0},textFile:{category:"Output",description:"Specifies the WebAssembly text output file (.wat).",type:"s",alias:"t",isPath:!0},bindings:{category:"Output",description:["Specifies the bindings to generate (.js + .d.ts).",""," esm JavaScript bindings & typings for ESM integration."," raw Like esm, but exports just the instantiate function."," Useful where modules are meant to be instantiated"," multiple times or non-ESM imports must be provided."],type:"S",alias:"b"},sourceMap:{category:"Debugging",description:["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],type:"s"},uncheckedBehavior:{category:"Debugging",description:["Changes the behavior of unchecked() expressions.","Using this option can potentially cause breakage.",""," default The default behavior: unchecked operations are"," only used inside of unchecked()."," never Unchecked operations are never used, even when"," inside of unchecked()."," always Unchecked operations are always used if possible,"," whether or not unchecked() is used."],type:"s",default:"default"},debug:{category:"Debugging",description:"Enables debug information in emitted binaries.",type:"b",default:!1},importMemory:{category:"Features",description:"Imports the memory from 'env.memory'.",type:"b",default:!1},noExportMemory:{category:"Features",description:"Does not export the memory as 'memory'.",type:"b",default:!1},initialMemory:{category:"Features",description:"Sets the initial memory size in pages.",type:"i",default:0},maximumMemory:{category:"Features",description:"Sets the maximum memory size in pages.",type:"i",default:0},sharedMemory:{category:"Features",description:"Declare memory as shared. Requires maximumMemory.",type:"b",default:!1},zeroFilledMemory:{category:"Features",description:"Assume imported memory is zeroed. Requires importMemory.",type:"b",default:!1},importTable:{category:"Features",description:"Imports the function table from 'env.table'.",type:"b",default:!1},exportTable:{category:"Features",description:"Exports the function table as 'table'.",type:"b",default:!1},exportStart:{category:"Features",description:["Exports the start function using the specified name instead","of calling it implicitly. Useful to obtain the exported memory","before executing any code accessing it."],type:"s"},runtime:{category:"Features",description:["Specifies the runtime variant to include in the program.",""," incremental TLSF + incremental GC (default)"," minimal TLSF + lightweight GC invoked externally"," stub Minimal runtime stub (never frees)"," ... Path to a custom runtime implementation",""],type:"s",default:"incremental"},exportRuntime:{category:"Features",description:["Always exports the runtime helpers (__new, __collect, __pin etc.).","Automatically determined when generation of --bindings is enabled."],type:"b",default:!1},stackSize:{category:"Features",description:["Overrides the stack size. Only relevant for incremental GC","or when using a custom runtime that requires stack space.","Defaults to 0 without and to 32768 with incremental GC."],default:0,type:"i"},enable:{category:"Features",description:["Enables WebAssembly features being disabled by default.",""," threads Threading and atomic operations."," simd SIMD types and operations."," reference-types Reference types and operations."," gc Garbage collection (WIP)."," stringref String reference types."," relaxed-simd Relaxed SIMD operations.",""],TODO_doesNothingYet:[" exception-handling Exception handling."," tail-calls Tail call operations."," multi-value Multi value types."," memory64 Memory64 operations."," extended-const Extended const expressions."],type:"S",mutuallyExclusive:"disable"},disable:{category:"Features",description:["Disables WebAssembly features being enabled by default.",""," mutable-globals Mutable global imports and exports."," sign-extension Sign-extension operations"," nontrapping-f2i Non-trapping float to integer ops."," bulk-memory Bulk memory operations.",""],type:"S",mutuallyExclusive:"enable"},use:{category:"Features",description:["Aliases a global object under another name, e.g., to switch","the default 'Math' implementation used: --use Math=JSMath","Can also be used to introduce an integer constant."],type:"S",alias:"u"},lowMemoryLimit:{category:"Features",description:"Enforces very low (<64k) memory constraints.",default:0,type:"i"},memoryBase:{category:"Linking",description:"Sets the start offset of emitted memory segments.",type:"i",default:0},tableBase:{category:"Linking",description:"Sets the start offset of emitted table elements.",type:"i",default:0},transform:{category:"API",description:"Specifies the path to a custom transform to load.",type:"S",isPath:!0,useNodeResolution:!0},trapMode:{category:"Binaryen",description:["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],type:"s",default:"allow"},runPasses:{category:"Binaryen",description:["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],type:"s"},noValidate:{category:"Binaryen",description:"Skips validating the module using Binaryen.",type:"b",default:!1},baseDir:{description:"Specifies the base directory of input and output files.",type:"s",default:"."},noColors:{description:"Disables terminal colors.",type:"b",default:!1},noUnsafe:{description:["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],type:"b",default:!1},disableWarning:{description:["Disables warnings matching the given diagnostic code.","If no diagnostic code is given, all warnings are disabled."],type:"I"},noEmit:{description:"Performs compilation as usual but does not emit code.",type:"b",default:!1},showConfig:{description:"Print computed compiler options and exit.",type:"b",default:!1},stats:{description:"Prints statistics on I/O and compile times.",type:"b",default:!1},pedantic:{description:"Make yourself sad for no good reason.",type:"b",default:!1},lib:{description:["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],type:"S",isPath:!0},path:{description:["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an 'ascMain' entry in a package's","package.json and falls back to an inner 'assembly/' folder."],type:"S",isPath:!0},wasm:{description:"Uses the specified Wasm binary of the compiler.",type:"s"}," ...":{description:"Specifies node.js options (CLI only). See: node --help"},"-Os":{value:{optimizeLevel:0,shrinkLevel:1}},"-Oz":{value:{optimizeLevel:0,shrinkLevel:2}},"-O0":{value:{optimizeLevel:0,shrinkLevel:0}},"-O1":{value:{optimizeLevel:1,shrinkLevel:0}},"-O2":{value:{optimizeLevel:2,shrinkLevel:0}},"-O3":{value:{optimizeLevel:3,shrinkLevel:0}},"-O0s":{value:{optimizeLevel:0,shrinkLevel:1}},"-O1s":{value:{optimizeLevel:1,shrinkLevel:1}},"-O2s":{value:{optimizeLevel:2,shrinkLevel:1}},"-O3s":{value:{optimizeLevel:3,shrinkLevel:1}},"-O0z":{value:{optimizeLevel:0,shrinkLevel:2}},"-O1z":{value:{optimizeLevel:1,shrinkLevel:2}},"-O2z":{value:{optimizeLevel:2,shrinkLevel:2}},"-O3z":{value:{optimizeLevel:3,shrinkLevel:2}},"-Ospeed":{value:{optimizeLevel:3,shrinkLevel:0}},"-Osize":{value:{optimizeLevel:0,shrinkLevel:2,converge:!0}},"--measure":{value:{stats:!0}}},Ae="~lib/",_e={array:`/// <reference path="./rt/index.d.ts" />
8
+ `,o={},f=[];Object.keys(e).forEach(b=>{var d=e[b];if(d.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,d.alias&&(g+=", -"+d.alias);g.length<r;)g+=" ";var y;!t.noCategories&&d.category?(y=o[d.category])||(o[d.category]=y=[]):y=f,Array.isArray(d.description)?y.push(g+d.description[0]+d.description.slice(1).map(m=>{for(let a=0;a<r;++a)m=" "+m;return s+m}).join("")):y.push(g+d.description)}});var c=[],p=!1;return Object.keys(o).forEach(b=>{p=!0,c.push(s+" "+An.gray(b)+s),c.push(o[b].join(s))}),p&&f.length&&c.push(s+" "+An.gray("Other")+s),c.push(f.join(s)),c.join(s)}function ye(e,t){if(e!=null)switch(t){case void 0:case"b":return!!e;case"i":return Math.trunc(e)||0;case"f":return Number(e)||0;case"s":return e===!0?"":e===!1?null:String(e);case"I":return Array.isArray(e)||(e=[e]),e.map(n=>Math.trunc(n)||0);case"F":return Array.isArray(e)||(e=[e]),e.map(n=>Number(n)||0);case"S":return Array.isArray(e)||(e=[e]),e.map(String)}}function Un(e,t,n,r){let s={};for(let[o,{type:f,mutuallyExclusive:c,isPath:p,useNodeResolution:b,cliOnly:d}]of Object.entries(e)){let g=ye(t[o],f),y=ye(n[o],f);if(g==null){if(y!=null){if(d)continue;if(Array.isArray(y)){let m;p&&(y=y.map(a=>tn(a,r,b))),c!=null&&(m=t[c])?s[o]=y.filter(a=>!m.includes(a)):s[o]=y.slice()}else p&&(y=tn(y,r,b)),s[o]=y}}else if(y==null)Array.isArray(g)?s[o]=g.slice():s[o]=g;else if(Array.isArray(g)){if(d){s[o]=g.slice();continue}let m;p&&(y=y.map(a=>tn(a,r,b))),c!=null&&(m=t[c])?s[o]=[...g,...y.filter(a=>!g.includes(a)&&!m.includes(a))]:s[o]=[...g,...y.filter(a=>!g.includes(a))]}else s[o]=g}return s}function Et(e){let t=v.parse(e);return t.root||(t.root="./"),v.format(t)}function tn(e,t,n=!1){return v.isAbsolute(e)?e:n&&!e.startsWith(".")&&be.resolve?be.resolve(e,{paths:[t]}):Et(v.join(t,e))}function Mn(e,t){for(let[n,{default:r}]of Object.entries(e))t[n]==null&&r!=null&&(t[n]=r)}var Ee="0.11.2",Y={version:{category:"General",description:"Prints just the compiler's version and exits.",type:"b",alias:"v"},help:{category:"General",description:"Prints this message and exits.",type:"b",alias:"h"},config:{category:"General",description:"Configuration file to apply. CLI arguments take precedence.",type:"s",cliOnly:!0},target:{category:"General",description:"Configuration file target to use. Defaults to 'release'.",type:"s",cliOnly:!0},optimize:{category:"Optimization",description:["Optimizes the module. Typical shorthands are:",""," Default optimizations -O"," Make a release build -O --noAssert"," Make a debug build --debug"," Optimize for speed -Ospeed"," Optimize for size -Osize",""],type:"b",alias:"O"},optimizeLevel:{category:"Optimization",description:"How much to focus on optimizing code. [0-3]",type:"i"},shrinkLevel:{category:"Optimization",description:"How much to focus on shrinking code size. [0-2, s=1, z=2]",type:"i"},converge:{category:"Optimization",description:"Re-optimizes until no further improvements can be made.",type:"b",default:!1},noAssert:{category:"Optimization",description:"Replaces assertions with just their value without trapping.",type:"b",default:!1},outFile:{category:"Output",description:"Specifies the WebAssembly output file (.wasm).",type:"s",alias:"o",isPath:!0},textFile:{category:"Output",description:"Specifies the WebAssembly text output file (.wat).",type:"s",alias:"t",isPath:!0},bindings:{category:"Output",description:["Specifies the bindings to generate (.js + .d.ts).",""," esm JavaScript bindings & typings for ESM integration."," raw Like esm, but exports just the instantiate function."," Useful where modules are meant to be instantiated"," multiple times or non-ESM imports must be provided."],type:"S",alias:"b"},sourceMap:{category:"Debugging",description:["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],type:"s"},uncheckedBehavior:{category:"Debugging",description:["Changes the behavior of unchecked() expressions.","Using this option can potentially cause breakage.",""," default The default behavior: unchecked operations are"," only used inside of unchecked()."," never Unchecked operations are never used, even when"," inside of unchecked()."," always Unchecked operations are always used if possible,"," whether or not unchecked() is used."],type:"s",default:"default"},debug:{category:"Debugging",description:"Enables debug information in emitted binaries.",type:"b",default:!1},importMemory:{category:"Features",description:"Imports the memory from 'env.memory'.",type:"b",default:!1},noExportMemory:{category:"Features",description:"Does not export the memory as 'memory'.",type:"b",default:!1},initialMemory:{category:"Features",description:"Sets the initial memory size in pages.",type:"i",default:0},maximumMemory:{category:"Features",description:"Sets the maximum memory size in pages.",type:"i",default:0},sharedMemory:{category:"Features",description:"Declare memory as shared. Requires maximumMemory.",type:"b",default:!1},zeroFilledMemory:{category:"Features",description:"Assume imported memory is zeroed. Requires importMemory.",type:"b",default:!1},importTable:{category:"Features",description:"Imports the function table from 'env.table'.",type:"b",default:!1},exportTable:{category:"Features",description:"Exports the function table as 'table'.",type:"b",default:!1},exportStart:{category:"Features",description:["Exports the start function using the specified name instead","of calling it implicitly. Useful to obtain the exported memory","before executing any code accessing it."],type:"s"},runtime:{category:"Features",description:["Specifies the runtime variant to include in the program.",""," incremental TLSF + incremental GC (default)"," minimal TLSF + lightweight GC invoked externally"," stub Minimal runtime stub (never frees)"," ... Path to a custom runtime implementation",""],type:"s",default:"incremental"},exportRuntime:{category:"Features",description:["Always exports the runtime helpers (__new, __collect, __pin etc.).","Automatically determined when generation of --bindings is enabled."],type:"b",default:!1},stackSize:{category:"Features",description:["Overrides the stack size. Only relevant for incremental GC","or when using a custom runtime that requires stack space.","Defaults to 0 without and to 32768 with incremental GC."],default:0,type:"i"},enable:{category:"Features",description:["Enables WebAssembly features being disabled by default.",""," threads Threading and atomic operations."," simd SIMD types and operations."," reference-types Reference types and operations."," gc Garbage collection (WIP)."," stringref String reference types."," relaxed-simd Relaxed SIMD operations.",""],TODO_doesNothingYet:[" exception-handling Exception handling."," tail-calls Tail call operations."," multi-value Multi value types."," memory64 Memory64 operations."," extended-const Extended const expressions."],type:"S",mutuallyExclusive:"disable"},disable:{category:"Features",description:["Disables WebAssembly features being enabled by default.",""," mutable-globals Mutable global imports and exports."," sign-extension Sign-extension operations"," nontrapping-f2i Non-trapping float to integer ops."," bulk-memory Bulk memory operations.",""],type:"S",mutuallyExclusive:"enable"},use:{category:"Features",description:["Aliases a global object under another name, e.g., to switch","the default 'Math' implementation used: --use Math=JSMath","Can also be used to introduce an integer constant."],type:"S",alias:"u"},lowMemoryLimit:{category:"Features",description:"Enforces very low (<64k) memory constraints.",default:0,type:"i"},memoryBase:{category:"Linking",description:"Sets the start offset of emitted memory segments.",type:"i",default:0},tableBase:{category:"Linking",description:"Sets the start offset of emitted table elements.",type:"i",default:0},transform:{category:"API",description:"Specifies the path to a custom transform to load.",type:"S",isPath:!0,useNodeResolution:!0},trapMode:{category:"Binaryen",description:["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],type:"s",default:"allow"},runPasses:{category:"Binaryen",description:["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],type:"s"},noValidate:{category:"Binaryen",description:"Skips validating the module using Binaryen.",type:"b",default:!1},baseDir:{description:"Specifies the base directory of input and output files.",type:"s",default:"."},noColors:{description:"Disables terminal colors.",type:"b",default:!1},noUnsafe:{description:["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],type:"b",default:!1},disableWarning:{description:["Disables warnings matching the given diagnostic code.","If no diagnostic code is given, all warnings are disabled."],type:"I"},noEmit:{description:"Performs compilation as usual but does not emit code.",type:"b",default:!1},showConfig:{description:"Print computed compiler options and exit.",type:"b",default:!1},stats:{description:"Prints statistics on I/O and compile times.",type:"b",default:!1},pedantic:{description:"Make yourself sad for no good reason.",type:"b",default:!1},lib:{description:["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],type:"S",isPath:!0},path:{description:["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an 'ascMain' entry in a package's","package.json and falls back to an inner 'assembly/' folder."],type:"S",isPath:!0},wasm:{description:"Uses the specified Wasm binary of the compiler.",type:"s"}," ...":{description:"Specifies node.js options (CLI only). See: node --help"},"-Os":{value:{optimizeLevel:0,shrinkLevel:1}},"-Oz":{value:{optimizeLevel:0,shrinkLevel:2}},"-O0":{value:{optimizeLevel:0,shrinkLevel:0}},"-O1":{value:{optimizeLevel:1,shrinkLevel:0}},"-O2":{value:{optimizeLevel:2,shrinkLevel:0}},"-O3":{value:{optimizeLevel:3,shrinkLevel:0}},"-O0s":{value:{optimizeLevel:0,shrinkLevel:1}},"-O1s":{value:{optimizeLevel:1,shrinkLevel:1}},"-O2s":{value:{optimizeLevel:2,shrinkLevel:1}},"-O3s":{value:{optimizeLevel:3,shrinkLevel:1}},"-O0z":{value:{optimizeLevel:0,shrinkLevel:2}},"-O1z":{value:{optimizeLevel:1,shrinkLevel:2}},"-O2z":{value:{optimizeLevel:2,shrinkLevel:2}},"-O3z":{value:{optimizeLevel:3,shrinkLevel:2}},"-Ospeed":{value:{optimizeLevel:3,shrinkLevel:0}},"-Osize":{value:{optimizeLevel:0,shrinkLevel:2,converge:!0}},"--measure":{value:{stats:!0}}},Ae="~lib/",_e={array:`/// <reference path="./rt/index.d.ts" />
9
9
 
10
10
  import { BLOCK_MAXSIZE } from "./rt/common";
11
11
  import { Runtime } from "shared/runtime";
@@ -1224,6 +1224,21 @@ export declare function alignof<T>(): usize; // | u32 / u64
1224
1224
  @builtin
1225
1225
  export declare function offsetof<T>(fieldName?: string): usize; // | u32 / u64
1226
1226
 
1227
+ /**
1228
+ * Copies an \`@inline struct\` value's leaves into memory at \`dest\`, one store
1229
+ * per leaf at \`dest + offsetof(leaf)\`.
1230
+ *
1231
+ * The value must be **SROA-tracked**: a local of the value, or a path into one
1232
+ * (\`copyInto(at, outer.inner)\`). There is no value expression to evaluate \u2014 an
1233
+ * inline value has no representation and no address \u2014 which is why
1234
+ * \`changetype<usize>(value)\` stays refused: the address it would return belongs
1235
+ * to a temp nobody tracks. \`copyInto\` names the destination instead, so the
1236
+ * copy is explicit and the bytes land where the caller chose.
1237
+ */
1238
+ // @ts-ignore: decorator
1239
+ @builtin
1240
+ export declare function copyInto(dest: usize, value: any): void;
1241
+
1227
1242
  /**
1228
1243
  * The ABI name of a field: its \`@abi.alias("\u2026")\` if the declaration has one,
1229
1244
  * else the field's TypeScript name. Compile-time, like \`offsetof\`.
@@ -20501,6 +20516,8 @@ declare function offsetof<T>(): usize;
20501
20516
  declare function offsetof<T>(fieldName: keyof T | string): usize;
20502
20517
  /** Determines the offset of the specified field within the given class type. Returns the class type's end offset if field name has been omitted. Compiles to a constant. */
20503
20518
  declare function offsetof<T>(fieldName?: string): usize;
20519
+ /** Copies an \`@inline struct\` value's leaves into memory at \`dest\`, one store per leaf at \`dest + offsetof(leaf)\`. The value must be held in a local (or a path into one); an inline value has no address to lend, which is why \`changetype<usize>(value)\` stays refused. */
20520
+ declare function copyInto(dest: usize, value: any): void;
20504
20521
  /** Determines the ABI name of the specified field: its \`@abi.alias\` if declared, else the field's TypeScript name. Compiles to a constant. */
20505
20522
  declare function abiNameOf<T>(fieldName: string): string;
20506
20523
  /** Determines the name of a given type. */