changeset 88:0fb9ae8d823d

Fixed bug. When a function has no arguments, then the resulting environment is no different than the one assigned to the node when it is initialized. This causes the workflow algorithm to halt. Solution is have an uninitialized environment, which is represented by None, and an initialized environment represented by a dictionary.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Fri, 29 May 2009 12:08:34 +0200
parents 015b29ec71fd
children 3bb5d6df094a
files pysmcl/flow.py pysmcl/range_analysis.py
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/flow.py	Fri May 29 11:57:13 2009 +0200
+++ b/pysmcl/flow.py	Fri May 29 12:08:34 2009 +0200
@@ -60,8 +60,8 @@
                 # in_values and out_values are used for storing
                 # lattice-points in for static analyses using the monotone
                 # framework.
-                child.in_values = {"secret" : set(), "range": dict()}
-                child.out_values = {"secret" : set(), "range": dict()}
+                child.in_values = {"secret" : set(), "range": None}
+                child.out_values = {"secret" : set(), "range": None}
         node.initialized = True
 
     def flow(self, function):
--- a/pysmcl/range_analysis.py	Fri May 29 11:57:13 2009 +0200
+++ b/pysmcl/range_analysis.py	Fri May 29 12:08:34 2009 +0200
@@ -70,12 +70,15 @@
         """The least upper bound of the node and the environment.
 
         node (ast.Node)
-        end (dict) A dictionary with variables and their current range.
+        end (dict) A dictionary with variables and their current range. 
+          May be None if the env is uninitialized.
         """
         if debug:
             print "========= Combining ==========="
             print "Node, env", node, env
 
+        if env is None:
+            env = {}
         class Visitor(ast.NodeVisitor):
             """Visitor for Python statements."""
             def __init__(self, prime):
@@ -233,9 +236,17 @@
         raise Exception("NYI, tuple targets")
 
 def combine_env(env1, env2):
-    """Combine the two environments env1 and env2."""
+    """Combine the two environments env1 and env2.
+
+    env1 (dict) May be a dictionary or None if the env is uninitialized.
+    env2 (dict) May be a dictionary or None if the env is uninitialized.
+    """
     if debug:
         print "  combine_env:", env1, env2
+    if env1 is None:
+        env1 = {}
+    if env2 is None:
+        env2 = {}
     env = {}
     common_keys = set(env1.keys()) & set(env2.keys())
     env1_keys = set(env1.keys()) - set(env2.keys())