changeset 71:a34b7936cf7f

Check if constant is too large for the field.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Wed, 27 May 2009 14:59:22 +0200
parents acc2a8647905
children 7d0c4cd0926a
files pysmcl/range_analysis.py pysmcl/test/unit/test_rangeanalysis.py
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/range_analysis.py	Wed May 27 13:54:48 2009 +0200
+++ b/pysmcl/range_analysis.py	Wed May 27 14:59:22 2009 +0200
@@ -127,6 +127,8 @@
         self.env = env
 
     def visit_Num(self, node):
+        if node.n > self.prime:
+            return (Bottom(), Bottom())
         return (node.n, node.n)
 
     def visit_Name(self, node):
--- a/pysmcl/test/unit/test_rangeanalysis.py	Wed May 27 13:54:48 2009 +0200
+++ b/pysmcl/test/unit/test_rangeanalysis.py	Wed May 27 14:59:22 2009 +0200
@@ -20,6 +20,14 @@
 
         self.assertEquals(prog.body[0].body[0].out_values["range"], {'y': (0, 0)})
 
+    def test_range_too_large_constant(self):
+        p = 7
+        prog = parse("def f():\n\ty=8\n")
+        init_statements(prog)
+        range_analysis = RangeAnalysis(p)
+        range_analysis.apply(prog.body[0])
+        self.assertEquals(prog.body[0].body[0].out_values["range"], {'y': (Bottom(), Bottom())})
+
     def test_range_unknown_range(self):
         p = 7
         prog = parse("def f(x):\n\tx\n")