changeset 147:0f7009afd716

Ideal functionality decorator now takes arguments
author Sigurd Meldgaard <stm@daimi.au.dk>
date Thu, 03 Dec 2009 14:46:24 +0100
parents c5779433111c
children c1d958858721
files pysmcl/ideal_functionality.py
diffstat 1 files changed, 23 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/ideal_functionality.py	Mon Nov 23 14:56:01 2009 +0100
+++ b/pysmcl/ideal_functionality.py	Thu Dec 03 14:46:24 2009 +0100
@@ -10,27 +10,28 @@
 import pysmcl.proof_burden
 from pysmcl.bad_calls import bad_calls
 
-def ideal_functionality(f):
-    print "ideal"
-    source_str = inspect.getsource(f)
-    source_ast = ast.parse(source_str) # Returns a module
-    function_ast = source_ast.body[0] # We want only the function
-    pysmcl.pretty_print.PrettyPrinter().visit(source_ast)
-    # We don't want recursive applications of this decorator
-    #function_ast.decorator_list.remove[0]
-    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:
+def ideal_functionality(args):
+    def ideal_functionality_helper(f):
+        print "ideal"
+        source_str = inspect.getsource(f)
+        source_ast = ast.parse(source_str) # Returns a module
+        function_ast = source_ast.body[0] # We want only the function
+        pysmcl.pretty_print.PrettyPrinter().visit(source_ast)
+        # We don't want recursive applications of this decorator
+        #function_ast.decorator_list.remove[0]
+        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)
-    pysmcl.secret_annotator.secret_analysis(function_ast)
-    bad_calls(function_ast)
-    t.decorator_list.pop()
-#     pysmcl.proof_burden.proof_burden(t)
-    pysmcl.pretty_print.PrettyPrinter().visit(t)
-    exec compile(ast.Module([t]), "<string>", "exec")
-    return eval(function_ast.name)
-
+        while transform_ifs.changed:
+            pysmcl.secret_annotator.secret_analysis(function_ast)
+            t = transform_ifs.visit(function_ast)
+        pysmcl.secret_annotator.secret_analysis(function_ast)
+        bad_calls(function_ast)
+        t.decorator_list.pop()
+#         pysmcl.proof_burden.proof_burden(t)
+        pysmcl.pretty_print.PrettyPrinter().visit(t)
+        exec compile(ast.Module([t]), "<string>", "exec")
+        return eval(function_ast.name)
+    return ideal_functionality_helper