changeset 172:b57cf4ece1f2

ideal functionality: now uses inlineCallbacks
author Sigurd Meldgaard <stm@daimi.au.dk>
date Mon, 14 Dec 2009 10:27:42 +0100
parents 32d6f31a8be2
children 9af426685e68
files pysmcl/ideal_functionality.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/ideal_functionality.py	Mon Dec 14 10:26:14 2009 +0100
+++ b/pysmcl/ideal_functionality.py	Mon Dec 14 10:27:42 2009 +0100
@@ -1,14 +1,15 @@
 import inspect
+from twisted.internet.defer import inlineCallbacks
 
 import pysmcl.ast_wrapper as ast
 import pysmcl.compatibility_check
 import pysmcl.pretty_print
 import pysmcl.secret_annotator
 import pysmcl.secret_ifs
+from pysmcl.runtime_sugar import runtime_sugar
 from pysmcl.bad_calls import bad_calls
 
-
-def ideal_functionality(args):
+def ideal_functionality(range={}):
     def ideal_functionality_helper(f):
         print "ideal"
         source_str = inspect.getsource(f)
@@ -27,9 +28,14 @@
             t = transform_ifs.visit(function_ast)
         pysmcl.secret_annotator.secret_analysis(function_ast)
         bad_calls(function_ast)
+        runtime_sugar(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)
+        g = f.__globals__
+        env = {}
+        ast.increment_lineno(t, 3)
+        exec compile(ast.Module([t]), f.__code__.co_filename, "exec") in g, env
+        f = env[function_ast.name]
+        return inlineCallbacks(f)
     return ideal_functionality_helper