From 6464d38e0f917fa13d96f3e0f09b57a3ca6b072c Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Tue, 30 Sep 2014 20:13:09 -0400 Subject: [PATCH] engines: no more `super_inits` method used in old-style automatic init Signed-off-by: Jean Privat --- src/compiler/abstract_compiler.nit | 31 +++++-------------------------- src/interpreter/naive_interpreter.nit | 23 ++--------------------- src/modelize/modelize_property.nit | 3 --- src/rapid_type_analysis.nit | 7 ------- 4 files changed, 7 insertions(+), 57 deletions(-) diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 2efd979..c98d54e 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -2324,33 +2324,12 @@ redef class AClassdef 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 diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index 5b79f0c..34fd8f1 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -1077,7 +1077,6 @@ redef class AClassdef 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 @@ -1085,27 +1084,9 @@ redef class AClassdef 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 diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index 5b51894..28e6a03 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -289,9 +289,6 @@ 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 diff --git a/src/rapid_type_analysis.nit b/src/rapid_type_analysis.nit index 3d8fb9e..c94e20f 100644 --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@ -239,13 +239,6 @@ class RapidTypeAnalysis 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) -- 1.7.9.5