Commits

Lars Wassermann committed 0cff3f7

merge the different approaches to exiting using a new exception: Exit
implemented Quit-Primitive (139)

Comments (0)

Files changed (4)

                                 else:
                                     pass # XXX: Todo?
                     elif c_type == RSDL.QUIT:
-                        from spyvm.interpreter import ReturnFromTopLevel
-                        print "Window closed.."
-                        raise SystemExit()
+                        from spyvm.error import Exit
+                        raise Exit("Window closed..")
         finally:
             lltype.free(event, flavor='raw')
 
         self.msg = msg
 
 class BlockCannotReturnError(SmalltalkException):
-	pass
+	pass
+
+class Exit(Exception):
+    def __init__(self, msg):
+        self.msg = msg

spyvm/primitives.py

 
 @expose_primitive(FAIL)
 def func(interp, s_frame, argcount):
-    from spyvm.interpreter import ReturnFromTopLevel
+    from spyvm.error import Exit
     if s_frame.w_method()._likely_methodname == 'doesNotUnderstand:':
-        print 'Probably Debugger called...'
-        raise ReturnFromTopLevel(interp.space.wrap_string("debugger called"))
+        raise Exit('Probably Debugger called...')
     raise PrimitiveFailedError()
 
 # ___________________________________________________________________________
 
 @expose_primitive(QUIT, unwrap_spec=[object])
 def func(interp, s_frame, w_rcvr):
-    raise PrimitiveNotYetWrittenError()
+    from spyvm.error import Exit
+    raise Exit('Quit-Primitive called..')
 
 @expose_primitive(EXIT_TO_DEBUGGER, unwrap_spec=[object])
 def func(interp, s_frame, w_rcvr):
+    from rpython.rlib import objectmodel
+    if not objectmodel.we_are_translated():
+        import pdb; pdb.set_trace()
     raise PrimitiveNotYetWrittenError()
 
 @expose_primitive(CHANGE_CLASS, unwrap_spec=[object, object], no_result=True)

targetimageloadingsmalltalk.py

 from rpython.rlib.streamio import open_file_as_stream
 from rpython.rlib import jit
 
-from spyvm import model, interpreter, squeakimage, objspace, wrapper, model
+from spyvm import model, interpreter, squeakimage, objspace, wrapper, model, \
+                error
 from spyvm.tool.analyseimage import create_image
 
 
         w_result = interp.perform(w_object, benchmark)
     except interpreter.ReturnFromTopLevel, e:
         w_result = e.object
+    except error.Exit, e:
+        print e.msg
     t2 = time.time()
     if w_result:
         if isinstance(w_result, model.W_BytesObject):
     w_ctx = ap.suspended_context()
     assert isinstance(w_ctx, model.W_PointersObject)
     ap.store_suspended_context(space.w_nil)
-    interp.interpret_with_w_frame(w_ctx)
+    try:
+        interp.interpret_with_w_frame(w_ctx)
+    except error.Exit, e:
+        print e.msg
     return 0