[pypy-svn] r77280 - in pypy/branch/fast-forward/pypy: annotation rpython translator/c

afa at codespeak.net afa at codespeak.net
Wed Sep 22 20:19:13 CEST 2010


Author: afa
Date: Wed Sep 22 20:19:12 2010
New Revision: 77280

Modified:
   pypy/branch/fast-forward/pypy/annotation/binaryop.py
   pypy/branch/fast-forward/pypy/annotation/model.py
   pypy/branch/fast-forward/pypy/rpython/rfloat.py
   pypy/branch/fast-forward/pypy/translator/c/primitive.py
Log:
Fix translation of the "long double" datatype


Modified: pypy/branch/fast-forward/pypy/annotation/binaryop.py
==============================================================================
--- pypy/branch/fast-forward/pypy/annotation/binaryop.py	(original)
+++ pypy/branch/fast-forward/pypy/annotation/binaryop.py	Wed Sep 22 20:19:12 2010
@@ -13,7 +13,7 @@
 from pypy.annotation.model import SomePBC, SomeFloat, s_None
 from pypy.annotation.model import SomeExternalObject, SomeWeakRef
 from pypy.annotation.model import SomeAddress, SomeTypedAddressAccess
-from pypy.annotation.model import SomeSingleFloat
+from pypy.annotation.model import SomeSingleFloat, SomeLongFloat
 from pypy.annotation.model import unionof, UnionError, missing_operation
 from pypy.annotation.model import isdegenerated, TLS
 from pypy.annotation.model import read_can_only_throw
@@ -490,6 +490,12 @@
         return SomeSingleFloat()
 
 
+class __extend__(pairtype(SomeLongFloat, SomeLongFloat)):
+    
+    def union((flt1, flt2)):
+        return SomeLongFloat()
+
+
 class __extend__(pairtype(SomeList, SomeList)):
 
     def union((lst1, lst2)):

Modified: pypy/branch/fast-forward/pypy/annotation/model.py
==============================================================================
--- pypy/branch/fast-forward/pypy/annotation/model.py	(original)
+++ pypy/branch/fast-forward/pypy/annotation/model.py	Wed Sep 22 20:19:12 2010
@@ -34,7 +34,7 @@
 from pypy.tool.pairtype import pair, extendabletype
 from pypy.tool.tls import tlsobject
 from pypy.rlib.rarithmetic import r_uint, r_ulonglong, base_int
-from pypy.rlib.rarithmetic import r_singlefloat, isnan
+from pypy.rlib.rarithmetic import r_singlefloat, r_longfloat, isnan
 import inspect, weakref
 
 DEBUG = False    # set to False to disable recording of debugging information
@@ -182,6 +182,15 @@
     def can_be_none(self):
         return False
 
+class SomeLongFloat(SomeObject):
+    "Stands for an r_longfloat."
+    # No operation supported, not even union with a regular float
+    knowntype = r_longfloat
+    immutable = True
+
+    def can_be_none(self):
+        return False
+
 class SomeInteger(SomeFloat):
     "Stands for an object which is known to be an integer."
     knowntype = int
@@ -580,6 +589,7 @@
     (SomeInteger(knowntype=r_ulonglong), NUMBER),    
     (SomeFloat(), lltype.Float),
     (SomeSingleFloat(), lltype.SingleFloat),
+    (SomeLongFloat(), lltype.LongFloat),
     (SomeChar(), lltype.Char),
     (SomeUnicodeCodePoint(), lltype.UniChar),
     (SomeAddress(), llmemory.Address),

Modified: pypy/branch/fast-forward/pypy/rpython/rfloat.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/rfloat.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/rfloat.py	Wed Sep 22 20:19:12 2010
@@ -209,8 +209,8 @@
                                      _callable=lambda x: pyobjectptr(x))
         return NotImplemented
 
-# ____________________________________________________________
-# Support for r_singlefloat from pypy.rlib.rarithmetic
+# ______________________________________________________________________
+# Support for r_singlefloat and r_longfloat from pypy.rlib.rarithmetic
 
 from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.rmodel import Repr
@@ -230,3 +230,19 @@
         # we use cast_primitive to go between Float and SingleFloat.
         return hop.genop('cast_primitive', [v],
                          resulttype = lltype.Float)
+
+class __extend__(annmodel.SomeLongFloat):
+    def rtyper_makerepr(self, rtyper):
+        return LongFloatRepr()
+    def rtyper_makekey(self):
+        return self.__class__,
+
+class LongFloatRepr(Repr):
+    lowleveltype = lltype.LongFloat
+
+    def rtype_float(self, hop):
+        v, = hop.inputargs(lltype.LongFloat)
+        hop.exception_cannot_occur()
+        # we use cast_primitive to go between Float and LongFloat.
+        return hop.genop('cast_primitive', [v],
+                         resulttype = lltype.Float)

Modified: pypy/branch/fast-forward/pypy/translator/c/primitive.py
==============================================================================
--- pypy/branch/fast-forward/pypy/translator/c/primitive.py	(original)
+++ pypy/branch/fast-forward/pypy/translator/c/primitive.py	Wed Sep 22 20:19:12 2010
@@ -100,6 +100,7 @@
         x = repr(value)
         assert not x.startswith('n')
         return x
+name_longfloat = name_float
 
 def name_singlefloat(value, db):
     value = float(value)
@@ -167,6 +168,7 @@
     Unsigned: name_unsigned,
     Float:    name_float,
     SingleFloat: name_singlefloat,
+    LongFloat: name_longfloat,
     Char:     name_char,
     UniChar:  name_unichar,
     Bool:     name_bool,
@@ -182,6 +184,7 @@
     Unsigned: 'unsigned long @',
     Float:    'double @',
     SingleFloat: 'float @',
+    LongFloat: 'long double @',
     Char:     'char @',
     UniChar:  'wchar_t @',
     Bool:     'bool_t @',



More information about the Pypy-commit mailing list