nitc :: AMethPropdef :: call_commons
It handle the common special cases: super, intern, extern
# Execution of the body of the method
#
# It handle the common special cases: super, intern, extern
fun call_commons(v: NaiveInterpreter, mpropdef: MMethodDef, arguments: Array[Instance], f: Frame): nullable Instance
do
v.frames.unshift(f)
for i in [0..mpropdef.msignature.arity[ do
var variable = self.n_signature.n_params[i].variable
assert variable != null
v.write_variable(variable, arguments[i+1])
end
# Call the implicit super-init
var auto_super_inits = self.auto_super_inits
if auto_super_inits != null then
var args = [arguments.first]
for auto_super_init in auto_super_inits do
args.clear
for i in [0..auto_super_init.msignature.arity+1[ do
args.add(arguments[i])
end
assert auto_super_init.mproperty != mpropdef.mproperty
v.callsite(auto_super_init, args)
end
end
if auto_super_call then
# standard call-next-method
var superpd = mpropdef.lookup_next_definition(v.mainmodule, arguments.first.mtype)
v.call(superpd, arguments)
end
# First, try intern
if mpropdef.is_intern or mpropdef.is_extern then
var res = intern_call(v, mpropdef, arguments)
if res != v.error_instance then return res
end
# Then, try extern
if mpropdef.is_extern then
var res = call_extern(v, mpropdef, arguments, f)
if res != v.error_instance then return res
end
# Else try block
if n_block != null then
v.stmt(self.n_block)
return null
end
# Fail if nothing succeed
if mpropdef.is_intern then
fatal(v, "NOT YET IMPLEMENTED intern {mpropdef}")
else if mpropdef.is_extern then
fatal(v, "NOT YET IMPLEMENTED extern {mpropdef}")
else
fatal(v, "NOT YET IMPLEMENTED <wat?> {mpropdef}")
end
abort
end
src/interpreter/naive_interpreter.nit:913,2--970,4