コード例 #1
0
ファイル: generator.py プロジェクト: hdeweirdt/imp
    def evaluate(self, state, local_scope):
        """
            Evaluate this statement. 
        """
        var = state.get_ref("variable").value
        
        for loop_var in var:
            # generate a subscope/namespace for each loop
            object_id = Scope.object_to_name(loop_var)
            namespace = Namespace(object_id, state.namespace)
            
            sub_scope = Scope.get_or_create_scope(state.graph,
                                                  namespace.to_path())

            # add the loop variable to the scope
            if not isinstance(loop_var, Variable):
                loop_var = Variable(loop_var)
            
            sub_scope.add_variable(self.loop_var, loop_var)
            
            # generate the import statement
            import_stmt = Import(self.module_name)
            import_stmt.namespace = namespace
            import_stmt.child_namespace = False
            
            child_state = DynamicState(state.compiler, namespace, import_stmt)
            child_state.add_to_graph(state.graph)
            state._child_statements[import_stmt] = child_state
コード例 #2
0
ファイル: generator.py プロジェクト: hdeweirdt/imp
 def evaluate(self, state, local_scope):
     """
         Evaluate this statement
     """
     implement_list = self.get_implementation(state, local_scope)
     
     if len(implement_list) == 0:
         raise Exception("Unable to select implementation for entity %s" % 
                         self.instance_type.name)
     
     implementations = []
     for impl in implement_list:
         implementations.extend(impl.implementations)
     
     for impl in implementations:
         # generate a subscope/namespace for each loop
         object_id = Scope.object_to_name(impl)
         namespace = Namespace(object_id, state.namespace)
         
         for stmt in impl.statements:
             child_state = DynamicState(state.compiler, namespace, stmt)
             child_state.add_to_graph(state.graph)
             state._child_statements[stmt] = child_state