lower_enums_mut
Stable function · Load-time lowering and templates
Tier: stable · Kind: function · Topic: Load-time lowering and templates
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
| not exported | not exported | lower_enums_mut | lower_enums_mut | LowerEnumsMut |
Julia
Julia does not export this function.
TypeScript
TypeScript does not export this function.
Python
lower_enums_mut(file: EsmFile) -> EsmFile
In-place twin of lower_enums
: lower every enum op in file
itself, and return it (API_SPEC.md §8 item 15).
The _mut suffix is the cross-binding spelling for a mutating variant whose
canonical name is pure — Julia writes the same thing as lower_enums!.
Use this when a caller elsewhere already holds a reference to file (or
to one of its models) and must see the lowered trees; the load path in
earthsci_ast.parse is exactly that case.
Raises the same EnumLoweringError
as lower_enums
, and
raises it BEFORE grafting anything, so a document that fails to lower is
left untouched rather than half-lowered.
Rust
pub fn lower_enums_mut(file: &mut EsmFile) -> Result<(), EnumLoweringError>
lower_enums
, applied in place. The _mut spelling API_SPEC.md §8 item
15 assigns to a mutating variant (Julia spells the same thing
lower_enums!).
Go
func LowerEnumsMut(file *ESMFile) error
LowerEnumsMut is LowerEnums applied IN PLACE: it walks every expression tree in the file and resolves each enum op to a {op: "const", value: <int>} node per esm-spec §9.3, mutating the file and returning nil, or returning an *EnumLoweringError if any enum op references an undeclared enum or symbol.
On error the file is left PARTIALLY LOWERED — the pass writes as it walks and does not roll back. A caller that cannot tolerate that wants LowerEnums.