From 3304366832d3dab2e8f2cd90e3eb1aacb5604787 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 26 Feb 2016 14:33:23 -0500 Subject: [PATCH] model: remove `new_msignature` and special call as the new signature is the method `autoinit` Signed-off-by: Jean Privat --- src/compiler/abstract_compiler.nit | 25 +------------------------ src/compiler/java_compiler.nit | 2 +- src/doc/console_templates/console_model.nit | 6 ------ src/interpreter/naive_interpreter.nit | 24 +----------------------- src/model/model.nit | 14 ++++++-------- src/modelize/modelize_property.nit | 4 +--- src/rapid_type_analysis.nit | 1 - src/semantize/auto_super_init.nit | 2 +- src/semantize/typing.nit | 4 ++-- src/web/model_html.nit | 8 -------- 10 files changed, 13 insertions(+), 77 deletions(-) diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 2375940..b8681bc 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -1162,29 +1162,6 @@ abstract class AbstractCompilerVisitor fun compile_callsite(callsite: CallSite, arguments: Array[RuntimeVariable]): nullable RuntimeVariable do if callsite.is_broken then return null - var initializers = callsite.mpropdef.initializers - if not initializers.is_empty then - var recv = arguments.first - - var i = 1 - for p in initializers do - if p isa MMethod then - 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 - end - assert i == arguments.length - - return self.send(callsite.mproperty, [recv]) - end - return self.send(callsite.mproperty, arguments) end @@ -1207,7 +1184,7 @@ abstract class AbstractCompilerVisitor # of runtime variables to use in the call. fun varargize(mpropdef: MMethodDef, map: nullable SignatureMap, recv: RuntimeVariable, args: SequenceRead[AExpr]): Array[RuntimeVariable] do - var msignature = mpropdef.new_msignature or else mpropdef.msignature.as(not null) + var msignature = mpropdef.msignature.as(not null) var res = new Array[RuntimeVariable] res.add(recv) diff --git a/src/compiler/java_compiler.nit b/src/compiler/java_compiler.nit index ec759a2..66115be 100644 --- a/src/compiler/java_compiler.nit +++ b/src/compiler/java_compiler.nit @@ -497,7 +497,7 @@ class JavaCompilerVisitor # This method is used to manage varargs in signatures and returns the real array # of runtime variables to use in the call. fun varargize(mpropdef: MMethodDef, map: nullable SignatureMap, recv: RuntimeVariable, args: SequenceRead[AExpr]): Array[RuntimeVariable] do - var msignature = mpropdef.new_msignature or else mpropdef.msignature.as(not null) + var msignature = mpropdef.msignature.as(not null) var res = new Array[RuntimeVariable] res.add(recv) diff --git a/src/doc/console_templates/console_model.nit b/src/doc/console_templates/console_model.nit index 96b1a40..7e9487f 100644 --- a/src/doc/console_templates/console_model.nit +++ b/src/doc/console_templates/console_model.nit @@ -484,16 +484,10 @@ redef class MMethodDef end redef fun cs_short_signature do - if mproperty.is_root_init then - return new_msignature.cs_short_signature - end return msignature.cs_short_signature end redef fun cs_signature do - if mproperty.is_root_init then - return new_msignature.cs_signature - end return msignature.cs_signature end diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index 545d89d..6d25e7c 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -437,7 +437,7 @@ class NaiveInterpreter # Return `null` if one of the evaluation of the arguments return null. fun varargize(mpropdef: MMethodDef, map: nullable SignatureMap, recv: Instance, args: SequenceRead[AExpr]): nullable Array[Instance] do - var msignature = mpropdef.new_msignature or else mpropdef.msignature.as(not null) + var msignature = mpropdef.msignature.as(not null) var res = new Array[Instance] res.add(recv) @@ -569,28 +569,6 @@ class NaiveInterpreter fun callsite(callsite: nullable CallSite, arguments: Array[Instance]): nullable Instance do if callsite == null then return null - var initializers = callsite.mpropdef.initializers - if not initializers.is_empty then - var recv = arguments.first - var i = 1 - for p in initializers do - if p isa MMethod then - 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 - write_attribute(p, recv, arguments[i]) - i += 1 - else abort - end - assert i == arguments.length - - return send(callsite.mproperty, [recv]) - end return send(callsite.mproperty, arguments) end diff --git a/src/model/model.nit b/src/model/model.nit index 1560022..8207bf0 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -2357,19 +2357,17 @@ class MMethodDef # The signature attached to the property definition var msignature: nullable MSignature = null is writable - # The signature attached to the `new` call on a root-init - # This is a concatenation of the signatures of the initializers - # - # REQUIRE `mproperty.is_root_init == (new_msignature != null)` - var new_msignature: nullable MSignature = null is writable - # List of initialisers to call in root-inits # # They could be setters or attributes - # - # REQUIRE `mproperty.is_root_init == (new_msignature != null)` var initializers = new Array[MProperty] + # Does the method take the responsibility to call `init`? + # + # If the method is used as an initializer, then + # using this information prevents to call `init` twice. + var is_calling_init = false is writable + # Is the method definition abstract? var is_abstract: Bool = false is writable diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index fe755a5..abce092 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -150,7 +150,6 @@ redef class ModelBuilder var mparameters = new Array[MParameter] var msignature = new MSignature(mparameters, null) mpropdef.msignature = msignature - mpropdef.new_msignature = msignature mprop.is_init = true self.toolcontext.info("{mclassdef} gets a free empty constructor {mpropdef}{msignature}", 3) the_root_init_mmethod = mprop @@ -335,7 +334,7 @@ redef class ModelBuilder # Combine the inherited list to what is collected if longest.initializers.length > 0 then - mparameters.prepend longest.new_msignature.mparameters + mparameters.prepend longest.msignature.mparameters initializers.prepend longest.initializers end end @@ -885,7 +884,6 @@ redef class AMethPropdef var root_init = mclassdef.mclass.root_init if root_init != null then # Inherit the initializers by refinement - mpropdef.new_msignature = root_init.new_msignature assert mpropdef.initializers.is_empty mpropdef.initializers.add_all root_init.initializers end diff --git a/src/rapid_type_analysis.nit b/src/rapid_type_analysis.nit index 4f3651d..9624932 100644 --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@ -245,7 +245,6 @@ class RapidTypeAnalysis v.add_monomorphic_send(vararg, self.modelbuilder.force_get_primitive_method(node, "with_native", vararg.mclass, self.mainmodule)) end - # TODO? new_msignature var sig = msignature var osig = mmeth.intro.msignature.as(not null) for i in [0..sig.arity[ do diff --git a/src/semantize/auto_super_init.nit b/src/semantize/auto_super_init.nit index 55263bd..454e9fb 100644 --- a/src/semantize/auto_super_init.nit +++ b/src/semantize/auto_super_init.nit @@ -121,7 +121,7 @@ redef class AMethPropdef return end - var msignature = candidatedef.new_msignature or else candidatedef.msignature + var msignature = candidatedef.msignature msignature = msignature.resolve_for(recvtype, anchor, mmodule, true) if msignature.arity > 0 then diff --git a/src/semantize/typing.nit b/src/semantize/typing.nit index ffabc08..4824cb4 100644 --- a/src/semantize/typing.nit +++ b/src/semantize/typing.nit @@ -378,7 +378,7 @@ private class TypeVisitor end - var msignature = mpropdef.new_msignature or else mpropdef.msignature + var msignature = mpropdef.msignature if msignature == null then return null # skip error msignature = resolve_for(msignature, recvtype, recv_is_self).as(MSignature) @@ -2008,7 +2008,7 @@ redef class ASuperExpr return end - var msignature = superprop.new_msignature or else superprop.msignature.as(not null) + var msignature = superprop.msignature.as(not null) msignature = v.resolve_for(msignature, recvtype, true).as(MSignature) var callsite = new CallSite(hot_location, recvtype, v.mmodule, v.anchor, true, superprop.mproperty, superprop, msignature, false) diff --git a/src/web/model_html.nit b/src/web/model_html.nit index 2b49b9e..2d47728 100644 --- a/src/web/model_html.nit +++ b/src/web/model_html.nit @@ -500,18 +500,10 @@ redef class MMethodDef end redef fun html_short_signature do - var new_msignature = self.new_msignature - if mproperty.is_root_init and new_msignature != null then - return new_msignature.html_short_signature - end return msignature.as(not null).html_short_signature end redef fun html_signature do - var new_msignature = self.new_msignature - if mproperty.is_root_init and new_msignature != null then - return new_msignature.html_signature - end return msignature.as(not null).html_signature end end -- 1.7.9.5