Skip to content
← Back

src/ir/values/state_machine_field.ghul

1
namespace IR.Values is
2
use Semantic.Symbols.Symbol;
3
use Semantic.Symbols.Variable;
4
5
// A generator or async local/argument has no CLR slot inside the
6
// MoveNext method — access routes through a field on the
7
// state-machine frame (`ldarg.0; ldfld/stfld <field>`). Returns
8
// that field's IL reference, or null for an ordinary local that
9
// keeps its CLR slot.
10
state_machine_field_reference(symbol: Symbol?) -> string? is
11
let variable = cast Variable?(symbol);
12
13
if variable? then
14
let `field = variable.state_machine_field;
15
16
if `field? then
17
return `field.get_il_reference();
18
fi
19
fi
20
21
return null;
22
si
23
si