[pypy-commit] lang-smalltalk default: changed the sequence of speical objects. now, nil should be first to be matched. If any later special object is also set to nil, nil's w_object will not be overwritten.

lwassermann noreply at buildbot.pypy.org
Mon Feb 25 16:21:31 CET 2013


Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch: 
Changeset: r97:2b3b4d9fc7ae
Date: 2013-02-25 16:15 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/2b3b4d9fc7ae/

Log:	changed the sequence of speical objects. now, nil should be first to
	be matched. If any later special object is also set to nil, nil's
	w_object will not be overwritten.

diff --git a/spyvm/error.py b/spyvm/error.py
--- a/spyvm/error.py
+++ b/spyvm/error.py
@@ -23,5 +23,5 @@
     def __init__(self, msg):
         self.msg = msg
 
-class BlockCannotReturnError(PrimitiveFailedError):
+class BlockCannotReturnError(SmalltalkException):
 	pass
\ No newline at end of file
diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -258,6 +258,8 @@
             raise ReturnFromTopLevel(object)
         # widow this context
         self.store_pc(None)
+        self.store_w_sender(self.space.w_nil)
+
         w_return_to.as_context_get_shadow(self.space).push(object)
         return w_return_to
 
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -930,7 +930,7 @@
 
 
 def activateClosure(interp, s_frame, w_block, args_w, mayContextSwitch=True):
-    # XXX may context switch is ignored
+    # XXX mayContextSwitch is ignored
     space = interp.space
     if not w_block.getclass(space).is_same_object(
             space.w_BlockClosure):
diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py
--- a/spyvm/squeakimage.py
+++ b/spyvm/squeakimage.py
@@ -264,14 +264,22 @@
             chunk.g_object.init_w_object()
 
     def assign_prebuilt_constants(self):
+        # assign w_objects for objects that are already in objtable
+        for name, so_index in constants.objects_in_special_object_table.items():
+            w_object = self.space.objtable["w_" + name]
+            if self.special_object(so_index).w_object is None:
+                self.special_object(so_index).w_object = w_object
+            else:
+                if self.special_object(0).w_object is not self.space.w_nil:
+                   raise Warning('Object found in multiple places in the special objects array')
         # assign w_objects for objects that are already in classtable
         for name, so_index in constants.classes_in_special_object_table.items():
             w_object = self.space.classtable["w_" + name]
-            self.special_object(so_index).w_object = w_object
-        # assign w_objects for objects that are already in objtable
-        for name, so_index in constants.objects_in_special_object_table.items():
-            w_object = self.space.objtable["w_" + name]
-            self.special_object(so_index).w_object = w_object
+            if self.special_object(so_index).w_object is None:
+                self.special_object(so_index).w_object = w_object
+            else:
+                if self.special_object(0).w_object is not self.space.w_nil:
+                   raise Warning('Object found in multiple places in the special objects array')
 
     def special_object(self, index):
         special = self.chunks[self.specialobjectspointer].g_object.pointers


More information about the pypy-commit mailing list