Example #1
0
File: nodes.py Project: lowks/ctree
    def codegen(self, indent=0):
        """
        Code generates each file in the project and links their
        bytecode together to get the master bytecode file.
        """
        from ctree.jit import JitModule

        module = JitModule()

        # now that we have a concrete compilation dir, resolve references to it
        from ctree.transformations import ResolveGeneratedPathRefs

        resolver = ResolveGeneratedPathRefs(module.compilation_dir)
        self.files = [resolver.visit(f) for f in self.files]
        log.info("automatically resolved %d GeneratedPathRef node(s).", resolver.count)

        # transform all files into llvm modules and link them into the master module
        for f in self.files:
            submodule = f._compile(f.codegen(), module.compilation_dir)
            if submodule:
                module._link_in(submodule)
        return module