Appearance
| 1 | namespace IR.Values.Load is | |
| 2 | use TypeTyped = Semantic.Types.Typed | |
| 3 | use SymbolBase = Semantic.Symbols.Symbol | |
| 4 | ||
| 5 | class LOCAL_ARGUMENT: 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 arguments: the CLR parameter | |
| 15 | // doesn't exist inside MoveNext, so the load is | |
| 16 | // redirected to the field on the state-machine frame | |
| 17 | // populated by the .ctor. Plain functions take the | |
| 18 | // ldarg path. | |
| 19 | if let state_machine_field = IR.Values.state_machine_field_for(symbol) then | |
| 20 | let body = context.current_srm_body_emitter! | |
| 21 | body.ldarg(0) | |
| 22 | body.ldfld(context.resolve_field_target(state_machine_field)) | |
| 23 | ||
| 24 | guard_complement_narrow(context) | |
| 25 | ||
| 26 | return | |
| 27 | fi | |
| 28 | ||
| 29 | if let packed_local = IR.Values.packed_parameter_local_for(symbol) then | |
| 30 | let body = context.current_srm_body_emitter! | |
| 31 | body.ldloc(packed_local) | |
| 32 | ||
| 33 | guard_complement_narrow(context) | |
| 34 | ||
| 35 | return | |
| 36 | fi | |
| 37 | ||
| 38 | let body = context.current_srm_body_emitter! | |
| 39 | body.ldarg(context.resolve_argument_index(symbol)) | |
| 40 | ||
| 41 | guard_complement_narrow(context) | |
| 42 | si | |
| 43 | ||
| 44 | gen_address(context: IR.CONTEXT) is | |
| 45 | if let state_machine_field = IR.Values.state_machine_field_for(symbol) then | |
| 46 | let body = context.current_srm_body_emitter! | |
| 47 | body.ldarg(0) | |
| 48 | body.ldflda(context.resolve_field_target(state_machine_field)) | |
| 49 | ||
| 50 | return | |
| 51 | fi | |
| 52 | ||
| 53 | if let packed_local = IR.Values.packed_parameter_local_for(symbol) then | |
| 54 | let body = context.current_srm_body_emitter! | |
| 55 | body.ldloca(packed_local) | |
| 56 | ||
| 57 | return | |
| 58 | fi | |
| 59 | ||
| 60 | let body = context.current_srm_body_emitter! | |
| 61 | body.ldarga(context.resolve_argument_index(symbol)) | |
| 62 | si | |
| 63 | ||
| 64 | to_string() -> string => | |
| 65 | "load:[{type}]({from},\"{symbol.name}\")" | |
| 66 | si | |
| 67 | si |