[pypy-svn] r9410 - in pypy/dist/pypy: objspace/std translator
pedronis at codespeak.net
pedronis at codespeak.net
Tue Feb 22 17:29:50 CET 2005
Author: pedronis
Date: Tue Feb 22 17:29:50 2005
New Revision: 9410
Modified:
pypy/dist/pypy/objspace/std/stdtypedef.py
pypy/dist/pypy/translator/genc.py
Log:
changes to have translate.py -no-a at least finish compilation
Modified: pypy/dist/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stdtypedef.py (original)
+++ pypy/dist/pypy/objspace/std/stdtypedef.py Tue Feb 22 17:29:50 2005
@@ -137,6 +137,7 @@
def sliced_typeorders(typeorder, multimethod, typedef, i, local=False):
+ """NOT_RPYTHON"""
list_of_typeorders = [typeorder] * multimethod.arity
prefix = '_mm_' + multimethod.name
if not local:
@@ -170,6 +171,7 @@
def make_perform_trampoline(prefix, exprargs, expr, miniglobals, multimethod, selfindex=0,
allow_NotImplemented_results=False):
+ """NOT_RPYTHON"""
# mess to figure out how to put a gateway around executing expr
argnames = ['_%d'%(i+1) for i in range(multimethod.arity)]
explicit_argnames = multimethod.extras.get('argnames', [])
@@ -241,6 +243,7 @@
return miniglobals["%s_perform_call" % prefix]
def wrap_trampoline_in_gateway(func, methname, multimethod):
+ """NOT_RPYTHON"""
unwrap_spec = [gateway.ObjSpace] + [gateway.W_Root]*multimethod.arity
if multimethod.extras.get('varargs_w', False):
unwrap_spec.append('args_w')
@@ -251,6 +254,7 @@
return gateway.interp2app(func, app_name=methname, unwrap_spec=unwrap_spec)
def slicemultimethod(space, multimethod, typedef, result, local=False):
+ """NOT_RPYTHON"""
for i in range(len(multimethod.specialnames)):
methname = multimethod.specialnames[i]
if methname in result:
@@ -261,6 +265,7 @@
continue
def multimethod_loader(i=i, methname=methname):
+ """NOT_RPYTHON"""
prefix, list_of_typeorders = sliced_typeorders(
space.model.typeorder, multimethod, typedef, i, local=local)
exprargs, expr, miniglobals, fallback = multimethod.install(prefix, list_of_typeorders,
@@ -277,6 +282,7 @@
result[methname] = multimethod_loader
def slicemultimethods(space, typedef):
+ """NOT_RPYTHON"""
result = {}
# import and slice all multimethods of the space.MM container
for multimethod in hack_out_multimethods(space.MM.__dict__):
Modified: pypy/dist/pypy/translator/genc.py
==============================================================================
--- pypy/dist/pypy/translator/genc.py (original)
+++ pypy/dist/pypy/translator/genc.py Tue Feb 22 17:29:50 2005
@@ -112,6 +112,7 @@
def initcode_python(self, name, pyexpr):
# generate init code that will evaluate the given Python expression
+ #self.initcode.append("print 'setting up', %r" % name)
self.initcode.append("%s = %s" % (name, pyexpr))
def nameof_object(self, value):
@@ -247,8 +248,19 @@
for key, value in content:
if self.should_translate_attr(instance, key):
yield '%s.%s = %s' % (name, key, self.nameof(value))
+ if hasattr(instance,'__reduce_ex__'):
+ import copy_reg
+ reduced = instance.__reduce_ex__()
+ assert reduced[0] is copy_reg._reconstructor
+ state = reduced[1][2]
+ else:
+ state = None
self.initcode.append('if isinstance(%s, type):' % cls)
- self.initcode.append(' %s = %s.__new__(%s)' % (name, cls, cls))
+ if state is not None:
+ #print "INST",' %s = %s.__new__(%s, %r)' % (name, cls, cls, state)
+ self.initcode.append(' %s = %s.__new__(%s, %r)' % (name, cls, cls, state))
+ else:
+ self.initcode.append(' %s = %s.__new__(%s)' % (name, cls, cls))
self.initcode.append('else:')
self.initcode.append(' %s = new.instance(%s)' % (name, cls))
self.later(initinstance())
@@ -337,6 +349,7 @@
InstanceType: 'types.InstanceType',
type(None): 'type(None)',
CodeType: 'types.CodeType',
+ type(sys): 'type(new)',
r_int: 'int', # XXX
r_uint: 'int', # XXX
More information about the Pypy-commit
mailing list