[pypy-svn] r13042 - pypy/branch/rpython-refactoring
arigo at codespeak.net
arigo at codespeak.net
Sat Jun 4 00:36:44 CEST 2005
Author: arigo
Date: Sat Jun 4 00:36:44 2005
New Revision: 13042
Modified:
pypy/branch/rpython-refactoring/rclass.py
pypy/branch/rpython-refactoring/robject.py
pypy/branch/rpython-refactoring/rpbc.py
Log:
Almost finished.
Modified: pypy/branch/rpython-refactoring/rclass.py
==============================================================================
--- pypy/branch/rpython-refactoring/rclass.py (original)
+++ pypy/branch/rpython-refactoring/rclass.py Sat Jun 4 00:36:44 2005
@@ -1,8 +1,7 @@
from pypy.annotation.pairtype import pairtype
from pypy.annotation import model as annmodel
from pypy.rpython.lltype import *
-from pypy.rpython.rtyper import inputconst
-
+from pypy.rpython.rmodel import Repr, TyperError, inputconst
#
# There is one "vtable" per user class, with the following structure:
@@ -103,9 +102,7 @@
return result
-def rtype_new_instance(s_cls, hop):
- assert s_cls.is_constant()
- cls = s_cls.const
+def rtype_new_instance(cls, hop):
classdef = hop.rtyper.annotator.getuserclasses()[cls]
rclassdef = getrclassdef(classdef)
return rclassdef.rtype_new_instance(hop.llops)
@@ -113,16 +110,26 @@
# ____________________________________________________________
-class __extend__(SomeInstance):
+class __extend__(annmodel.SomeInstance):
+ def rtyper_makerepr(self, rtyper):
+ return InstanceRepr(self.classdef)
- def lowleveltype(s_ins):
- rclassdef = getrclassdef(s_ins.classdef)
- return GcPtr(rclassdef.object_type)
-
- def rtype_type(s_ins, hop):
- rclassdef = getrclassdef(s_ins.classdef)
- vptr, = hop.inputargs(s_ins)
- vptr_as_object = rclassdef.parent_cast(None, vptr, hop.llops)
- typeptr_name = inputconst(Void, "typeptr")
+
+class InstanceRepr(Repr):
+
+ def __init__(self, classdef):
+ self.rclassdef = getrclassdef(classdef)
+ self.lowleveltype = GcPtr(self.rclassdef.object_type)
+
+ def rtype_type(self, hop):
+ vptr, = hop.inputargs(self)
+ vptr_as_object = self.rclassdef.parent_cast(None, vptr, hop.llops)
+ typeptr_name = hop.inputconst(Void, "typeptr")
return hop.genop('getfield', [vptr_as_object, typeptr_name],
resulttype=TYPEPTR)
+
+
+class TypeRepr(Repr):
+ lowleveltype = TYPEPTR
+
+type_repr = TypeRepr()
Modified: pypy/branch/rpython-refactoring/robject.py
==============================================================================
--- pypy/branch/rpython-refactoring/robject.py (original)
+++ pypy/branch/rpython-refactoring/robject.py Sat Jun 4 00:36:44 2005
@@ -2,7 +2,7 @@
from pypy.annotation import model as annmodel
from pypy.rpython.lltype import PyObject, GcPtr, Void, Bool
from pypy.rpython.rmodel import Repr, TyperError
-#from pypy.rpython import rclass
+from pypy.rpython import rclass
class __extend__(annmodel.SomeObject):
Modified: pypy/branch/rpython-refactoring/rpbc.py
==============================================================================
--- pypy/branch/rpython-refactoring/rpbc.py (original)
+++ pypy/branch/rpython-refactoring/rpbc.py Sat Jun 4 00:36:44 2005
@@ -3,7 +3,7 @@
from pypy.annotation import model as annmodel
from pypy.rpython.lltype import typeOf, Void
from pypy.rpython.rmodel import Repr, TyperError
-#from pypy.rpython import rclass
+from pypy.rpython import rclass
class __extend__(annmodel.SomePBC):
@@ -44,4 +44,4 @@
return hop.genop('direct_call', [c] + args_v,
resulttype = rresult)
elif isinstance(func, (types.ClassType, type)):
- return rclass.rtype_new_instance(s_func, hop)
+ return rclass.rtype_new_instance(s_func.const, hop)
More information about the Pypy-commit
mailing list