Commit 920aa273 authored by Stefan Marr's avatar Stefan Marr

Only method needs to handled control flow exceptions [WIP-completed]

Method invocation takes care of restarts and non-local returns, very similar to the Truffle version.
Signed-off-by: 's avatarStefan Marr <git@stefan-marr.de>
parent cac30b5e
......@@ -2,6 +2,8 @@ from __future__ import absolute_import
from rpython.rlib import jit
from som.interpreter.control_flow import ReturnException, RestartLoopException
from som.vmobjects.abstract_object import AbstractObject
class Method(AbstractObject):
......@@ -93,8 +95,24 @@ class Method(AbstractObject):
def invoke(self, frame, interpreter):
# Allocate and push a new frame on the interpreter stack
new_frame = interpreter.push_new_frame(self, None)
new_frame = interpreter.new_frame(frame, self, None)
new_frame.copy_arguments_from(frame)
while True:
try:
result = interpreter.interpret(self, new_frame)
frame.pop_old_arguments_and_push_result(self, result)
new_frame.clear_previous_frame()
return
except ReturnException as e:
if e.has_reached_target(new_frame):
frame.pop_old_arguments_and_push_result(self, e.get_result())
return
else:
new_frame.clear_previous_frame()
raise e
except RestartLoopException:
new_frame.reset_stack_pointer()
def __str__(self):
return "Method(" + self.get_holder().get_name().get_string() + ">>" + str(self.get_signature()) + ")"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment