[pypy-svn] r15965 - in pypy/dist/pypy: annotation rpython/memory

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Aug 11 17:01:55 CEST 2005


Author: cfbolz
Date: Thu Aug 11 17:01:54 2005
New Revision: 15965

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/annotation/model.py
   pypy/dist/pypy/rpython/memory/lladdress.py
Log:
added Primitive instance Address to lladdress and use this
consistently (thanks samuele).


Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Thu Aug 11 17:01:54 2005
@@ -659,13 +659,13 @@
 
 class __extend__(pairtype(SomeTypedAddressAccess, SomeInteger)):
     def getitem((s_taa, s_int)):
-        from pypy.annotation.model import lltype_or_address_to_annotation
-        return lltype_or_address_to_annotation(s_taa.type)
+        from pypy.annotation.model import lltype_to_annotation
+        return lltype_to_annotation(s_taa.type)
     getitem.can_only_throw = []
 
     def setitem((s_taa, s_int), s_value):
-        from pypy.annotation.model import annotation_to_lltype_or_address
-        assert annotation_to_lltype_or_address(s_value) is s_taa.type
+        from pypy.annotation.model import annotation_to_lltype
+        assert annotation_to_lltype(s_value) is s_taa.type
     setitem.can_only_throw = []
 
 

Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py	(original)
+++ pypy/dist/pypy/annotation/model.py	Thu Aug 11 17:01:54 2005
@@ -387,6 +387,30 @@
     def can_be_none(self):
         return False
 
+# ____________________________________________________________
+# memory addresses
+
+from pypy.rpython.memory import lladdress
+
+class SomeAddress(SomeObject):
+    def __init__(self, is_null=False):
+        self.is_null = is_null
+
+    def can_be_none(self):
+        return False
+
+
+# The following class is used to annotate the intermediate value that
+# appears in expressions of the form:
+# addr.signed[offset] and addr.signed[offset] = value
+
+class SomeTypedAddressAccess(SomeObject):
+    def __init__(self, type):
+        self.type = type
+
+    def can_be_none(self):
+        return False
+
 #____________________________________________________________
 # annotation of low-level types
 
@@ -407,6 +431,7 @@
     (SomeFloat(), lltype.Float),
     (SomeChar(), lltype.Char),
     (SomeUnicodeCodePoint(), lltype.UniChar),
+    (SomeAddress(), lladdress.Address),
 ]
 
 def annotation_to_lltype(s_val, info=None):
@@ -438,41 +463,6 @@
         from bookkeeper import getbookkeeper
         return getbookkeeper().immutablevalue(None)
     return lltype_to_annotation(lltype.typeOf(v))
-
-# ____________________________________________________________
-# memory addresses
-
-class SomeAddress(SomeObject):
-    def __init__(self, is_null=False):
-        self.is_null = is_null
-
-    def can_be_none(self):
-        return False
-
-
-# The following class is used to annotate the intermediate value that
-# appears in expressions of the form:
-# addr.signed[offset] and addr.signed[offset] = value
-
-class SomeTypedAddressAccess(SomeObject):
-    def __init__(self, type):
-        self.type = type
-
-    def can_be_none(self):
-        return False
-
-def lltype_or_address_to_annotation(T):
-    from pypy.rpython.memory.lladdress import address
-    if T is address:
-        return SomeAddress()
-    return lltype_to_annotation(T)
-
-def annotation_to_lltype_or_address(s_ann):
-    from pypy.rpython.memory.lladdress import address
-    if isinstance(s_ann, SomeAddress):
-        return address
-    else:
-        return annotation_to_lltype(s_ann)
     
 # ____________________________________________________________
 

Modified: pypy/dist/pypy/rpython/memory/lladdress.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/lladdress.py	(original)
+++ pypy/dist/pypy/rpython/memory/lladdress.py	Thu Aug 11 17:01:54 2005
@@ -1,5 +1,4 @@
 import struct
-from pypy.rpython import lltype
 from pypy.rpython.memory.simulator import MemorySimulator
 from pypy.rpython.rarithmetic import r_uint
 
@@ -104,9 +103,12 @@
     return simulator.get_py_object(address.intaddress)
 
 
+from pypy.rpython import lltype
+Address = lltype.Primitive("Address", NULL)
+
+
 supported_access_types = {"signed":    lltype.Signed,
                           "unsigned":  lltype.Unsigned,
                           "char":      lltype.Char,
-                          "address":   address,
+                          "address":   Address,
                           }
-



More information about the Pypy-commit mailing list