changeset 247:26f0f4a81ef4

ideal_functionality: cleanup
author Sigurd Meldgaard <stm@daimi.au.dk>
date Wed, 06 Jan 2010 12:18:32 +0100
parents c0acf53c72c1
children 3f35fc6e5951
files pysmcl/ideal_functionality.py
diffstat 1 files changed, 16 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/ideal_functionality.py	Wed Jan 06 11:21:21 2010 +0100
+++ b/pysmcl/ideal_functionality.py	Wed Jan 06 12:18:32 2010 +0100
@@ -6,8 +6,9 @@
 import pysmcl.ast_wrapper as ast
 import pysmcl.compatibility_check
 import pysmcl.pretty_print
-import pysmcl.secret_annotator
-import pysmcl.secret_ifs
+from pysmcl.range_analysis import RangeAnalysis
+from pysmcl.secret_annotator import secret_analysis
+import pysmcl.secret_ifs as secret_ifs
 from pysmcl.runtime_sugar import runtime_sugar
 from pysmcl.bad_calls import bad_calls
 
@@ -15,6 +16,7 @@
 
 
 def catcher(f):
+
     def c(*args, **kwargs):
         try:
             return f(*args, **kwargs)
@@ -22,7 +24,9 @@
             return e.value
     return c
 
+
 def ideal_functionality(range={}, secrets=[]):
+
     def ideal_functionality_helper(f):
         source_str = inspect.getsource(f)
         source_ast = ast.parse(source_str) # Returns a module
@@ -31,28 +35,25 @@
             pysmcl.pretty_print.pprint(source_ast)
             print "-"*80
         pysmcl.compatibility_check.CompatibilityChecker().visit(function_ast)
-        transform_ifs = pysmcl.secret_ifs.TransformIfs()
-        pysmcl.secret_annotator.secret_analysis(function_ast)
-        t = transform_ifs.visit(function_ast)
-        while transform_ifs.changed:
-            pysmcl.secret_annotator.secret_analysis(function_ast)
-            t = transform_ifs.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
         pysmcl.secret_annotator.secret_analysis(function_ast)
         bad_calls(function_ast)
 
         runtime_sugar(function_ast)
-        t.decorator_list.pop()
+        function_ast.decorator_list.pop()
         if(debug):
             pysmcl.pretty_print.pprint(source_ast)
         g = f.__globals__
         g["returnValue"] = returnValue
         env = {}
-        ast.increment_lineno(t, 10)
-        # for i in ast.walk(function_ast):
-        #     print i, getattr(i, "lineno", None)
-        #     i.lineno = 3
-        # print ast.dump(function_ast)
-        exec compile(ast.Module([t]), f.__code__.co_filename, "exec") in g, env
+        exec compile(ast.Module([function_ast]),
+                     f.__code__.co_filename, "exec") in g, env
         f = env[function_ast.name]
         return inlineCallbacks(f)