Skip to content
← Back

src/ir/values/spilled_subject.ghul

1
namespace IR.Values is
2
use Semantic.Types.Type
3
4
// Spills the value sitting on top of the evaluation stack - the
5
// unwrapped subject a COALESCE_LOAD present arm leaves there -
6
// into a fresh local, then generates `built`, which was
7
// constructed against a `Load.TEMP` referring to that local.
8
//
9
// A value consumed straight off the stack only works when the
10
// consuming value's gen() reads it first, before pushing anything
11
// of its own: true of a member access on the subject (it is the
12
// call target, pushed before the arguments), false of invoking a
13
// delegate with the subject as an argument - the delegate itself
14
// is pushed first. Spilling to a local decouples the subject's
15
// stack position from where the built value needs it.
16
class SPILLED_SUBJECT(temp: IR.LOCAL, built: Value): Value is
17
type: Type? pure => built.type
18
is_lightweight_pure: bool => false
19
20
accept(visitor: Visitor) is
21
visitor.visit(self)
22
si
23
24
to_string() -> string =>
25
"spilled-subject:[{type}]({built})"
26
si
27
si