changeset 188:4b8cd0370fa7

editor_info: use if_rewrites
author Sigurd Meldgaard <stm@daimi.au.dk>
date Wed, 16 Dec 2009 15:20:37 +0100
parents ec6a31c28623
children 67503a9dd613
files pysmcl/editor_info.py
diffstat 1 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/editor_info.py	Wed Dec 16 15:20:06 2009 +0100
+++ b/pysmcl/editor_info.py	Wed Dec 16 15:20:37 2009 +0100
@@ -1,10 +1,11 @@
 import sys
 
 import pysmcl.ast_wrapper as ast
+import pysmcl.setup
 from pysmcl.pretty_print import expr_string
 from pysmcl.range_analysis import RangeAnalysis
 from pysmcl.secret_annotator import secret_analysis, expr_secret
-
+import pysmcl.secret_ifs
 
 def main():
     try:
@@ -14,13 +15,24 @@
     for i in prog.body:
         if isinstance(i, ast.FunctionDef):
             secret_analysis(i)
+            
+            RangeAnalysis(pysmcl.setup.Zp.modulus).apply(i, {})
+
+            transform_ifs = pysmcl.secret_ifs.TransformIfs()
+            t = transform_ifs.visit(i)
+            while transform_ifs.changed:
+                secret_analysis(i)
+                RangeAnalysis(pysmcl.setup.Zp.modulus).apply(i, {})
+                transform_ifs.reset()
+                t = transform_ifs.visit(i)
+
     # Graph(Flow().to_dot(prog.body[1])).to_dot()
     for top_level_statement in prog.body:
         if(isinstance(top_level_statement, ast.FunctionDef)):
             decorator = ast.get_ideal_functionality(top_level_statement)
             if decorator is None:
                 continue
-            RangeAnalysis(13).apply(top_level_statement, {})
+
             for statement in top_level_statement.body:
                 for j in ast.walk(statement):
                     if isinstance(j, ast.stmt):
@@ -34,8 +46,8 @@
                     if(isinstance(j, ast.Name) and not 
                        (isinstance(j.parent, ast.Call) and j is j.parent.func)):
 
-                        print "values: %d %d %d %s" % (j.lineno, j.col_offset,
-                                                len(expr_string(j)), str(r[j.id]))
+                        print "values: %d %d %d (%s)" % (j.lineno, j.col_offset,
+                                                len(expr_string(j)), j.id + " is in " +str(r[j.id]))
 
 
 if __name__ == "__main__":