Skip to content
← Back

src/ir/values/constrained.ghul

1
namespace IR.Values is
2
use Semantic.Types.Type;
3
4
class CONSTRAINED: Value is
5
value: Value;
6
type: Type? => value.type;
7
is_value_type: bool => false;
8
9
init(
10
value: Value
11
) is
12
super.init();
13
14
self.value = ADDRESS(value, value.type!);
15
si
16
17
// Only load the receiver address. The `constrained.` prefix
18
// must sit immediately before the `callvirt`, after the
19
// arguments have been loaded, so the enclosing instance call
20
// emits it via gen_prefix once the operand stack is set up.
21
gen(context: IR.CONTEXT) is
22
value.gen(context);
23
si
24
25
gen_prefix(context: IR.CONTEXT) is
26
context.write_line("constrained. {type!.get_il_type()}");
27
si
28
29
to_string() -> string =>
30
"constrained:[{type}]({value})";
31
si
32
si