Appearance
| 1 | namespace IR.Values.Store 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 | class LOCAL_VARIABLE: SYMBOL is | |
| 12 | is_consumable: bool => value.is_consumable; | |
| 13 | ||
| 14 | init(symbol: SymbolBase, value: IR.Values.Value) is | |
| 15 | super.init(null, symbol, value); | |
| 16 | si | |
| 17 | ||
| 18 | gen(context: IR.CONTEXT) is | |
| 19 | // Generator-function locals: store routes through the | |
| 20 | // state-machine frame's field. See the matching | |
| 21 | // Load.LOCAL_VARIABLE for the rationale. | |
| 22 | let field_reference = IR.Values.state_machine_field_reference(symbol); | |
| 23 | ||
| 24 | if field_reference? then | |
| 25 | context.write_line("ldarg.0"); | |
| 26 | gen(value, context); | |
| 27 | context.write_line("stfld {field_reference}"); | |
| 28 | return; | |
| 29 | fi | |
| 30 | ||
| 31 | gen(value, context); | |
| 32 | ||
| 33 | context.write_line("stloc {symbol.il_name}"); | |
| 34 | si | |
| 35 | ||
| 36 | to_string() -> string => | |
| 37 | "store:[{type}]({from},\"{symbol.name}\",{value})"; | |
| 38 | si | |
| 39 | ||
| 40 | si |