changeset 196:14bb029606f9

editor_info: info about transformations, and improved handling of ranges.
author Sigurd Meldgaard <stm@daimi.au.dk>
date Wed, 16 Dec 2009 16:57:11 +0100
parents 06e52f99cb67
children b8c907304254
files pysmcl/editor_info.py
diffstat 1 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/editor_info.py	Wed Dec 16 16:56:12 2009 +0100
+++ b/pysmcl/editor_info.py	Wed Dec 16 16:57:11 2009 +0100
@@ -2,7 +2,7 @@
 
 import pysmcl.ast_wrapper as ast
 import pysmcl.setup
-from pysmcl.pretty_print import expr_string
+import pysmcl.pretty_print as pp
 from pysmcl.range_analysis import RangeAnalysis
 from pysmcl.secret_annotator import secret_analysis, expr_secret
 import pysmcl.secret_ifs
@@ -14,6 +14,9 @@
         exit(2)  # Exit code signalling syntax error.
     for i in prog.body:
         if isinstance(i, ast.FunctionDef):
+            decorator = ast.get_ideal_functionality(i)
+            if decorator is None:
+                continue
             secret_analysis(i)
             
             RangeAnalysis(pysmcl.setup.Zp.modulus).apply(i, {})
@@ -22,9 +25,13 @@
             t = transform_ifs.visit(i)
             while transform_ifs.changed:
                 secret_analysis(i)
-                RangeAnalysis(pysmcl.setup.Zp.modulus).apply(i, {})
+#                RangeAnalysis(pysmcl.setup.Zp.modulus).apply(i, {})
                 transform_ifs.reset()
                 t = transform_ifs.visit(i)
+            secret_analysis(i)
+            func_string = pp.pprint_string(i)
+            print "!transformed: %d %d %d (%s)" % (i.lineno, i.col_offset,
+                                                len(i.name), func_string) 
 
     # Graph(Flow().to_dot(prog.body[1])).to_dot()
     for top_level_statement in prog.body:
@@ -40,14 +47,16 @@
                         r = j.out_values["range"]
                     if isinstance(j, ast.expr):
                         if expr_secret(j, e):
-                            s = expr_string(j)
-                            print "secret: %d %d %d (%s)" % (j.lineno, j.col_offset,
+                            s = pp.expr_string(j)
+                            print "!secret: %d %d %d (%s)" % (j.lineno, j.col_offset,
                                                 len(s), s)
                     if(isinstance(j, ast.Name) and not 
-                       (isinstance(j.parent, ast.Call) and j is j.parent.func)):
+                       (isinstance(j.parent, ast.Call) and j is j.parent.func) and
+                       r and
+                       j.id in r):
 
-                        print "values: %d %d %d (%s)" % (j.lineno, j.col_offset,
-                                                len(expr_string(j)), j.id + " is in " +str(r[j.id]))
+                        print "!values: %d %d %d (%s)" % (j.lineno, j.col_offset,
+                                                len(pp.expr_string(j)), j.id + " is in " +str(r[j.id]))
 
 
 if __name__ == "__main__":