Skip to content
← Back

src/ir/values/store/symbol.ghul

1
namespace IR.Values.Store is
2
use TypeTyped = Semantic.Types.Typed
3
use Semantic.Types.Type
4
use SymbolBase = Semantic.Symbols.Symbol
5
6
class SYMBOL: Value, TypeTyped is
7
symbol: SymbolBase
8
symbol_as_typed: TypeTyped => cast TypeTyped?(symbol)!
9
10
// Absent while the symbol has no type of its own, matching the
11
// load side and the `Value.type` contract both sides answer to.
12
// A top-level `let` assigned above its own declaration is the
13
// case that reaches here: the store is reported at its site and
14
// the walk carries on, so this has to describe the store rather
15
// than insist on a type the variable has not been given.
16
type: Type? pure => symbol_as_typed.type
17
from: Value?
18
value: IR.Values.Value
19
is_consumable: bool => false
20
21
init(from: Value?, symbol: SymbolBase, value: IR.Values.Value) is
22
super.init()
23
24
self.from = from
25
self.symbol = symbol
26
self.value = value
27
si
28
29
gen(context: IR.CONTEXT) is
30
gen(from, context)
31
gen(value, context)
32
33
throw System.NotImplementedException(
34
"the binary back end has no emission for storing to '{symbol}' yet")
35
si
36
37
to_string() -> string =>
38
"store:[{type}]({from},\"{symbol.name}\",{value})"
39
si
40
si