Appearance
| 1 | namespace IR.Values.Load is | |
| 2 | use TypeTyped = Semantic.Types.Typed | |
| 3 | use SymbolBase = Semantic.Symbols.Symbol | |
| 4 | ||
| 5 | class LOCAL_VARIABLE: SYMBOL, TypeTyped is | |
| 6 | is_consumable: bool => true | |
| 7 | is_lightweight_pure: bool => true | |
| 8 | ||
| 9 | init(symbol: SymbolBase) is | |
| 10 | super.init(null, symbol) | |
| 11 | si | |
| 12 | ||
| 13 | gen(context: IR.CONTEXT) is | |
| 14 | // Generator-function locals: the CLR-local slot doesn't | |
| 15 | // exist inside MoveNext, so the load is redirected to | |
| 16 | // the field on the state-machine frame. See the matching | |
| 17 | // Load.LOCAL_ARGUMENT for the rationale. | |
| 18 | if let state_machine_field = IR.Values.state_machine_field_for(symbol) then | |
| 19 | let body = context.current_srm_body_emitter! | |
| 20 | body.ldarg(0) | |
| 21 | body.ldfld(context.resolve_field_target(state_machine_field)) | |
| 22 | ||
| 23 | guard_complement_narrow(context) | |
| 24 | ||
| 25 | return | |
| 26 | fi | |
| 27 | ||
| 28 | let body = context.current_srm_body_emitter! | |
| 29 | body.ldloc(symbol.il_name) | |
| 30 | ||
| 31 | guard_complement_narrow(context) | |
| 32 | si | |
| 33 | ||
| 34 | gen_address(context: IR.CONTEXT) is | |
| 35 | if let state_machine_field = IR.Values.state_machine_field_for(symbol) then | |
| 36 | let body = context.current_srm_body_emitter! | |
| 37 | body.ldarg(0) | |
| 38 | body.ldflda(context.resolve_field_target(state_machine_field)) | |
| 39 | ||
| 40 | return | |
| 41 | fi | |
| 42 | ||
| 43 | let body = context.current_srm_body_emitter! | |
| 44 | body.ldloca(symbol.il_name) | |
| 45 | si | |
| 46 | ||
| 47 | to_string() -> string => | |
| 48 | "load:[{type}]({from},\"{symbol.name}\")" | |
| 49 | si | |
| 50 | si |