[pypy-svn] r8949 - in pypy/branch/dist-simpler-multimethods/pypy: interpreter objspace/std
pedronis at codespeak.net
pedronis at codespeak.net
Mon Feb 7 13:03:33 CET 2005
Author: pedronis
Date: Mon Feb 7 13:03:33 2005
New Revision: 8949
Modified:
pypy/branch/dist-simpler-multimethods/pypy/interpreter/gateway.py
pypy/branch/dist-simpler-multimethods/pypy/objspace/std/dicttype.py
pypy/branch/dist-simpler-multimethods/pypy/objspace/std/model.py
pypy/branch/dist-simpler-multimethods/pypy/objspace/std/stdtypedef.py
Log:
{}.pop works again
Modified: pypy/branch/dist-simpler-multimethods/pypy/interpreter/gateway.py
==============================================================================
--- pypy/branch/dist-simpler-multimethods/pypy/interpreter/gateway.py (original)
+++ pypy/branch/dist-simpler-multimethods/pypy/interpreter/gateway.py Mon Feb 7 13:03:33 2005
@@ -127,7 +127,16 @@
assert new_sig.varargname is None,(
"built-in function %r has conflicting rest args specs" % orig_sig.func)
new_sig.varargname = argname[:-2]
-
+
+def unwrap_spec_check_w_args(orig_sig, new_sig):
+ argname = orig_sig.next()
+ assert argname.startswith('w_'), (
+ "rest arguments arg %s of built-in function %r should start 'w_'" %
+ (argname, orig_sig.func))
+ assert new_sig.varargname is None,(
+ "built-in function %r has conflicting rest args specs" % orig_sig.func)
+ new_sig.varargname = argname[2:]
+
# recipes for checking interp2app func argumes wrt unwrap_spec
unwrap_spec_checks = {
ObjSpace: unwrap_spec_check_space,
@@ -136,6 +145,7 @@
Arguments: unwrap_spec_check_arguments,
'*': unwrap_spec_check_starargs,
'args_w': unwrap_spec_check_args_w,
+ 'w_args': unwrap_spec_check_w_args,
}
def unwrap_spec_emit_space(orig_sig, new_sig):
@@ -178,6 +188,13 @@
(new_sig.through_scope_w))
new_sig.through_scope_w += 1
new_sig.run_args.append("self.args_w")
+
+def unwrap_spec_emit_w_args(orig_sig, new_sig):
+ cur = new_sig.through_scope_w
+ new_sig.setfastscope.append(
+ "self.w_args = scope_w[%d]" % cur)
+ new_sig.through_scope_w += 1
+ new_sig.run_args.append("self.w_args")
# recipes for emitting unwrapping code for arguments of a interp2app func
# wrt a unwrap_spec
@@ -188,6 +205,7 @@
Arguments: unwrap_spec_emit_arguments,
'*': unwrap_spec_emit_starargs,
'args_w': unwrap_spec_emit_args_w,
+ 'w_args': unwrap_spec_emit_w_args,
}
# unwrap_spec_check/emit for str,int,float
Modified: pypy/branch/dist-simpler-multimethods/pypy/objspace/std/dicttype.py
==============================================================================
--- pypy/branch/dist-simpler-multimethods/pypy/objspace/std/dicttype.py (original)
+++ pypy/branch/dist-simpler-multimethods/pypy/objspace/std/dicttype.py Mon Feb 7 13:03:33 2005
@@ -8,7 +8,7 @@
dict_has_key = MultiMethod('has_key', 2)
dict_clear = MultiMethod('clear', 1)
dict_get = MultiMethod('get', 3, defaults=(None,))
-dict_pop = MultiMethod('pop', 2, varargs=True)
+dict_pop = MultiMethod('pop', 2, w_varargs=True)
dict_popitem = MultiMethod('popitem', 1)
dict_setdefault = MultiMethod('setdefault', 3, defaults=(None,))
dict_update = MultiMethod('update', 2)
Modified: pypy/branch/dist-simpler-multimethods/pypy/objspace/std/model.py
==============================================================================
--- pypy/branch/dist-simpler-multimethods/pypy/objspace/std/model.py (original)
+++ pypy/branch/dist-simpler-multimethods/pypy/objspace/std/model.py Mon Feb 7 13:03:33 2005
@@ -144,6 +144,10 @@
self.name = operatorsymbol
if extras.get('general__args__', False):
self.argnames_after = ['__args__']
+ if extras.get('w_varargs', False):
+ self.argnames_after = ['w_args']
+ if extras.get('varargs_w', False):
+ self.argnames_after = ['args_w']
def install_not_sliced(self, typeorder):
return self.install(prefix = '__mm_' + self.name,
Modified: pypy/branch/dist-simpler-multimethods/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/branch/dist-simpler-multimethods/pypy/objspace/std/stdtypedef.py (original)
+++ pypy/branch/dist-simpler-multimethods/pypy/objspace/std/stdtypedef.py Mon Feb 7 13:03:33 2005
@@ -178,8 +178,10 @@
# XXX packed arguments: w_args, w_kwds instead of *args_w, **kwds_w
solid_arglist = ['w_'+name for name in argnames]
wrapper_arglist = solid_arglist[:]
- if multimethod.extras.get('varargs', False):
+ if multimethod.extras.get('varargs_w', False):
wrapper_arglist.append('args_w')
+ if multimethod.extras.get('w_varargs', False):
+ wrapper_arglist.append('w_args')
if multimethod.extras.get('keywords', False):
raise Exception, "no longer supported, use __args__"
if multimethod.extras.get('general__args__', False):
@@ -233,8 +235,10 @@
def wrap_trampoline_in_gateway(func, methname, multimethod):
unwrap_spec = [gateway.ObjSpace] + [gateway.W_Root]*multimethod.arity
- if multimethod.extras.get('varargs', False):
+ if multimethod.extras.get('varargs_w', False):
unwrap_spec.append('args_w')
+ if multimethod.extras.get('w_varargs', False):
+ unwrap_spec.append('w_args')
if multimethod.extras.get('general__args__', False):
unwrap_spec.append(gateway.Arguments)
return gateway.interp2app(func, app_name=methname, unwrap_spec=unwrap_spec)
More information about the Pypy-commit
mailing list