Пример #1
0
def create_pyx_pipeline(context, options, result, py=False, exclude_classes=()):
    if py:
        mode = 'py'
    else:
        mode = 'pyx'
    test_support = []
    if options.evaluate_tree_assertions:
        from Cython.TestUtils import TreeAssertVisitor
        test_support.append(TreeAssertVisitor())

    if options.gdb_debug:
        from Cython.Debugger import DebugWriter
        from ParseTreeTransforms import DebugTransform
        context.gdb_debug_outputwriter = DebugWriter.CythonDebugWriter(
            options.output_dir)
        debug_transform = [DebugTransform(context, options, result)]
    else:
        debug_transform = []

    return list(itertools.chain(
        [parse_stage_factory(context)],
        create_pipeline(context, mode, exclude_classes=exclude_classes),
        test_support,
        [inject_pxd_code_stage_factory(context),
         inject_utility_code_stage_factory(context),
         abort_on_errors],
        debug_transform,
        [generate_pyx_code_stage_factory(options, result)]))
Пример #2
0
    def create_pyx_pipeline(self, options, result, py=False):
        def generate_pyx_code(module_node):
            module_node.process_implementation(options, result)
            result.compilation_source = module_node.compilation_source
            return result

        def inject_pxd_code(module_node):
            from textwrap import dedent
            stats = module_node.body.stats
            for name, (statlistnode, scope) in self.pxds.iteritems():
                # Copy over function nodes to the module
                # (this seems strange -- I believe the right concept is to split
                # ModuleNode into a ModuleNode and a CodeGenerator, and tell that
                # CodeGenerator to generate code both from the pyx and pxd ModuleNodes.
                stats.append(statlistnode)
                # Until utility code is moved to code generation phase everywhere,
                # we need to copy it over to the main scope
                module_node.scope.utility_code_list.extend(
                    scope.utility_code_list)
            return module_node

        test_support = []
        if options.evaluate_tree_assertions:
            from Cython.TestUtils import TreeAssertVisitor
            test_support.append(TreeAssertVisitor())

        return ([
            create_parse(self),
        ] + self.create_pipeline(pxd=False, py=py) + test_support + [
            inject_pxd_code,
            abort_on_errors,
            generate_pyx_code,
        ])
Пример #3
0
    def create_pyx_pipeline(self, options, result, py=False):
        def generate_pyx_code(module_node):
            module_node.process_implementation(options, result)
            result.compilation_source = module_node.compilation_source
            return result

        def inject_pxd_code(module_node):
            from textwrap import dedent
            stats = module_node.body.stats
            for name, (statlistnode, scope) in self.pxds.iteritems():
                # Copy over function nodes to the module
                # (this seems strange -- I believe the right concept is to split
                # ModuleNode into a ModuleNode and a CodeGenerator, and tell that
                # CodeGenerator to generate code both from the pyx and pxd ModuleNodes.
                 stats.append(statlistnode)
                 # Until utility code is moved to code generation phase everywhere,
                 # we need to copy it over to the main scope
                 module_node.scope.utility_code_list.extend(scope.utility_code_list)
            return module_node

        test_support = []
        if options.evaluate_tree_assertions:
            from Cython.TestUtils import TreeAssertVisitor
            test_support.append(TreeAssertVisitor())

        if options.gdb_debug:
            from Cython.Debugger import DebugWriter
            from ParseTreeTransforms import DebugTransform
            self.gdb_debug_outputwriter = DebugWriter.CythonDebugWriter(
                options.output_dir)
            debug_transform = [DebugTransform(self, options, result)]
        else:
            debug_transform = []

        return list(itertools.chain(
            [create_parse(self)],
            self.create_pipeline(pxd=False, py=py),
            test_support,
            [inject_pxd_code, abort_on_errors],
            debug_transform,
            [generate_pyx_code]))