# HG changeset patch # User Thinker K.F. Li # Date 1309536197 -28800 # Node ID 6c2efdeffa7bb6dab40d6dce6520f0ce3f60f139 # Parent 17b9d02a5f3c9897b431374ba777681c736bf994 Strip instruction string for opcode with no any argument. diff -r 17b9d02a5f3c -r 6c2efdeffa7b paraspace/dalvik_opcodes.py --- a/paraspace/dalvik_opcodes.py Fri Jul 01 17:58:43 2011 +0800 +++ b/paraspace/dalvik_opcodes.py Sat Jul 02 00:03:17 2011 +0800 @@ -1195,8 +1195,13 @@ fmt_parse_cfg = fmt_parse_cfgs[fmt_name] arg_part = ''.join([encode_arg(arg, sz) for arg, sz in map(None, args, fmt_parse_cfg)]) + + inst = chr(opcode) + arg_part + + while len(inst) % 2: + encode_arg(0, 1) + pass - inst = chr(opcode) + arg_part return inst @@ -1209,7 +1214,11 @@ fmt_name = fmt_names[fmt] fmt_str = fmt_fmtstr[fmt_name] - line = opname + ' ' + fmt_str.format(*args) + if fmt_str: + line = opname + ' ' + fmt_str.format(*args) + else: + line = opname + pass return line diff -r 17b9d02a5f3c -r 6c2efdeffa7b paraspace/tests/dalvik_opcodes_test.py --- a/paraspace/tests/dalvik_opcodes_test.py Fri Jul 01 17:58:43 2011 +0800 +++ b/paraspace/tests/dalvik_opcodes_test.py Sat Jul 02 00:03:17 2011 +0800 @@ -54,4 +54,8 @@ line = format_inst(opv) assert line == 'OP_INVOKE_SUPER {v1, v0, v0, v0, v0},' \ ' thing@a601 (1: count, A: vG)' + + opv = (0, ()) + line = format_inst(opv) + assert line == 'OP_NOP' pass