Appearance
| 1 | namespace IR.Values is | |
| 2 | use TypeTyped = Semantic.Types.Typed; | |
| 3 | use Semantic.Types.Type; | |
| 4 | ||
| 5 | // poisoning error value. It's OK to create this, for example speculatively, | |
| 6 | // provided it's never converted to actual IL assembly language via 'gen()' | |
| 7 | ||
| 8 | // TODO rename this to POISON or ERROR | |
| 9 | class DUMMY: Value, TypeTyped is | |
| 10 | type: Type; | |
| 11 | location: Source.LOCATION; | |
| 12 | has_location: bool => true; | |
| 13 | ||
| 14 | init( | |
| 15 | type: Type, | |
| 16 | location: Source.LOCATION | |
| 17 | ) is | |
| 18 | super.init(); | |
| 19 | ||
| 20 | self.type = type; | |
| 21 | self.location = location; | |
| 22 | si | |
| 23 | ||
| 24 | // we're actually attempting to generate this poison value: that | |
| 25 | // indicates a bug, so we need block generating an object file | |
| 26 | gen(context: IR.CONTEXT) is | |
| 27 | IoC.CONTAINER.instance.logger.poison(location, "generated dummy value: {type} from {location}"); | |
| 28 | context.fixme("dummy {type} from {location}"); | |
| 29 | si | |
| 30 | ||
| 31 | // may have been called from a process that will subsequently | |
| 32 | // backtrack so, don't poison, yet. Leave as signalling error | |
| 33 | // value that will still throw if we attempt to emit actual IL | |
| 34 | freeze() -> Value => self; | |
| 35 | ||
| 36 | to_string() -> string => | |
| 37 | "dummy:[{type}]()"; | |
| 38 | si | |
| 39 | si |