[pypy-svn] r9132 - pypy/branch/dist-interpapp/pypy/interpreter
hpk at codespeak.net
hpk at codespeak.net
Fri Feb 11 17:45:08 CET 2005
Author: hpk
Date: Fri Feb 11 17:45:08 2005
New Revision: 9132
Modified:
pypy/branch/dist-interpapp/pypy/interpreter/baseobjspace.py
pypy/branch/dist-interpapp/pypy/interpreter/gateway.py
Log:
- get rid of unused app2interp_temp_method
- preserve function name across appexec()
- slight renamings of variables
Modified: pypy/branch/dist-interpapp/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/dist-interpapp/pypy/interpreter/baseobjspace.py (original)
+++ pypy/branch/dist-interpapp/pypy/interpreter/baseobjspace.py Fri Feb 11 17:45:08 2005
@@ -276,20 +276,20 @@
raise TypeError, 'space.exec_(): expected a string, code or PyCode object'
return statement.exec_code(self, w_globals, w_locals)
- def appexec(self, posargs, source):
+ def appexec(self, posargs_w, source, funcname="anon"):
""" return value from executing given source at applevel with
given name=wrapped value parameters as its starting scope.
Note: EXPERIMENTAL.
"""
space = self
- pypyco = pypycodecache.getorbuild((space,source), buildpypycode, posargs)
+ pypyco = pypycodecache.getorbuild((space,source, funcname), buildpypycode, posargs_w)
w_glob = space.newdict([])
frame = pypyco.create_frame(space, w_glob)
- frame.setfastscope(posargs)
+ frame.setfastscope(posargs_w)
return frame.run()
pypycodecache = Cache()
-def buildpypycode((space, source), posargs):
+def buildpypycode((space, source, funcname), posargs_w):
""" NOT_RPYTHON """
# XXX will change once we have our own compiler
from pypy.interpreter.pycode import PyCode
@@ -299,10 +299,10 @@
if not argdecl.startswith('(') or not argdecl.endswith(')'):
raise SyntaxError("incorrect exec_with header\n%s" % source)
source = py.code.Source(source)
- source = source.putaround("def anon%s:" % argdecl)
+ source = source.putaround("def %s%s:" % (funcname, argdecl))
d = {}
exec source.compile() in d
- newco = d['anon'].func_code
+ newco = d[funcname].func_code
return PyCode(space)._from_code(newco)
## Table describing the regular part of the interface of object spaces,
Modified: pypy/branch/dist-interpapp/pypy/interpreter/gateway.py
==============================================================================
--- pypy/branch/dist-interpapp/pypy/interpreter/gateway.py (original)
+++ pypy/branch/dist-interpapp/pypy/interpreter/gateway.py Fri Feb 11 17:45:08 2005
@@ -624,7 +624,7 @@
# SOME MESS AHEAD !
# construct the special app source passed to appexec
- appsource = py.code.Source(source).strip().putaround("(%s):" % fastscope, "")
+ appsource = py.code.Source(source).strip().putaround("(%s):" % fastscope)
sourcelines = ["def %(funcname)s(space, %(wfuncdecl)s):" % locals()]
sourcelines.extend(defaulthandlingsource.indent().lines)
sourcelines.append(
@@ -632,7 +632,7 @@
for line in appsource.indent().indent().lines:
line = line.replace("\\", r"\\").replace("'", r"\'")
sourcelines.append(line)
- sourcelines.append( "''')")
+ sourcelines.append( "''', funcname=%r)" % funcname)
source = py.code.Source()
source.lines = sourcelines
glob = {}
@@ -679,22 +679,6 @@
""" NOT_RPYTHON """
self.appfunc = appdef(func, overridename)
- def __get__(self, instance, cls=None):
- """ NOT_RPYTHON """
- return app2interp_temp_method(self.appfunc, instance)
-
def __call__(self, space, *args_w, **kwargs_w):
""" NOT_RPYTHON """
return self.appfunc(space, *args_w, **kwargs_w)
-
-class app2interp_temp_method(object):
- def __init__(self, func, instance):
- """ NOT_RPYTHON """
- self.func = func
- self.instance = instance
-
- def __call__(self, *args_w, **kwargs_w):
- """ NOT_RPYTHON """
- space = self.instance.space
- return self.appfunc(space, space.wrap(self.instance),
- *args_w, **kwargs_w)
More information about the Pypy-commit
mailing list