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
is_receiver_interior_call: bool => function.writes_only_receiver_interior
8
from: Value
9
function: Semantic.Symbols.Function
10
arguments: Collections.List[Value]
11
type: Type
12
13
init(from: Value, function: Semantic.Symbols.Function, arguments: Collections.List[Value], type: Type?) is
14
super.init()
15
16
self.from = from
17
self.function = function
18
self.arguments = arguments
19
20
if type? then
21
self.type = type
22
else
23
self.type = function.return_type!
24
fi
25
26
si
27
28
gen(context: IR.CONTEXT) is
29
gen(from, context)
30
31
for a in arguments do
32
gen(a, context)
33
od
34
35
if isa CONSTRAINED(from) then
36
(cast CONSTRAINED(from)).gen_prefix(context)
37
fi
38
39
let body = context.current_srm_body_emitter!
40
let target = context.resolve_call_target(function)
41
42
if from.is_super \/ !function.is_virtual then
43
body.call(target)
44
else
45
body.call_virtual(target)
46
fi
47
si
48
49
to_string() -> string =>
50
"instance-call:[{type}]({from},\"{function.name}\",{arguments})"
51
si
52
53
si