Skip to content
← Back

src/ir/values/store/local_variable.ghul

1
namespace IR.Values.Store is
2
use TypeTyped = Semantic.Types.Typed
3
use Semantic.Types.Type
4
use SymbolBase = Semantic.Symbols.Symbol
5
6
class LOCAL_VARIABLE: SYMBOL is
7
is_consumable: bool => value.is_consumable
8
9
init(symbol: SymbolBase, value: IR.Values.Value) is
10
super.init(null, symbol, value)
11
si
12
13
gen(context: IR.CONTEXT) is
14
// Generator-function locals: store routes through the
15
// state-machine frame's field. See the matching
16
// Load.LOCAL_VARIABLE for the rationale.
17
if let state_machine_field = IR.Values.state_machine_field_for(symbol) then
18
let body = context.current_srm_body_emitter!
19
body.ldarg(0)
20
gen(value, context)
21
body.stfld(context.resolve_field_target(state_machine_field))
22
23
return
24
fi
25
26
gen(value, context)
27
28
let body = context.current_srm_body_emitter!
29
body.stloc(symbol.il_name)
30
si
31
32
to_string() -> string =>
33
"store:[{type}]({from},\"{symbol.name}\",{value})"
34
si
35
si