[pypy-svn] r26011 - pypy/dist/pypy/rpython/lltypesystem
tismer at codespeak.net
tismer at codespeak.net
Thu Apr 20 00:30:54 CEST 2006
Author: tismer
Date: Thu Apr 20 00:30:52 2006
New Revision: 26011
Modified:
pypy/dist/pypy/rpython/lltypesystem/rclass.py
Log:
- create __self__ attribute also in the absence of wrapper
- bugfix for setfield if the wrapper is not in the same class
Modified: pypy/dist/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rclass.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/rclass.py Thu Apr 20 00:30:52 2006
@@ -470,7 +470,7 @@
else:
if self.classdef is None:
raise MissingRTypeAttribute(attr)
- self.rbase.setfield(vinst, attr, vvalue, llops, force_cast=True)
+ self.rbase.setfield(vinst, attr, vvalue, llops, force_cast=True, opname=opname)
def new_instance(self, llops):
"""Build a new instance, without calling __init__."""
@@ -639,13 +639,13 @@
v_inst, c_spec = hop.inputargs(*hop.args_r)
repr = c_spec.value
v_res = into_cobject(v_inst, repr, hop.llops)
+ v_cobj = v_res
+ c_cls = hop.inputconst(pyobj_repr, repr.classdef.classdesc.pyobj)
+ c_0 = hop.inputconst(Signed, 0)
+ v_res = hop.llops.gencapicall('PyType_GenericAlloc', [c_cls, c_0], resulttype=pyobj_repr)
+ c_self = hop.inputconst(pyobj_repr, '__self__')
+ hop.genop('setattr', [v_res, c_self, v_cobj], resulttype=pyobj_repr)
if repr.has_wrapper:
- v_cobj = v_res
- c_cls = hop.inputconst(pyobj_repr, repr.classdef.classdesc.pyobj)
- c_0 = hop.inputconst(Signed, 0)
- v_res = hop.llops.gencapicall('PyType_GenericAlloc', [c_cls, c_0], resulttype=pyobj_repr)
- c_self = hop.inputconst(pyobj_repr, '__self__')
- hop.genop('setattr', [v_res, c_self, v_cobj], resulttype=pyobj_repr)
repr.setfield(v_inst, '_wrapper_', v_res, hop.llops)
hop.genop('gc_unprotect', [v_res]) # yes a weak ref
return v_res
@@ -702,9 +702,9 @@
r_to.setfield(v_inst, '_wrapper_', v, llops)
llops.genop('gc_unprotect', [v])
return v_inst
-
- c_self = inputconst(pyobj_repr, '__self__')
- v = llops.genop('getattr', [v, c_self], resulttype=r_from)
+ # if we don't have a wrapper field, we just don't support __init__
+ c_self = inputconst(pyobj_repr, '__self__')
+ v = llops.genop('getattr', [v, c_self], resulttype=r_from)
return outof_cobject(v, r_to, llops)
# ____________________________________________________________
More information about the Pypy-commit
mailing list