[pypy-svn] rev 1018 - pypy/trunk/src/pypy/interpreter
mwh at codespeak.net
mwh at codespeak.net
Mon Jun 23 19:20:24 CEST 2003
Author: mwh
Date: Mon Jun 23 19:20:23 2003
New Revision: 1018
Modified:
pypy/trunk/src/pypy/interpreter/opcode.py
pypy/trunk/src/pypy/interpreter/opcode_app.py
Log:
call the right metaclass in reponse to a BUILD_CLASS opcode.
Modified: pypy/trunk/src/pypy/interpreter/opcode.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/opcode.py (original)
+++ pypy/trunk/src/pypy/interpreter/opcode.py Mon Jun 23 19:20:23 2003
@@ -315,9 +315,8 @@
w_methodsdict = f.valuestack.pop()
w_bases = f.valuestack.pop()
w_name = f.valuestack.pop()
- w_metaclass = f.space.w_type # XXX do the correct thing here
- w_newclass = f.space.call_function(w_metaclass,
- w_name, w_bases, w_methodsdict)
+ w_newclass = f.space.gethelper(appfile).call(
+ "build_class", [w_name, w_bases, w_methodsdict, f.w_globals])
f.valuestack.push(w_newclass)
def STORE_NAME(f, varindex):
Modified: pypy/trunk/src/pypy/interpreter/opcode_app.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/opcode_app.py (original)
+++ pypy/trunk/src/pypy/interpreter/opcode_app.py Mon Jun 23 19:20:23 2003
@@ -183,3 +183,19 @@
## 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)
More information about the Pypy-commit
mailing list