Appearance
| 1 | namespace IR.Values is | |
| 2 | use Semantic.Types.Type | |
| 3 | ||
| 4 | // A new array of `element_type` with `count` elements, on the stack. | |
| 5 | class NEW_ARRAY: Value is | |
| 6 | element_type: Type | |
| 7 | count: Value | |
| 8 | ||
| 9 | type: Type | |
| 10 | ||
| 11 | init(type: Type, element_type: Type, count: Value) is | |
| 12 | super.init() | |
| 13 | ||
| 14 | self.type = type | |
| 15 | self.element_type = element_type | |
| 16 | self.count = count | |
| 17 | si | |
| 18 | ||
| 19 | accept(visitor: Visitor) is | |
| 20 | visitor.visit(self) | |
| 21 | si | |
| 22 | ||
| 23 | to_string() -> string => "new-array:[{type}]({count})" | |
| 24 | si | |
| 25 | ||
| 26 | // `array[index] = element`, boxing the element where the array holds | |
| 27 | // a reference type. Leaves nothing on the stack. | |
| 28 | class STORE_ARRAY_ELEMENT: Value is | |
| 29 | array: Value | |
| 30 | index: Value | |
| 31 | element: Value | |
| 32 | element_type: Type | |
| 33 | ||
| 34 | init(array: Value, index: Value, element: Value, element_type: Type) is | |
| 35 | super.init() | |
| 36 | ||
| 37 | self.array = array | |
| 38 | self.index = index | |
| 39 | self.element = element | |
| 40 | self.element_type = element_type | |
| 41 | si | |
| 42 | ||
| 43 | accept(visitor: Visitor) is | |
| 44 | visitor.visit(self) | |
| 45 | si | |
| 46 | ||
| 47 | to_string() -> string => "store-array-element:({array}[{index}] = {element})" | |
| 48 | si | |
| 49 | si |