[pypy-svn] rev 1133 - pypy/branch/builtinrefactor/pypy/interpreter
hpk at codespeak.net
hpk at codespeak.net
Mon Jul 14 21:02:30 CEST 2003
Author: hpk
Date: Mon Jul 14 21:02:28 2003
New Revision: 1133
Modified:
pypy/branch/builtinrefactor/pypy/interpreter/baseobjspace.py
pypy/branch/builtinrefactor/pypy/interpreter/opcode.py
pypy/branch/builtinrefactor/pypy/interpreter/opcode_app.py
pypy/branch/builtinrefactor/pypy/interpreter/pycode.py
Log:
- moved build_class from opcode_app to opcode.py
- initialized co_lnotab, co_firstline, co_filename in AppCode
to get better tracebacks
- little tweak to use w_builtins instead of w_builtin during
basobjcspace-initialization
Modified: pypy/branch/builtinrefactor/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/builtinrefactor/pypy/interpreter/baseobjspace.py (original)
+++ pypy/branch/builtinrefactor/pypy/interpreter/baseobjspace.py Mon Jul 14 21:02:28 2003
@@ -38,7 +38,7 @@
import os
fn = os.path.join(os.path.dirname(fn), 'builtin_app.py')
w_args = self.newtuple([self.wrap(fn), self.w_builtins, self.w_builtins])
- w_execfile = self.getattr(self.w_builtin, self.wrap('execfile'))
+ w_execfile = self.getitem(self.w_builtins, self.wrap('execfile'))
self.call(w_execfile, w_args, self.newdict([]))
def make_sys(self):
Modified: pypy/branch/builtinrefactor/pypy/interpreter/opcode.py
==============================================================================
--- pypy/branch/builtinrefactor/pypy/interpreter/opcode.py (original)
+++ pypy/branch/builtinrefactor/pypy/interpreter/opcode.py Mon Jul 14 21:02:28 2003
@@ -2,6 +2,7 @@
from pypy.interpreter.baseobjspace import OperationError, NoValue
import dis
from pypy.interpreter import pyframe, baseobjspace
+from pypy.interpreter.pycode import app2interp
# dynamically loaded application-space utilities
@@ -311,12 +312,32 @@
if unroller is not None:
raise unroller # re-raise the unroller, if any
+class app(object):
+ def __init__(self, space):
+ self.space = space
+
+ def app_build_class(self, name, bases, namespace, globals):
+ if '__metaclass__' in namespace:
+ metaclass = namespace['__metaclass__']
+ elif len(bases) > 0:
+ base = bases[0]
+ if hasattr(base, '__class__'):
+ metaclass = base.__class__
+ else:
+ metaclass = type(base)
+ elif '__metaclass__' in globals:
+ metaclass = globals['__metaclass__']
+ else:
+ metaclass = type
+ return metaclass(name, bases, namespace)
+
+ build_class = app2interp(app_build_class)
+
def BUILD_CLASS(f):
w_methodsdict = f.valuestack.pop()
w_bases = f.valuestack.pop()
w_name = f.valuestack.pop()
- w_newclass = f.space.gethelper(appfile).call(
- "build_class", [w_name, w_bases, w_methodsdict, f.w_globals])
+ w_newclass = app(f.space).build_class(w_name, w_bases, w_methodsdict, f.w_globals)
f.valuestack.push(w_newclass)
def STORE_NAME(f, varindex):
Modified: pypy/branch/builtinrefactor/pypy/interpreter/opcode_app.py
==============================================================================
--- pypy/branch/builtinrefactor/pypy/interpreter/opcode_app.py (original)
+++ pypy/branch/builtinrefactor/pypy/interpreter/opcode_app.py Mon Jul 14 21:02:28 2003
@@ -183,19 +183,3 @@
## XXX add in parent flag merging
co = compile(prog,'<string>','exec',flags,1)
return (co,globals,locals)
-
-def build_class(name, bases, namespace, globals):
- if '__metaclass__' in namespace:
- metaclass = namespace['__metaclass__']
- elif len(bases) > 0:
- base = bases[0]
- if hasattr(base, '__class__'):
- metaclass = base.__class__
- else:
- metaclass = type(base)
- elif '__metaclass__' in globals:
- metaclass = globals['__metaclass__']
- else:
- metaclass = type
-
- return metaclass(name, bases, namespace)
Modified: pypy/branch/builtinrefactor/pypy/interpreter/pycode.py
==============================================================================
--- pypy/branch/builtinrefactor/pypy/interpreter/pycode.py (original)
+++ pypy/branch/builtinrefactor/pypy/interpreter/pycode.py Mon Jul 14 21:02:28 2003
@@ -277,6 +277,9 @@
self.co_nlocals = co.co_nlocals
self.co_argcount = co.co_argcount
self.co_names = co.co_names
+ self.co_lnotab = co.co_lnotab
+ self.co_firstlineno = co.co_firstlineno
+ self.co_filename = co.co_filename
self.next_arg = self.co_argcount
def __call__(self, *args_w):
More information about the Pypy-commit
mailing list