[pypy-svn] r10555 - pypy/dist/pypy/annotation
pedronis at codespeak.net
pedronis at codespeak.net
Tue Apr 12 18:11:39 CEST 2005
Author: pedronis
Date: Tue Apr 12 18:11:39 2005
New Revision: 10555
Modified:
pypy/dist/pypy/annotation/binaryop.py
pypy/dist/pypy/annotation/model.py
pypy/dist/pypy/annotation/unaryop.py
Log:
fix/improve unsigned handling for some ops
Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py (original)
+++ pypy/dist/pypy/annotation/binaryop.py Tue Apr 12 18:11:39 2005
@@ -152,8 +152,10 @@
# unsignedness is considered a rare and contagious disease
def union((int1, int2)):
- return SomeInteger(nonneg = int1.nonneg and int2.nonneg,
- unsigned = int1.unsigned or int2.unsigned)
+ unsigned = int1.unsigned or int2.unsigned
+ return SomeInteger(nonneg = unsigned or (int1.nonneg and int2.nonneg),
+ unsigned=unsigned)
+
add = mul = div = floordiv = mod = or_ = xor = union
@@ -164,8 +166,9 @@
return SomeInteger(unsigned = int1.unsigned or int2.unsigned)
def and_((int1, int2)):
- return SomeInteger(nonneg = int1.nonneg or int1.nonneg,
- unsigned = int1.unsigned or int2.unsigned)
+ unsigned = int1.unsigned or int2.unsigned
+ return SomeInteger(nonneg = unsigned or int1.nonneg or int1.nonneg,
+ unsigned = unsigned)
def lshift((int1, int2)):
if int1.unsigned:
@@ -175,6 +178,8 @@
rshift = lshift
def pow((int1, int2), obj3):
+ if int1.unsigned or int2.unsigned or getattr(obj3, 'unsigned', False):
+ return SomeInteger(unsigned=True)
return SomeInteger()
class __extend__(pairtype(SomeBool, SomeBool)):
Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py (original)
+++ pypy/dist/pypy/annotation/model.py Tue Apr 12 18:11:39 2005
@@ -104,7 +104,7 @@
"Stands for an object which is known to be an integer."
knowntype = int
def __init__(self, nonneg=False, unsigned=False):
- self.nonneg = nonneg
+ self.nonneg = unsigned or nonneg
self.unsigned = unsigned # pypy.tool.rarithmetic.r_uint
Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py (original)
+++ pypy/dist/pypy/annotation/unaryop.py Tue Apr 12 18:11:39 2005
@@ -143,9 +143,13 @@
int = pos
def neg(self):
+ if self.unsigned:
+ return SomeInteger(unsigned=True)
return SomeInteger()
def abs(self):
+ if self.unsigned:
+ return self
return SomeInteger(nonneg=True)
More information about the Pypy-commit
mailing list