Skip to content
← Back

src/ir/values/make_closure.ghul

1
namespace IR.Values is
2
use TypeTyped = Semantic.Types.Typed
3
use Semantic.Types.Type
4
use Semantic.Symbols.Function
5
6
// A function value: `function`, bound to `receiver`, as a value of
7
// the function or delegate type `type`. The receiver is a null
8
// value for a function that takes none.
9
//
10
// A virtual one calls whatever overrides `function` on the
11
// receiver's run-time type, rather than `function` itself.
12
class MAKE_CLOSURE: Value, TypeTyped is
13
function: Function
14
receiver: Value
15
is_virtual: bool
16
type: Type
17
18
// Marks nothing itself: the receiver is where the source wrote
19
// anything.
20
has_location: bool => false
21
22
referenced_function: Function? => function
23
24
init(type: Type, function: Function, receiver: Value, is_virtual: bool) is
25
super.init()
26
27
self.type = type
28
self.function = function
29
self.receiver = receiver
30
self.is_virtual = is_virtual
31
si
32
33
init(type: Type, function: Function, receiver: Value) is
34
self.init(type, function, receiver, false)
35
si
36
37
accept(visitor: Visitor) is
38
visitor.visit(self)
39
si
40
41
to_string() -> string =>
42
"make-closure:[{type}]({receiver},\"{function.name}\")"
43
si
44
si