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