def get_context(self, func): try: func = func.im_func except AttributeError: pass code = HostCode._from_code(func.func_code) graph = PyGraph(func, code) ctx = FlowContext(graph, code) # hack the frame ctx.setstate(graph.startblock.framestate) ctx.locals_stack_w[ctx.pycode.co_nlocals - 1] = Constant(None) return ctx
def get_context(self, func): try: func = func.im_func except AttributeError: pass code = HostCode._from_code(func.func_code) graph = PyGraph(func, code) ctx = FlowContext(graph, code) # hack the frame ctx.setstate(graph.startblock.framestate) ctx.locals_stack_w[ctx.pycode.co_nlocals-1] = Constant(None) return ctx
def build_flow(func): """ Create the flow graph (in SSA form) for the function. """ _assert_rpythonic(func) if (isgeneratorfunction(func) and not hasattr(func, '_generator_next_method_of_')): return make_generator_entry_graph(func) code = HostCode._from_code(func.func_code) graph = PyGraph(func, code) ctx = FlowContext(graph, code) ctx.build_flow() fixeggblocks(graph) if code.is_generator: tweak_generator_graph(graph) return graph