Skip to content
← Back

src/semantic/symbols/pack_thunk.ghul

1
namespace Semantic.Symbols is
2
use Types.Type
3
4
// What a generated argument pack thunk does. A thunk stands between
5
// the two shapes one pack has - a function of the pack's elements and
6
// a function of the tuple they make - for a function value that has
7
// one shape going where the other is wanted. It has no source: its
8
// body is this description, and is emitted from it.
9
class PACK_THUNK is
10
// Whether the thunk takes the tuple and calls a function of the
11
// elements, rather than taking the elements and calling a
12
// function of the tuple.
13
is_unpack: bool
14
15
// How many leading parameters are passed through as they are.
16
fixed_count: int
17
18
element_types: Collections.List[Type]
19
20
// The wrapped function value, as the thunk's body loads it, and
21
// the type it is called at. Absent where the thunk calls `target`.
22
callee: IR.Values.Value?
23
callee_type: Type
24
25
// A function the thunk calls by name: one that needs no receiver
26
// and no type arguments, so there is no value to capture and the
27
// call is a direct one.
28
target: Function?
29
30
init(
31
is_unpack: bool,
32
fixed_count: int,
33
element_types: Collections.List[Type],
34
callee: IR.Values.Value?,
35
callee_type: Type,
36
target: Function?
37
) is
38
self.is_unpack = is_unpack
39
self.fixed_count = fixed_count
40
self.element_types = element_types
41
self.callee = callee
42
self.callee_type = callee_type
43
self.target = target
44
si
45
si
46
si