Appearance
| 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 | class INSTANCE_ANONYMOUS_FUNCTION: SYMBOL, TypeTyped is | |
| 7 | is_consumable: bool => true; | |
| 8 | ||
| 9 | func_type: Type; | |
| 10 | ||
| 11 | // The constructed delegate is what this load yields, which is | |
| 12 | // the target delegate type when the literal was compiled for | |
| 13 | // one rather than the closure's own function type. | |
| 14 | type: Type => func_type; | |
| 15 | ||
| 16 | has_address: bool => false; | |
| 17 | ||
| 18 | init(symbol: SymbolBase, func_type: Type) is | |
| 19 | super.init(null, symbol); | |
| 20 | ||
| 21 | ||
| 22 | self.func_type = func_type; | |
| 23 | si | |
| 24 | ||
| 25 | gen(context: IR.CONTEXT) is | |
| 26 | context.write_line("ldarg.0"); | |
| 27 | context.write_line("ldftn instance {symbol.get_il_reference()}"); | |
| 28 | context.write_line("newobj instance void {func_type.get_il_type()}::'.ctor'(object, native int)"); | |
| 29 | si | |
| 30 | ||
| 31 | to_string() -> string => | |
| 32 | "load:[{type}]({from},\"{symbol.name}\")"; | |
| 33 | si | |
| 34 | ||
| 35 | si |