Ejemplo n.º 1
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, e:
         raise OperationError(space.w_SyntaxError, e.wrap_info(space))
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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))
Ejemplo n.º 5
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))
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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