Skip to content
← Back

src/ir/values/store/local_argument.ghul

1
namespace IR.Values.Store is
2
use TypeTyped = Semantic.Types.Typed
3
use SymbolBase = Semantic.Symbols.Symbol
4
5
class LOCAL_ARGUMENT: SYMBOL, TypeTyped is
6
is_consumable: bool => value.is_consumable
7
8
init(symbol: SymbolBase, value: IR.Values.Value) is
9
super.init(null, symbol, value)
10
si
11
12
gen(context: IR.CONTEXT) is
13
// Generator-function arguments: the CLR parameter
14
// slot doesn't exist inside MoveNext. Store routes
15
// through the state-machine frame's field. See the
16
// matching Load.LOCAL_ARGUMENT 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
if let packed_local = IR.Values.packed_parameter_local_for(symbol) then
27
gen(value, context)
28
let body = context.current_srm_body_emitter!
29
body.stloc(packed_local)
30
31
return
32
fi
33
34
gen(value, context)
35
let body = context.current_srm_body_emitter!
36
body.starg(context.resolve_argument_index(symbol))
37
si
38
39
to_string() -> string =>
40
"load:[{type}]({from},\"{symbol.name}\")"
41
si
42
si