var outname = outfile(mainmodule)
- var orig_dir=".." # FIXME only works if `compile_dir` is a subdirectory of cwd
+ var orig_dir = compile_dir.relpath(".")
var outpath = orig_dir.join_path(outname).simplify_path
var makename = makefile_name(mainmodule)
var makepath = "{compile_dir}/{makename}"
if not initializers.is_empty then
var recv = arguments.first
- assert initializers.length == arguments.length - 1 else debug("expected {initializers.length}, got {arguments.length - 1}")
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
self.write_attribute(p, recv, arguments[i])
+ i += 1
else abort
- i += 1
end
+ assert i == arguments.length
return self.send(callsite.mproperty, [recv])
end
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