# HG changeset patch # User Thinker K.F. Li # Date 1311072390 -28800 # Node ID 835b8f9de23e8786dcc70f4807f19a0dd6b99242 # Parent 9c7bfb13b2624ae0015c91d73d1503f530dde5a5 Add doc for doxygen diff -r 9c7bfb13b262 -r 835b8f9de23e paraspace/dalvik_opcodes.py --- a/paraspace/dalvik_opcodes.py Tue Jul 19 18:03:30 2011 +0800 +++ b/paraspace/dalvik_opcodes.py Tue Jul 19 18:46:30 2011 +0800 @@ -262,13 +262,16 @@ OP_UNUSED_FF = 0xff pass +## \brief List of names of opcodes opcode_names = sorted([name for name in all_opcodes.__dict__.keys() if name.startswith('OP_')], key=lambda name: all_opcodes.__dict__[name]) +## \brief Map opcode names to opcodes name_2_opcodes = dict([(name, code) for name, code in all_opcodes.__dict__.items()]) +## \brief Length of instructions of opcodes in bytes opcode_widths = [0] * 256 _w1_ops = '''OP_NOP @@ -635,6 +638,7 @@ kFmt51l '''.split() +## \brief Map opcodes to their formats opcode_fmts = [0] * 256 opcode_fmts[all_opcodes.OP_GOTO] = all_opcode_fmts.kFmt10t @@ -1036,6 +1040,7 @@ pass +## \brief String for string format from name of format. fmt_fmtstr = { 'kFmtUnknown': '', 'kFmt10x': '', @@ -1070,6 +1075,7 @@ 'kFmt51l': 'v{0}, #+{1:016x}' } +## \brief Map from names of opcode formats to tuples of fields size fmt_parse_cfgs = { 'kFmtUnknown': (), # '' 'kFmt10x': (), # '' @@ -1105,6 +1111,7 @@ 'kFmt51l': (2, 16) # 'vAA, #+BBBBBBBBBBBBBBBB' } +## \brief Decode an instruction def decode_inst(insn): def build_arg(sz): if sz == 1: @@ -1160,6 +1167,7 @@ return op_vector +## \brief Encode a opcode and arguments vector to an instruction def encode_inst(op_vector): def encode_arg(arg, sz): if sz == 1: @@ -1216,6 +1224,7 @@ return inst +## \brief Generate formated string for given opcode and arguments vector def format_inst(op_vector): opcode, args = op_vector