How to use the bytecode.ControlFlowGraph.from_bytecode function in bytecode

To help you get started, we’ve selected a few bytecode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thautwarm / restrain-jit / restrain_jit / bejulia / julia_vm.py View on Github external
def code_info(cls, code: Bytecode) -> PyCodeInfo[Repr]:

        cfg = ControlFlowGraph.from_bytecode(code)
        current = cls.empty()
        run_machine(
            Interpreter(code.first_lineno).abs_i_cfg(cfg), current)
        glob_deps = tuple(current.globals)
        instrs = current.instrs
        instrs = current.pass_push_pop_inline(instrs)
        return PyCodeInfo(code.name, tuple(glob_deps), code.argnames,
                          code.freevars, code.cellvars, code.filename,
                          code.first_lineno, code.argcount,
                          code.kwonlyargcount,
                          bool(code.flags & CompilerFlags.GENERATOR),
                          bool(code.flags & CompilerFlags.VARKEYWORDS),
                          bool(code.flags & CompilerFlags.VARARGS),
                          instrs)