Skip to content
← Back

src/ir/values/load/static_field.ghul

1
namespace IR.Values.Load is
2
use TypeTyped = Semantic.Types.Typed
3
use SymbolBase = Semantic.Symbols.Symbol
4
5
// The cast to the symbol's expected kind is a checked construction
6
// invariant: the caller only ever builds this value with a symbol of
7
// that kind, so a throw here means the invariant broke elsewhere.
8
@suppress("cast-may-throw")
9
class STATIC_FIELD: SYMBOL, TypeTyped is
10
is_consumable: bool => true
11
is_lightweight_pure: bool => true
12
13
init(symbol: SymbolBase) is
14
super.init(null, symbol)
15
si
16
17
gen(context: IR.CONTEXT) is
18
let body = context.current_srm_body_emitter!
19
body.ldsfld(context.resolve_field_target(cast Semantic.Symbols.Field(symbol)))
20
si
21
22
gen_address(context: IR.CONTEXT) is
23
let body = context.current_srm_body_emitter!
24
body.ldsflda(context.resolve_field_target(cast Semantic.Symbols.Field(symbol)))
25
si
26
27
to_string() -> string =>
28
"load:[{type}](\"{symbol.name}\")"
29
si
30
si