def analyse_generator_code(known_globals, generator_code): asm_indexes, indexed_asm = disassemble_code(generator_code) for i in range(len(asm_indexes)): index = asm_indexes[i] elem = indexed_asm[index] if elem['mnemo'] == 'STORE_FAST': variable_name = elem['indic'] expr_start = i+1 break asm_indexes = asm_indexes[expr_start:] asm_indexes, indexed_asm = analyse_structures(asm_indexes, indexed_asm) statements = decompile.bloc.decompile_bloc( indexed_asm, generator_code, known_globals, index=asm_indexes[0], indent=0) #print 'statements:', statements expr_code = statements[0][1] # first statement, code part (first part is indent) return expr_code, variable_name
def decompile_func_body(func_code, known_globals, body_indent): asm_indexes, indexed_asm = disassemble_code(func_code) asm_indexes, indexed_asm = analyse_structures(asm_indexes, indexed_asm) return decompile_bloc( indexed_asm, func_code, known_globals, index=asm_indexes[0], indent=body_indent, is_top_level_bloc=True)