diff --git a/src/main/vm/runtime/interpreter.cpp b/src/main/vm/runtime/interpreter.cpp index 0a47ee41676405000e7b69f9df67c39a17c7111d..70c38540613f70c237da0a2c26c1e780843a383b 100644 --- a/src/main/vm/runtime/interpreter.cpp +++ b/src/main/vm/runtime/interpreter.cpp @@ -86,25 +86,27 @@ void Interpreter::initialize() { } void Interpreter::build_frame(HiObject* callable, ObjList args, int op_arg) { - if (callable->klass() == NativeFunctionKlass::get_instance()) { - PUSH(((FunctionObject*)callable)->call(args)); + Handle h_callable(callable); + Handle h_args(args); + if (h_callable->klass() == NativeFunctionKlass::get_instance()) { + PUSH(((FunctionObject*)h_callable())->call(args)); } - else if (callable->klass() == MethodKlass::get_instance()) { - MethodObject* method = (MethodObject*) callable; + else if (h_callable->klass() == MethodKlass::get_instance()) { + Handle method((MethodObject*) callable); // return value is ignored here, because they are handled // by other pathes. - if (!args) { - args = NEW_ARRAYLIST(HiObject*, 1); + if (!h_args()) { + h_args = NEW_ARRAYLIST(HiObject*, 1); } - args->insert(0, method->owner()); - build_frame(method->func(), args, op_arg + 1); + h_args->insert(0, method->owner()); + build_frame(method->func(), h_args(), op_arg + 1); } else if (MethodObject::is_yield_function(callable)) { Generator* gtor = new Generator((FunctionObject*) callable, args, op_arg); PUSH(gtor); return; } - else if (callable->klass() == FunctionKlass::get_instance()) { + else if (h_callable->klass() == FunctionKlass::get_instance()) { FrameObject* frame = new FrameObject(); frame->set_sender(_frame); _frame = frame; @@ -114,13 +116,13 @@ void Interpreter::build_frame(HiObject* callable, ObjList args, int op_arg) { */ _frame->initialize((FunctionObject*) callable, args, op_arg); } - else if (callable->klass() == TypeKlass::get_instance()) { + else if (h_callable->klass() == TypeKlass::get_instance()) { HiObject* inst = ((HiTypeObject*)callable)->own_klass()-> allocate_instance(callable, args); PUSH(inst); } else { - HiObject* m = callable->get_klass_attr(ST(call)); + HiObject* m = h_callable->get_klass_attr(ST(call)); if (m != Universe::HiNone) build_frame(m, args, op_arg); else { diff --git a/src/main/vm/util/handles.cpp b/src/main/vm/util/handles.cpp index 6ce7a82550edd9d7933b6afbe010afd72309afd9..455a6515897d31954985a547e4e343a1977877b0 100644 --- a/src/main/vm/util/handles.cpp +++ b/src/main/vm/util/handles.cpp @@ -95,6 +95,9 @@ template class Handle; class HiDict; template class Handle; +class MethodObject; +template class Handle; + class Generator; template class Handle;