Appearance
| 1 | namespace IR.Values.Load is | |
| 2 | use TypeTyped = Semantic.Types.Typed | |
| 3 | use SymbolBase = Semantic.Symbols.Symbol | |
| 4 | ||
| 5 | // The cast to the symbol's expected kind is a checked construction | |
| 6 | // invariant: the caller only ever builds this value with a symbol of | |
| 7 | // that kind, so a throw here means the invariant broke elsewhere. | |
| 8 | @suppress("cast-may-throw") | |
| 9 | class INSTANCE_FIELD: SYMBOL, TypeTyped is | |
| 10 | is_consumable: bool => true | |
| 11 | is_lightweight_pure: bool => from!.is_lightweight_pure | |
| 12 | ||
| 13 | // A field is addressable in place when its containing instance | |
| 14 | // is: a reference receiver holds the object, so ldflda always | |
| 15 | // works; a struct receiver must itself be addressable or the | |
| 16 | // field lives in a temporary copy. | |
| 17 | has_address: bool => | |
| 18 | if from!.is_value_type then | |
| 19 | from!.has_address | |
| 20 | else | |
| 21 | true | |
| 22 | fi | |
| 23 | ||
| 24 | init(from: Value, symbol: SymbolBase) is | |
| 25 | super.init(from, symbol) | |
| 26 | si | |
| 27 | ||
| 28 | accept(visitor: Visitor) is | |
| 29 | visitor.visit(self) | |
| 30 | si | |
| 31 | ||
| 32 | accept_address(visitor: Visitor) is | |
| 33 | visitor.visit_address(self) | |
| 34 | si | |
| 35 | ||
| 36 | to_string() -> string => | |
| 37 | "load:[{type}]({from},\"{symbol.name}\")" | |
| 38 | si | |
| 39 | si |