Appearance
| 1 | namespace IR.Values.Load is | |
| 2 | use Semantic.Types.Type | |
| 3 | use Semantic.Symbols.Function | |
| 4 | ||
| 5 | // An argument of a function, named by its position among the | |
| 6 | // arguments the function declares rather than by a symbol. | |
| 7 | // | |
| 8 | // The state-machine lowering forwards its enclosing method's own | |
| 9 | // arguments into a frame constructor, where what is wanted is | |
| 10 | // positional. There is no symbol to resolve, because the argument | |
| 11 | // being loaded belongs to the method the lowering is rewriting | |
| 12 | // rather than to anything it declares. | |
| 13 | class ARGUMENT: Value is | |
| 14 | function: Function | |
| 15 | index: int | |
| 16 | ||
| 17 | type: Type? pure => | |
| 18 | if index < function.arguments.count then | |
| 19 | function.arguments[index] | |
| 20 | else | |
| 21 | null | |
| 22 | fi | |
| 23 | ||
| 24 | init(function: Function, index: int) is | |
| 25 | super.init() | |
| 26 | ||
| 27 | self.function = function | |
| 28 | self.index = index | |
| 29 | si | |
| 30 | ||
| 31 | accept(visitor: Visitor) is | |
| 32 | visitor.visit(self) | |
| 33 | si | |
| 34 | ||
| 35 | to_string() -> string => "load-argument:({function.name}, {index})" | |
| 36 | si | |
| 37 | ||
| 38 | // The receiver of a function that has one: the instance a method | |
| 39 | // was called on, or the frame a closure runs in. | |
| 40 | class RECEIVER: Value is | |
| 41 | function: Function | |
| 42 | ||
| 43 | init(function: Function) is | |
| 44 | super.init() | |
| 45 | ||
| 46 | self.function = function | |
| 47 | si | |
| 48 | ||
| 49 | accept(visitor: Visitor) is | |
| 50 | visitor.visit(self) | |
| 51 | si | |
| 52 | ||
| 53 | to_string() -> string => "load-receiver:({function.name})" | |
| 54 | si | |
| 55 | si |