Appearance
| 1 | namespace IR.Values.Load is | |
| 2 | // An argument of the method being emitted, named by the slot it | |
| 3 | // occupies rather than by a symbol. | |
| 4 | // | |
| 5 | // The state-machine lowering forwards its enclosing method's own | |
| 6 | // arguments into a frame constructor, where what is wanted is | |
| 7 | // positional: the receiver when the method has one, then each | |
| 8 | // declared argument in order. There is no symbol to resolve, | |
| 9 | // because the argument being loaded belongs to the method the | |
| 10 | // lowering is rewriting rather than to anything it declares. | |
| 11 | class ARGUMENT_SLOT: Value is | |
| 12 | _index: int | |
| 13 | _il_name: string | |
| 14 | ||
| 15 | // `il_name` names the argument the slot loads — the receiver, | |
| 16 | // or a declared argument by name — alongside the index the | |
| 17 | // instruction is actually encoded from. | |
| 18 | init(index: int, il_name: string) is | |
| 19 | super.init() | |
| 20 | ||
| 21 | _index = index | |
| 22 | _il_name = il_name | |
| 23 | si | |
| 24 | ||
| 25 | gen(context: IR.CONTEXT) is | |
| 26 | let body = context.current_srm_body_emitter! | |
| 27 | body.ldarg(_index) | |
| 28 | si | |
| 29 | ||
| 30 | to_string() -> string => "load-argument-slot:({_index})" | |
| 31 | si | |
| 32 | si |