X-Git-Url: http://nitlanguage.org diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index 82800cf..189f293 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -25,7 +25,7 @@ import primitive_types redef class ToolContext # --discover-call-trace - var opt_discover_call_trace = new OptionBool("Trace calls of the first invocation of a method", "--discover-call-trace") + var opt_discover_call_trace = new OptionBool("Trace calls of the first invocation of methods", "--discover-call-trace") redef init do @@ -157,7 +157,7 @@ class NaiveInterpreter n.debug("inconsitance: no value and not escaping.") end var implicit_cast_to = n.implicit_cast_to - if implicit_cast_to != null then + if i != null and implicit_cast_to != null then var mtype = self.unanchor_type(implicit_cast_to) if not self.is_subtype(i.mtype, mtype) then n.fatal(self, "Cast failed. Expected `{implicit_cast_to}`, got `{i.mtype}`") end @@ -471,8 +471,8 @@ class NaiveInterpreter res.add(null_instance) continue end - if param.is_vararg and map.vararg_decl > 0 then - var vararg = exprs.sub(j, map.vararg_decl) + if param.is_vararg and args[i].vararg_decl > 0 then + var vararg = exprs.sub(j, args[i].vararg_decl) var elttype = param.mtype.anchor_to(self.mainmodule, recv.mtype.as(MClassType)) var arg = self.array_instance(vararg, elttype) res.add(arg) @@ -528,8 +528,10 @@ class NaiveInterpreter do var msignature = mpropdef.msignature.as(not null) for i in [0..msignature.arity[ do + var mp = msignature.mparameters[i] + # skip test for vararg since the array is instantiated with the correct polymorphic type - if msignature.vararg_rank == i then continue + if mp.is_vararg then continue # skip if the cast is not required var origmtype = mpropdef.mproperty.intro.msignature.mparameters[i].mtype @@ -538,7 +540,7 @@ class NaiveInterpreter #print "{mpropdef}: {mpropdef.mproperty.intro.msignature.mparameters[i]}" # get the parameter type - var mtype = msignature.mparameters[i].mtype + var mtype = mp.mtype var anchor = args.first.mtype.as(MClassType) var amtype = mtype.anchor_to(self.mainmodule, anchor) if not args[i+1].mtype.is_subtype(self.mainmodule, anchor, amtype) then @@ -566,6 +568,7 @@ class NaiveInterpreter # Use this method, instead of `send` to execute and control the additional behavior of the call-sites 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