1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//! Type readers for the wasm-gc body emitter.
//!
//! After Step 3 (the typed-ABI refactor), the wasm-gc backend no longer
//! performs ad-hoc inference. Every `Spanned<Expr>` reaching codegen has
//! its `Type` stamped by the type checker (`Spanned::ty()`). The
//! accessors here are thin readers that panic if the type was not
//! stamped — that means either the type checker did not run before
//! codegen, or a synthesised AST node skipped `Spanned::set_ty(...)`
//! (interp_lower / buffer_build are the usual suspects). Both are bugs
//! to fix at the source, not to paper over with a fallback here.
//!
//! Schema-level helpers that were previously co-located with inference
//! (option-/result-shape match recognition) stay in this module — they
//! describe the program's static AST shape, not its inferred types.
use ValType;
use crateSpanned;
use crateType;
use WasmGcError;
use ;
// ---------------------------------------------------------------------------
// Match-arm shape predicates (schema-level — no type inference involved)
// ---------------------------------------------------------------------------
/// True when a match arm matches against `Option.Some(_)` /
/// `Option.None`. Used to opt the surrounding match into the
/// dedicated tag-based dispatch path (instead of the generic
/// `ref.test` cascade for user variants). Reads identity off
/// [`crate::ir::hir::ResolvedCtor::Builtin`] — post Phase E PR 9.1
/// every reachable arm carries the typed ctor, so the pre-resolve
/// source-shape variant is gone.
pub
/// True when a match arm matches against `Result.Ok(_)` /
/// `Result.Err(_)`. Same Phase E shape as
/// [`arm_is_option_pattern_resolved`].
pub
// ---------------------------------------------------------------------------
// Typed-AST accessors
// ---------------------------------------------------------------------------
/// Inferred Aver type for a typed `Spanned<T>`. Panics if the type
/// checker did not stamp this node — that is a pipeline bug, not a
/// recoverable codegen condition (see module doc).
///
/// Generic over the wrapped node type so the readers work uniformly
/// against both `Spanned<crate::ast::Expr>` (source-shape, used by
/// the pre-PR-9.x dispatch sites that haven't migrated yet) and
/// `Spanned<crate::ir::hir::ResolvedExpr>` (resolved, used by the
/// migrated emitters). `Spanned::ty()` is generic over `T` already,
/// so the readers don't care which IR shape the node carries.
pub
/// Display string of the stamped Aver type. Most of the existing
/// lowering machinery is keyed on the canonical type-name string
/// (`record_field_type`, `aver_to_wasm`, registry canonical lookups),
/// so a single `display()` per call site keeps the diff small.
pub
/// WASM machine type for a typed `Spanned<T>`. Same panic contract
/// as `aver_type_of`; `Ok(None)` for Unit (no value pushed).
pub
/// Display string of the stamped Aver type in the canonical no-whitespace
/// form used by wasm-gc registries. Generic constructors must already be
/// resolved by the type checker before codegen reaches this reader.
pub