Esempio n. 1
0
 def create_implementation(self, node):
     """
         Create an implementation
     """
     impl = DefineImplementation(str(node.children[0].text))
     
     for stmt in node.children[1].children:
         impl.add_statement(self._handle_node(stmt))
         
     return impl
Esempio n. 2
0
 def create_for(self, node):
     """
         Create a for statement
     """
     loop_var = str(node.children[0])
     var = self._handle_node(node.children[1])
     module_name = "for_%s" % (id(node))
     
     for_stmt = For(var, loop_var, Reference(module_name, 
                                     self._current_namespace.to_path()))
     
     module_def = DefineImplementation(module_name)
     module_def.namespace = self._current_namespace
     for stmt in node.children[2].children:
         module_def.add_statement(self._handle_node(stmt))
         
     self._stack.append(module_def)
     
     return for_stmt
Esempio n. 3
0
 def create_anonymous_implementation(self, node):
     """
         Add an "anonymous" class definition to the specific instance of an 
         entity.
     """
     ctor = self._handle_node(node.children[0])
     
     if len(node.children) == 1:
         return ctor
     
     # create a module for this constructor
     module_def = DefineImplementation(hex(id(ctor)))
     module_def.namespace = self._current_namespace
     for stmt in node.children[1].children:
         module_def.add_statement(self._handle_node(stmt))
         
     ctor.implemented = True
     self._stack.append(module_def)
     
     return ctor