changeset 57:996d9e5da978

Merged with Sigurd.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Tue, 26 May 2009 17:16:30 +0200
parents cfd400983f45 (current diff) 52e6dad22cf5 (diff)
children b8b250033b5e
files pysmcl/range_analysis.py
diffstat 2 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/range_analysis.py	Tue May 26 17:14:51 2009 +0200
+++ b/pysmcl/range_analysis.py	Tue May 26 17:16:30 2009 +0200
@@ -85,7 +85,7 @@
                 for target in node.targets:
                     targetVisitor.visit(target)
                 return env
-           
+
             def visit_FunctionDef(self, node):
                 for arg in node.args.args:
                     env[arg.id] = (0, self.prime)
@@ -109,7 +109,7 @@
     env (dict) An environment of variables and their range.
     """
     rangeVisitor = RangeVisitor(prime, env)
-    return rangeVisitor.visit(node)        
+    return rangeVisitor.visit(node)
 
 class RangeVisitor(ast.NodeVisitor):
     """RangeVisitor is the visitor which actually implements the 
@@ -132,7 +132,7 @@
         return (0, self.prime)
 
     def visit_BinOp(self, node):
-        # operator = Add | Sub | Mult | Div | Mod | Pow | LShift 
+        # operator = Add | Sub | Mult | Div | Mod | Pow | LShift
         #          | RShift | BitOr | BitXor | BitAnd | FloorDiv
         left = self.visit(node.left)
         right = self.visit(node.right)
@@ -147,8 +147,8 @@
             return (r0, r1)
 
         if isinstance(node.op, ast.Sub):
-            r0 = left[0] - right[0]
-            r1 = left[1] - right[1]
+            r0 = left[0] - right[1]
+            r1 = left[1] - right[0]
             if r0 < 0:
                 r0 = Bottom()
             if r1 < 0:
@@ -163,7 +163,7 @@
             if r1 >= self.prime:
                 r1 = Bottom()
             return (r0, r1)
-        raise Exception("Operator not implemented: ", node.op) 
+        raise Exception("Operator not implemented: ", node.op)
 
     def visit_Compare(self, node):
         # cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn
@@ -231,5 +231,5 @@
     if h1 > h2:
         r[1] = h1
     else:
-        r[1] = h2    
+        r[1] = h2
     return r
--- a/pysmcl/test/unit/test_rangeanalysis.py	Tue May 26 17:14:51 2009 +0200
+++ b/pysmcl/test/unit/test_rangeanalysis.py	Tue May 26 17:16:30 2009 +0200
@@ -6,6 +6,8 @@
 from pysmcl.ideal_functionality import init_statements
 from pysmcl.range_analysis import RangeAnalysis, Bottom
 
+x = 30
+
 class RangeAnalysisTest(unittest.TestCase):