### changeset 73:1ed5f9156fe3

Moved the function liftMinus.
author Janus Dam Nielsen Wed, 27 May 2009 14:59:22 +0200 7d0c4cd0926a 25268f5d228e pysmcl/range_analysis.py 1 files changed, 9 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
```--- a/pysmcl/range_analysis.py	Wed May 27 14:59:22 2009 +0200
+++ b/pysmcl/range_analysis.py	Wed May 27 14:59:22 2009 +0200
@@ -137,15 +137,6 @@
return (0, self.prime)

def visit_BinOp(self, node):
-        def liftMinus(a,b):
-            if(isinstance(a, Bottom) or
-               isinstance(b, Bottom)):
-                return Bottom()
-            c = a-b
-            if(c < 0):
-                return Bottom()
-            return c
-
# operator = Add | Sub | Mult | Div | Mod | Pow | LShift
#          | RShift | BitOr | BitXor | BitAnd | FloorDiv
left = self.visit(node.left)
@@ -159,13 +150,20 @@
c = a + b
if c > self.prime:
return Bottom()
-                return c
-
+                return c
return (r0, r1)

if isinstance(node.op, ast.Sub):
+            def liftMinus(a,b):
+                if(isinstance(a, Bottom) or
+                   isinstance(b, Bottom)):
+                    return Bottom()
+                c = a-b
+                if(c < 0):
+                    return Bottom()
+                return c
r0 = liftMinus(left[0], right[1])
r1 = liftMinus(left[1], right[0])
return (r0, r1)```