def compile(self, body): program = reformat_expr(body) ast = self.parse(program) imp = Importer(self.space) w_mod = compile_module(self.space, '<test>', 'self.test', program, ast, imp) return compile_bytecode(ast.elements[0], program, w_mod)
def compile_module(source, ast): name_mapping = {} for item in ast.get_element_list(): if item.name in name_mapping: raise NameAlreadyDefined(item.name) name_mapping[item.name] = len(name_mapping) functions = [] w_mod = W_Module(name_mapping, functions) for item in ast.get_element_list(): functions.append( W_Function(item.name, compile_bytecode(item, source, w_mod))) return w_mod
def add_global_symbols(self, space, globals_w, source, w_mod): w_g = W_Function( self.name, compile_bytecode(self, source, w_mod, self.arglist, self.lineno)) globals_w.append(w_g)
def compile(self, body): program = reformat_expr(body) ast = self.parse(program) return compile_bytecode(ast.elements[0], program, None)
def add_global_symbols(self, space, globals_w, source, w_mod): w_g = W_Function(self.name, compile_bytecode(self, source, w_mod, self.arglist, self.lineno)) globals_w.append(w_g)