changeset 146:c5779433111c

Moved getVirtualFunctionality to ast
author Sigurd Meldgaard <stm@daimi.au.dk>
date Mon, 23 Nov 2009 14:56:01 +0100
parents 3ae677faacf1
children 0f7009afd716
files pysmcl/ast_wrapper.py pysmcl/editor_info.py
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/ast_wrapper.py	Mon Nov 23 11:26:33 2009 +0100
+++ b/pysmcl/ast_wrapper.py	Mon Nov 23 14:56:01 2009 +0100
@@ -20,3 +20,11 @@
     while not isinstance(node, type):
         node = node.parent
     return node
+
+def get_ideal_functionality(function_def):
+      for decorator in function_def.decorator_list:
+          if isinstance(decorator, ast.Name) and decorator.id == 'ideal_functionality':
+              return decorator
+          elif isinstance(decorator, ast.Call) and decorator.func.id == 'ideal_functionality':
+              return decorator
+      return None
--- a/pysmcl/editor_info.py	Mon Nov 23 11:26:33 2009 +0100
+++ b/pysmcl/editor_info.py	Mon Nov 23 14:56:01 2009 +0100
@@ -19,9 +19,11 @@
             secret_analysis(i)
     # Graph(Flow().to_dot(prog.body[1])).to_dot()
     for top_level_statement in prog.body:
-        if(isinstance(top_level_statement, ast.FunctionDef) and
-           is_ideal_functionality(top_level_statement)):
-            RangeAnalysis(13).apply(top_level_statement)
+        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):