예제 #1
0
파일: pycompiler.py 프로젝트: Qointum/pypy
 def _compile_ast(self, node, info):
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = codegen.compile_ast(space, mod, info)
     except parseerror.SyntaxError, e:
         raise OperationError(space.w_SyntaxError, e.wrap_info(space))
예제 #2
0
 def _compile_ast(self, node, info):
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = codegen.compile_ast(space, mod, info)
     except parseerror.SyntaxError as e:
         raise OperationError(space.w_SyntaxError, e.wrap_info(space))
     return code
예제 #3
0
 def _compile_ast(self, node, info, source=None):
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = codegen.compile_ast(space, mod, info)
     except parseerror.SyntaxError as e:
         raise OperationError(space.w_SyntaxError, e.find_sourceline_and_wrap_info(space, source))
     return code
예제 #4
0
 def _compile_ast(self, node, info):
     from pypy.interpreter.astcompiler import optimize
     from pypy.interpreter.astcompiler.codegen import compile_ast
     from pypy.interpreter.pyparser.error import SyntaxError
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = compile_ast(space, mod, info)
     except SyntaxError, e:
         raise OperationError(space.w_SyntaxError, e.wrap_info(space))
예제 #5
0
파일: pycompiler.py 프로젝트: alkorzt/pypy
 def _compile_ast(self, node, info):
     from pypy.interpreter.astcompiler import optimize
     from pypy.interpreter.astcompiler.codegen import compile_ast
     from pypy.interpreter.pyparser.error import SyntaxError
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = compile_ast(space, mod, info)
     except SyntaxError, e:
         raise OperationError(space.w_SyntaxError,
                              e.wrap_info(space))
예제 #6
0
 def _compile_ast(self, node, info, source=None):
     from pypy.interpreter.astcompiler.unparse import unparse_annotations
     space = self.space
     if info.flags & consts.CO_FUTURE_ANNOTATIONS:
         node = unparse_annotations(space, node)
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = codegen.compile_ast(space, mod, info)
     except parseerror.SyntaxError as e:
         raise OperationError(
             space.w_SyntaxError,
             e.find_sourceline_and_wrap_info(space, source))
     return code
예제 #7
0
def generate_function_code(expr, space):
    p = pyparse.PythonParser(space)
    info = pyparse.CompileInfo("<test>", 'exec')
    cst = p.parse_source(expr, info)
    ast = astbuilder.ast_from_node(space, cst, info)
    function_ast = optimize.optimize_ast(space, ast.body[0], info)
    function_ast = ast.body[0]
    symbols = symtable.SymtableBuilder(space, ast, info)
    generator = codegen.FunctionCodeGenerator(
        space, 'function', function_ast, 1, symbols, info)
    blocks = generator.first_block.post_order()
    generator._resolve_block_targets(blocks)
    return generator, blocks
예제 #8
0
def generate_function_code(expr, space):
    p = pyparse.PythonParser(space)
    info = pyparse.CompileInfo("<test>", 'exec')
    cst = p.parse_source(expr, info)
    ast = astbuilder.ast_from_node(space, cst, info)
    function_ast = optimize.optimize_ast(space, ast.body[0], info)
    function_ast = ast.body[0]
    symbols = symtable.SymtableBuilder(space, ast, info)
    generator = codegen.FunctionCodeGenerator(space, 'function', function_ast,
                                              1, symbols, info)
    blocks = generator.first_block.post_order()
    generator._resolve_block_targets(blocks)
    return generator, blocks