Skip to content
← Back

src/ir/values/tuple.ghul

1
namespace IR.Values is
2
use TypeTyped = Semantic.Types.Typed;
3
use Semantic.Types.Type;
4
5
class TUPLE: Value, TypeTyped is
6
type: Type;
7
8
values: Collections.List[Value];
9
10
init(type: Type, values: Collections.List[Value]) is
11
super.init();
12
13
self.type = type;
14
self.values = values;
15
si
16
17
gen(context: IR.CONTEXT) is
18
let call = System.Text.StringBuilder();
19
20
call
21
.append("newobj instance void ");
22
23
type.gen_type(call);
24
25
call
26
.append(" ::'.ctor'(");
27
28
let i mut = 0;
29
let seen_any mut = false;
30
31
for v in values do
32
gen(v, context);
33
34
if seen_any then
35
call.append(',');
36
fi
37
38
call.append('!').append(i);
39
40
seen_any = true;
41
42
i = i + 1;
43
od
44
45
call.append(")");
46
47
context.write_line(call, "tuple {type}");
48
si
49
50
to_string() -> string =>
51
"tuple:[{type}]({values})";
52
si
53
si