Skip to content
← Back

src/ir/values/call/instance.ghul

1
namespace IR.Values.Call is
2
use TypeTyped = Semantic.Types.Typed;
3
use Semantic.Types.Type;
4
5
class INSTANCE: Value, TypeTyped is
6
is_state_changing_call: bool => !function.is_store_free;
7
from: Value;
8
function: Semantic.Symbols.Function;
9
arguments: Collections.List[Value];
10
type: Type;
11
12
init(from: Value, function: Semantic.Symbols.Function, arguments: Collections.List[Value], type: Type?) is
13
super.init();
14
15
self.from = from;
16
self.function = function;
17
self.arguments = arguments;
18
19
if type? then
20
self.type = type;
21
else
22
self.type = function.return_type!;
23
fi
24
25
si
26
27
gen(context: IR.CONTEXT) is
28
gen(from, context);
29
30
for a in arguments do
31
gen(a, context);
32
od
33
34
if isa CONSTRAINED(from) then
35
(cast CONSTRAINED(from)).gen_prefix(context);
36
fi
37
38
let il_ref = function.get_il_reference();
39
40
if from.is_super \/ !function.is_virtual then
41
context.write_line("call {il_ref}");
42
else
43
context.write_line("callvirt {il_ref}");
44
fi
45
si
46
47
to_string() -> string =>
48
"instance-call:[{type}]({from},\"{function.name}\",{arguments})";
49
si
50
51
si