Skip to content
← Back

src/ir/values/load/global_anonymous_function.ghul

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