Author: Lars Wassermann <lars.wasserm...@gmail.com> Branch: Changeset: r66:0aa0ef3aab2d Date: 2013-02-20 12:03 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/0aa0ef3aab2d/
Log: added new closure primitive numbers, added new unwrap spec list diff --git a/spyvm/objspace.py b/spyvm/objspace.py --- a/spyvm/objspace.py +++ b/spyvm/objspace.py @@ -254,6 +254,14 @@ elif isinstance(w_v, model.W_SmallInteger): return float(w_v.value) raise UnwrappingError() + def unwrap_array(self, w_array): + # Check that our argument has pointers format and the class: + if not w_array.getclass(self).is_same_object(self.w_Array): + raise PrimitiveFailedError() + assert isinstance(w_array, model.W_PointersObject) + + return [w_array.at0(self, i) for i in range(w_array.size())] + def _freeze_(self): return True diff --git a/spyvm/primitives.py b/spyvm/primitives.py --- a/spyvm/primitives.py +++ b/spyvm/primitives.py @@ -97,6 +97,9 @@ elif spec is str: assert isinstance(w_arg, model.W_BytesObject) args += (w_arg.as_string(), ) + elif spec is list: + assert isinstance(w_arg, model.W_PointersObject) + args += (interp.space.unwrap_array(w_arg), ) elif spec is char: args += (unwrap_char(w_arg), ) else: @@ -829,25 +832,20 @@ frame.pop() finalize_block_ctx(interp, s_block_ctx, frame.w_self()) -@expose_primitive(VALUE_WITH_ARGS, unwrap_spec=[object, object], +@expose_primitive(VALUE_WITH_ARGS, unwrap_spec=[object, list], no_result=True) -def func(interp, w_block_ctx, w_args): +def func(interp, w_block_ctx, l_args): 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() - # Check that our arguments have pointers format and the right size: - if not w_args.getclass(interp.space).is_same_object( - interp.space.w_Array): - raise PrimitiveFailedError() - if w_args.size() != exp_arg_cnt: + if len(l_args) != exp_arg_cnt: raise PrimitiveFailedError() - assert isinstance(w_args, model.W_PointersObject) # Push all the items from the array for i in range(exp_arg_cnt): - s_block_ctx.push(w_args.at0(interp.space, i)) + s_block_ctx.push(l_args[i]) # XXX Check original logic. Image does not test this anyway # because falls back to value + internal implementation @@ -913,6 +911,21 @@ return w_rcvr # ___________________________________________________________________________ +# BlockClosure Primitives + +CLOSURE_COPY_WITH_COPIED_VALUES = 200 +CLOSURE_VALUE = 201 +CLOSURE_VALUE_ = 202 +CLOSURE_VALUE_VALUE = 203 +CLOSURE_VALUE_VALUE_VALUE = 204 +CLOSURE_VALUE_VALUE_VALUE_VALUE = 205 +CLOSURE_VALUE_WITH_ARGS = 206 #valueWithArguments: + +@expose_primitive(CLOSURE_VALUE_WITH_ARGS, unwrap_spec=[object, list]) +def func(interp, w_block_closure, l_args): + pass + +# ___________________________________________________________________________ # PrimitiveLoadInstVar # # These are some wacky bytecodes in squeak. They are defined to do _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit