engines: no more `super_inits` method used in old-style automatic init
authorJean Privat <jean@pryen.org>
Wed, 1 Oct 2014 00:13:09 +0000 (20:13 -0400)
committerJean Privat <jean@pryen.org>
Wed, 1 Oct 2014 00:13:09 +0000 (20:13 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/abstract_compiler.nit
src/interpreter/naive_interpreter.nit
src/modelize/modelize_property.nit
src/rapid_type_analysis.nit

index 2efd979..c98d54e 100644 (file)
@@ -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
index 5b79f0c..34fd8f1 100644 (file)
@@ -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
 
index 5b51894..28e6a03 100644 (file)
@@ -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
index 3d8fb9e..c94e20f 100644 (file)
@@ -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)