示例#1
0
 def generateDefinedMethod(self, entry_point_node, method_attributes):
     method_attributes |= MethodAttributes.Public
     method_parameters = self.methodParameters(entry_point_node)
     method_name = self.lookupCtsMethodName(entry_point_node.name)
     logging.debug("name = %s", entry_point_node.name)
     # Setup code generators for loading and storing the methods arguments
     if entry_point_node.formalParameters is not None:
         formal_parameters = entry_point_node.formalParameters.arguments
         for index, param in enumerate(formal_parameters):
         # TODO: Lookup the argument symbol
             name = param.argument.identifier
             logging.debug("formal parameter identifier = %s", name)
             symbol_node = findNode(entry_point_node, hasSymbolTableLookup)
             arg_symbol = symbol_node.symbolTable.lookup(name)
             assert arg_symbol is not None
             arg_symbol.loadEmitter  = partial(emitLdarg, index=index)
             arg_symbol.storeEmitter = partial(emitStarg, index=index)
             # Setup the return type of the method
         
     if isinstance(entry_point_node, DefineProcedure):
         method_return_type = System.Void
     elif isinstance(entry_point_node, DefineFunction):
         method_return_type = cts.mapType(entry_point_node.returnType)
     
     return method_name, method_return_type, method_attributes, method_parameters
 def visitVariable(self, variable):
     logger.debug("SymbolTableVisitor.visitVariable")
     statement_node = findNode(variable, lambda node: isinstance(node, AstStatement))
     symbol_table = statement_node.symbolTable
     self.tryAddVariable(symbol_table, variable)