[pypy-svn] r22437 - in pypy/dist/pypy: annotation rpython/memory rpython/memory/test
mwh at codespeak.net
mwh at codespeak.net
Thu Jan 19 13:57:07 CET 2006
Author: mwh
Date: Thu Jan 19 13:57:05 2006
New Revision: 22437
Modified:
pypy/dist/pypy/annotation/binaryop.py
pypy/dist/pypy/annotation/builtin.py
pypy/dist/pypy/annotation/model.py
pypy/dist/pypy/rpython/memory/lladdress.py
pypy/dist/pypy/rpython/memory/test/test_address.py
Log:
make the new-ish offsetof be annotated as a SomeOffset() not
a SomeInteger()
Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py (original)
+++ pypy/dist/pypy/annotation/binaryop.py Thu Jan 19 13:57:05 2006
@@ -11,7 +11,7 @@
from pypy.annotation.model import SomeTuple, SomeImpossibleValue, s_ImpossibleValue
from pypy.annotation.model import SomeInstance, SomeBuiltin, SomeIterator
from pypy.annotation.model import SomePBC, SomeSlice, SomeFloat, s_None
-from pypy.annotation.model import SomeExternalObject
+from pypy.annotation.model import SomeExternalObject, SomeOffset
from pypy.annotation.model import SomeAddress, SomeTypedAddressAccess
from pypy.annotation.model import unionof, UnionError, set, missing_operation, TLS
from pypy.annotation.model import add_knowntypedata, merge_knowntypedata
@@ -733,3 +733,6 @@
def union((s_obj, s_addr)):
raise UnionError, "union of address and anything else makes no sense"
+class __extend__(pairtype(SomeOffset, SomeOffset)):
+ def add((s_off1, s_off2)):
+ return SomeOffset()
Modified: pypy/dist/pypy/annotation/builtin.py
==============================================================================
--- pypy/dist/pypy/annotation/builtin.py (original)
+++ pypy/dist/pypy/annotation/builtin.py Thu Jan 19 13:57:05 2006
@@ -8,7 +8,7 @@
from pypy.annotation.model import SomeUnicodeCodePoint, SomeAddress
from pypy.annotation.model import SomeFloat, unionof
from pypy.annotation.model import SomePBC, SomeInstance, SomeDict
-from pypy.annotation.model import SomeExternalObject
+from pypy.annotation.model import SomeExternalObject, SomeOffset
from pypy.annotation.model import annotation_to_lltype, lltype_to_annotation
from pypy.annotation.model import add_knowntypedata
from pypy.annotation.model import s_ImpossibleValue
@@ -505,7 +505,7 @@
# offsetof/sizeof
def offsetof(TYPE, fldname):
- return SomeInteger()
+ return SomeOffset()
BUILTIN_ANALYZERS[lladdress.offsetof] = offsetof
Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py (original)
+++ pypy/dist/pypy/annotation/model.py Thu Jan 19 13:57:05 2006
@@ -452,6 +452,11 @@
def can_be_none(self):
return False
+class SomeOffset(SomeObject):
+ immutable = True
+ def can_be_none(self):
+ return False
+
# The following class is used to annotate the intermediate value that
# appears in expressions of the form:
Modified: pypy/dist/pypy/rpython/memory/lladdress.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/lladdress.py (original)
+++ pypy/dist/pypy/rpython/memory/lladdress.py Thu Jan 19 13:57:05 2006
@@ -132,7 +132,7 @@
def annotation(self):
from pypy.annotation import model
- return model.SomeInteger()
+ return model.SomeOffset()
def __repr__(self):
return "<OffsetOf %r %r>" % (self.TYPE, self.fldname)
Modified: pypy/dist/pypy/rpython/memory/test/test_address.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_address.py (original)
+++ pypy/dist/pypy/rpython/memory/test/test_address.py Thu Jan 19 13:57:05 2006
@@ -120,13 +120,13 @@
return offsetof(S, 'x') + offsetof(S, 'y')
a = RPythonAnnotator()
s = a.build_types(f, [])
- assert s.knowntype == int
+ assert isinstance(s, annmodel.SomeOffset)
coff = offsetof(S, 'y')
def f():
return coff
a = RPythonAnnotator()
s = a.build_types(f, [])
- assert s.knowntype == int
+ assert isinstance(s, annmodel.SomeOffset)
class TestAddressRTyping(object):
def test_null(self):
More information about the Pypy-commit
mailing list