Author: Lars Wassermann <lars.wasserm...@gmail.com>
Branch: 
Changeset: r67:256ad8186a3b
Date: 2013-02-20 15:42 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/256ad8186a3b/

Log:    moved createClosure from contextPart to objectsSpace

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -400,15 +400,6 @@
         index_in_array, w_indirectTemps = self._extract_index_and_temps()
         w_indirectTemps.atput0(self.space, index_in_array, self.pop())
 
-    def _newClosure(self, numArgs, pc, numCopied):
-        BlockClosureShadow = 
self.space.w_BlockClosure.as_class_get_shadow(self.space)
-        w_closure = BlockClosureShadow.new(numCopied)
-        closure = wrapper.BlockClosureWrapper(self.space, w_closure)
-        closure.store_outerContext(self._w_self)
-        closure.store_startpc(pc)
-        closure.store_numArgs(numArgs)
-        return closure, w_closure
-
     def pushClosureCopyCopiedValuesBytecode(self, interp):
         """ Copied from Blogpost: 
http://www.mirandabanda.org/cogblog/2008/07/22/closures-part-ii-the-bytecodes/
         ContextPart>>pushClosureCopyNumCopiedValues: numCopied numArgs: 
numArgs blockSize: blockSize
@@ -436,11 +427,8 @@
         i = self.getbytecode()
         blockSize = (j << 8) | i
         #create new instance of BlockClosure
-        closure, w_closure = self._newClosure(numArgs, self.pc(), numCopied)
-        if numCopied > 0:
-            copiedValues = self.pop_and_return_n(numCopied)
-            for i0 in range(numCopied):
-                closure.atput0(i0, copiedValues[i0])
+        w_closure, closure = space.newClosure(self._w_self, self.pc(), 
numArgs, 
+                                            self.pop_and_return_n(numCopied))
         self.push(w_closure)
         self.jump(blockSize)
 
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -1,6 +1,4 @@
-from spyvm import constants
-from spyvm import model
-from spyvm import shadow
+from spyvm import constants, model, shadow, wrapper
 from spyvm.error import UnwrappingError, WrappingError
 from rpython.rlib.objectmodel import instantiate
 from rpython.rlib.rarithmetic import intmask, r_uint
@@ -265,6 +263,16 @@
     def _freeze_(self):
         return True
 
+    def newClosure(self, outerContext, pc, numArgs, copiedValues):
+        BlockClosureShadow = self.w_BlockClosure.as_class_get_shadow(self)
+        w_closure = BlockClosureShadow.new(len(copiedValues))
+        closure = wrapper.BlockClosureWrapper(self, w_closure)
+        closure.store_outerContext(outerContext)
+        closure.store_startpc(pc)
+        closure.store_numArgs(numArgs)
+        for i0 in range(len(copiedValues)):
+            closure.atput0(i0, copiedValues[i0])
+        return w_closure, closure
 
 def bootstrap_class(space, instsize, w_superclass=None, w_metaclass=None,
                     name='?', format=shadow.POINTERS, varsized=False):
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -834,18 +834,18 @@
     
 @expose_primitive(VALUE_WITH_ARGS, unwrap_spec=[object, list],
                   no_result=True)
-def func(interp, w_block_ctx, l_args):
+def func(interp, w_block_ctx, args_w):
 
     assert isinstance(w_block_ctx, model.W_PointersObject)
     s_block_ctx = w_block_ctx.as_blockcontext_get_shadow(interp.space)
     exp_arg_cnt = s_block_ctx.expected_argument_count()
 
-    if len(l_args) != exp_arg_cnt:
+    if len(args_w) != exp_arg_cnt:
         raise PrimitiveFailedError()
     
     # Push all the items from the array
     for i in range(exp_arg_cnt):
-        s_block_ctx.push(l_args[i])
+        s_block_ctx.push(args_w[i])
 
     # XXX Check original logic. Image does not test this anyway
     # because falls back to value + internal implementation
diff --git a/spyvm/test/test_primitives.py b/spyvm/test/test_primitives.py
--- a/spyvm/test/test_primitives.py
+++ b/spyvm/test/test_primitives.py
@@ -30,6 +30,7 @@
     if isinstance(x, model.W_Object): return x
     if isinstance(x, str) and len(x) == 1: return space.wrap_char(x)
     if isinstance(x, str): return space.wrap_string(x)
+    if isinstance(x, list): return space.wrap_list(x)
     raise NotImplementedError
     
 def mock(stack):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to