fun compile_callsite(callsite: CallSite, arguments: Array[RuntimeVariable]): nullable RuntimeVariable
do
if callsite.is_broken then return null
- var initializers = callsite.mpropdef.initializers
- if not initializers.is_empty then
- var recv = arguments.first
-
- var i = 1
- for p in initializers do
- if p isa MMethod then
- var args = [recv]
- for x in p.intro.msignature.mparameters do
- args.add arguments[i]
- i += 1
- end
- self.send(p, args)
- else if p isa MAttribute then
- self.write_attribute(p, recv, arguments[i])
- i += 1
- else abort
- end
- assert i == arguments.length
-
- return self.send(callsite.mproperty, [recv])
- end
-
return self.send(callsite.mproperty, arguments)
end
# of runtime variables to use in the call.
fun varargize(mpropdef: MMethodDef, map: nullable SignatureMap, recv: RuntimeVariable, args: SequenceRead[AExpr]): Array[RuntimeVariable]
do
- var msignature = mpropdef.new_msignature or else mpropdef.msignature.as(not null)
+ var msignature = mpropdef.msignature.as(not null)
var res = new Array[RuntimeVariable]
res.add(recv)
v.supercall(mpropdef, arguments.first.mtype.as(MClassType), arguments)
end
return
+ else if mclassdef.auto_init == mpropdef then
+ var recv = arguments.first
+ var initializers = mpropdef.initializers
+ var no_init = false
+ if not initializers.is_empty then
+
+ var i = 1
+ for p in initializers do
+ if p isa MMethod then
+ var args = [recv]
+ for x in p.intro.msignature.mparameters do
+ args.add arguments[i]
+ i += 1
+ end
+ v.send(p, args)
+ if p.intro.is_calling_init then no_init = true
+ else if p isa MAttribute then
+ v.write_attribute(p, recv, arguments[i])
+ i += 1
+ else abort
+ end
+ assert i == arguments.length
+
+ end
+ if not no_init then v.send(mclass.the_root_init_mmethod.as(not null), [recv])
+ return
else
abort
end