Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parseInstruction(dex, insns_start_pos, shorts, pos):
word = shorts[pos]
opcode = word & 0xFF
newpos, args = dalvikformats.decode(shorts, pos, opcode)
# parse special data instructions
switchdata = None
fillarrdata = None
if word == 0x100 or word == 0x200: # switch
size = shorts[pos + 1]
st = dex.stream(insns_start_pos + pos * 2 + 4)
if word == 0x100: # packed
first_key = st.u32()
targets = [st.u32() for _ in range(size)]
newpos = pos + 2 + (1 + size) * 2
switchdata = {(i + first_key): x for i, x in enumerate(targets)}
else: # sparse
keys = [st.u32() for _ in range(size)]
targets = [st.u32() for _ in range(size)]