[pypy-svn] r50164 - in pypy/dist/pypy: rlib rpython
arigo at codespeak.net
arigo at codespeak.net
Fri Dec 28 19:35:44 CET 2007
Author: arigo
Date: Fri Dec 28 19:35:44 2007
New Revision: 50164
Modified:
pypy/dist/pypy/rlib/rarithmetic.py
pypy/dist/pypy/rpython/rfloat.py
Log:
Ordering issue: the lazy registering hacks for SomeSingleFloat() didn't
quite work, because SomeSingleFloat() can also be found via the
annotation_to_llmap table in annotation/model.py and then the
rtyper_makerepr() method is missing.
Modified: pypy/dist/pypy/rlib/rarithmetic.py
==============================================================================
--- pypy/dist/pypy/rlib/rarithmetic.py (original)
+++ pypy/dist/pypy/rlib/rarithmetic.py Fri Dec 28 19:35:44 2007
@@ -478,13 +478,15 @@
_type_ = r_singlefloat
def compute_annotation(self):
- return _somesinglefloat()
+ from pypy.annotation import model as annmodel
+ return annmodel.SomeSingleFloat()
class For_r_singlefloat_type_Entry(extregistry.ExtRegistryEntry):
_about_ = r_singlefloat
def compute_result_annotation(self, *args_s, **kwds_s):
- return _somesinglefloat()
+ from pypy.annotation import model as annmodel
+ return annmodel.SomeSingleFloat()
def specialize_call(self, hop):
from pypy.rpython.lltypesystem import lltype
@@ -493,31 +495,3 @@
# we use cast_primitive to go between Float and SingleFloat.
return hop.genop('cast_primitive', [v],
resulttype = lltype.SingleFloat)
-
-def _somesinglefloat():
- """Returns SomeSingleFloat(), but also lazily register the rtyping support
- for SomeSingleFloat.
- """
- from pypy.annotation import model as annmodel
-
- if 'rtyper_makerepr' not in annmodel.SomeSingleFloat.__dict__:
- from pypy.rpython.lltypesystem import lltype
- from pypy.rpython.rmodel import Repr
-
- class SingleFloatRepr(Repr):
- lowleveltype = lltype.SingleFloat
-
- def rtype_float(self, hop):
- v, = hop.inputargs(lltype.SingleFloat)
- hop.exception_cannot_occur()
- # we use cast_primitive to go between Float and SingleFloat.
- return hop.genop('cast_primitive', [v],
- resulttype = lltype.Float)
-
- class __extend__(annmodel.SomeSingleFloat):
- def rtyper_makerepr(self, rtyper):
- return SingleFloatRepr()
- def rtyper_makekey(self):
- return self.__class__,
-
- return annmodel.SomeSingleFloat()
Modified: pypy/dist/pypy/rpython/rfloat.py
==============================================================================
--- pypy/dist/pypy/rpython/rfloat.py (original)
+++ pypy/dist/pypy/rpython/rfloat.py Fri Dec 28 19:35:44 2007
@@ -216,3 +216,25 @@
resulttype=pyobj_repr,
_callable=lambda x: pyobjectptr(x))
return NotImplemented
+
+# ____________________________________________________________
+# Support for r_singlefloat from pypy.rlib.rarithmetic
+
+from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.rmodel import Repr
+
+class __extend__(annmodel.SomeSingleFloat):
+ def rtyper_makerepr(self, rtyper):
+ return SingleFloatRepr()
+ def rtyper_makekey(self):
+ return self.__class__,
+
+class SingleFloatRepr(Repr):
+ lowleveltype = lltype.SingleFloat
+
+ def rtype_float(self, hop):
+ v, = hop.inputargs(lltype.SingleFloat)
+ hop.exception_cannot_occur()
+ # we use cast_primitive to go between Float and SingleFloat.
+ return hop.genop('cast_primitive', [v],
+ resulttype = lltype.Float)
More information about the Pypy-commit
mailing list