changeset 255:c837fa9ff823

ideal_functionality: refactor, extract fixpoint tranformation of ifs
author Sigurd Meldgaard <stm@daimi.au.dk>
date Wed, 06 Jan 2010 14:46:16 +0100
parents 67875afe1c90
children 71ebbf22dd78 7b9a5eaf2e88
files pysmcl/editor_info.py pysmcl/ideal_functionality.py
diffstat 2 files changed, 13 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/editor_info.py	Wed Jan 06 14:01:10 2010 +0100
+++ b/pysmcl/editor_info.py	Wed Jan 06 14:46:16 2010 +0100
@@ -8,7 +8,7 @@
 import pysmcl.secret_ifs as secret_ifs
 from pysmcl.util import error
 from pysmcl.bad_calls import bad_calls
-
+from pysmcl.ideal_functionality import transform_ifs_fixpoint
 
 def main():
     try:
@@ -21,13 +21,7 @@
             decorator = ast.get_ideal_functionality(i)
             if decorator is None:
                 continue
-            while True:
-                secret_analysis(i)
-                RangeAnalysis().apply(i, {})
-                transform_ifs = secret_ifs.TransformIfs()
-                i = transform_ifs.visit(i)
-                if not transform_ifs.changed:
-                    break
+            i = transform_ifs_fixpoint(i)
             secret_analysis(i)
             bad_calls(i)
             func_string = pp.pprint_string(i)
--- a/pysmcl/ideal_functionality.py	Wed Jan 06 14:01:10 2010 +0100
+++ b/pysmcl/ideal_functionality.py	Wed Jan 06 14:46:16 2010 +0100
@@ -24,6 +24,16 @@
             return e.value
     return c
 
+def transform_ifs_fixpoint(function_ast):
+    while True:
+        secret_analysis(function_ast)
+        RangeAnalysis().apply(function_ast, {})
+        transform_ifs = secret_ifs.TransformIfs()
+        function_ast = transform_ifs.visit(function_ast)
+        if not transform_ifs.changed:
+            break
+    return function_ast
+
 
 def ideal_functionality(range={}, secrets=[]):
 
@@ -35,13 +45,7 @@
             pysmcl.pretty_print.pprint(source_ast)
             print "-"*80
         pysmcl.compatibility_check.CompatibilityChecker().visit(function_ast)
-        while True:
-            secret_analysis(function_ast)
-            RangeAnalysis().apply(function_ast, {})
-            transform_ifs = secret_ifs.TransformIfs()
-            function_ast = transform_ifs.visit(function_ast)
-            if not transform_ifs.changed:
-                break
+        function_ast = transform_ifs_fixpoint(function_ast)
         pysmcl.secret_annotator.secret_analysis(function_ast)
         bad_calls(function_ast)