private fun compile_to_c(v: AbstractCompilerVisitor, mpropdef: MMethodDef, arguments: Array[RuntimeVariable])
do
if mpropdef == self.mfree_init then
- if mpropdef.mproperty.is_root_init then
- assert self.super_inits == null
- assert arguments.length == 1
- if not mpropdef.is_intro then
- v.supercall(mpropdef, arguments.first.mtype.as(MClassType), arguments)
- end
- return
- end
-
- var super_inits = self.super_inits
- if super_inits != null then
- var args_of_super = arguments
- if arguments.length > 1 then args_of_super = [arguments.first]
- for su in super_inits do
- v.send(su, args_of_super)
- end
- end
-
- var recv = arguments.first
- var i = 1
- # Collect undefined attributes
- for npropdef in self.n_propdefs do
- if npropdef isa AAttrPropdef and npropdef.n_expr == null and not npropdef.noinit then
- v.write_attribute(npropdef.mpropdef.mproperty, recv, arguments[i])
- i += 1
- end
+ assert mpropdef.mproperty.is_root_init
+ assert arguments.length == 1
+ if not mpropdef.is_intro then
+ v.supercall(mpropdef, arguments.first.mtype.as(MClassType), arguments)
end
+ return
else
abort
end
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
redef class AClassdef
var build_properties_is_done: Bool = false
- # The list of super-constructor to call at the start of the free constructor
- # FIXME: this is needed to implement the crazy constructor thing of the of old compiler. We need to think what to do with since this cannot stay in the modelbuilder
- var super_inits: nullable Collection[MMethod] = null
# The free init (implicitely constructed by the class if required)
var mfree_init: nullable MMethodDef = null
if mmeth.name == "init" then
var nclassdef = self.modelbuilder.mclassdef2nclassdef[mmethoddef.mclassdef]
assert mmethoddef == nclassdef.mfree_init
- var super_inits = nclassdef.super_inits
- if super_inits != null then
- #assert args.length == 1
- for su in super_inits do
- v.add_monomorphic_send(v.receiver, su)
- end
- end
if mmethoddef.mproperty.is_root_init and not mmethoddef.is_intro then
self.add_super_send(v.receiver, mmethoddef)