def get_jump_target_maps(code, opc):
    """Returns a dictionary where the key is an offset and the values are
    a list of instruction offsets which can get run before that
    instruction. This includes jump instructions as well as non-jump
    instructions. Therefore, the keys of the dictionary are reachable
    instructions. The values of the dictionary may be useful in control-flow
    analysis.
    """
    offset2prev = {}
    prev_offset = -1
    for offset, op, arg in unpack_opargs_bytecode(code, opc):
        if prev_offset >= 0:
            prev_list = offset2prev.get(offset, [])
            prev_list.append(prev_offset)
            offset2prev[offset] = prev_list
        if op in opc.NOFOLLOW:
            prev_offset = -1
        else:
            prev_offset = offset
        if arg is not None:
            jump_offset = -1
            if op in opc.JREL_OPS:
                op_len = op_size(op, opc)
                jump_offset = offset + op_len + arg
            elif op in opc.JABS_OPS:
                jump_offset = arg
            if jump_offset >= 0:
                prev_list = offset2prev.get(jump_offset, [])
                prev_list.append(offset)
                offset2prev[jump_offset] = prev_list
    return offset2prev
def get_jump_target_maps ( code , opc ) : offset2prev = { } prev_offset = - 1 for offset , op , arg in unpack_opargs_bytecode ( code , opc ) : if prev_offset >= 0 : prev_list = offset2prev . get ( offset , [ ] ) prev_list . append ( prev_offset ) offset2prev [ offset ] = prev_list if op in opc . NOFOLLOW : prev_offset = - 1 else : prev_offset = offset if arg is not None : jump_offset = - 1 if op in opc . JREL_OPS : op_len = op_size ( op , opc ) jump_offset = offset + op_len + arg elif op in opc . JABS_OPS : jump_offset = arg if jump_offset >= 0 : prev_list = offset2prev . get ( jump_offset , [ ] ) prev_list . append ( offset ) offset2prev [ jump_offset ] = prev_list return offset2prev
Returns a dictionary where the key is an offset and the values are
    a list of instruction offsets which can get run before that
    instruction. This includes jump instructions as well as non-jump
    instructions. Therefore, the keys of the dictionary are reachable
    instructions. The values of the dictionary may be useful in control-flow
    analysis.