do
var initializers = callsite.mpropdef.initializers
if not initializers.is_empty then
- assert initializers.length == arguments.length - 1 else debug("expected {initializers.length} got {arguments.length - 1}")
var recv = arguments.first
var i = 1
for p in initializers do
if p isa MMethod then
- self.send(p, [recv, arguments[i]])
+ 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
assert recv isa MutableInstance
recv.attributes[p] = arguments[i]
+ i += 1
else abort
- i += 1
end
+ assert i == arguments.length
+
return send(callsite.mproperty, [recv])
end
return send(callsite.mproperty, arguments)
private fun call(v: NaiveInterpreter, mpropdef: MMethodDef, args: Array[Instance]): nullable Instance
do
if mpropdef.mproperty.is_root_init then
- assert self.super_inits == null
assert args.length == 1
if not mpropdef.is_intro then
# standard call-next-method
v.call_without_varargs(superpd, args)
end
return null
+ else
+ abort
end
-
- var super_inits = self.super_inits
- if super_inits != null then
- var args_of_super = args
- if args.length > 1 then args_of_super = [args.first]
- for su in super_inits do
- v.send(su, args_of_super)
- end
- end
- var recv = args.first
- assert recv isa MutableInstance
- var i = 1
- # Collect undefined attributes
- for npropdef in self.n_propdefs do
- if npropdef isa AAttrPropdef and not npropdef.noinit and npropdef.n_expr == null then
- v.write_attribute(npropdef.mpropdef.mproperty, recv, args[i])
- i += 1
- end
- end
- return null
end
end