Mercurial > paraspace
changeset 5:97b7006ced5f
Move move_off imps. to man_off
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 24 May 2011 10:04:59 +0800 |
parents | b0766f1984bb |
children | 917f0a9b9d06 |
files | paraspace/dexfile.py |
diffstat | 1 files changed, 19 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/dexfile.py Tue May 24 09:56:53 2011 +0800 +++ b/paraspace/dexfile.py Tue May 24 10:04:59 2011 +0800 @@ -378,7 +378,7 @@ def parse(self, num, data, off): def parse(): - off = (cur_off[0] + 3) & ~0x3 + off = (cur_off[0] + 3) & ~0x3 # type list must aligned for 4 bytes typeList = _DEX_TypeList() typeList.parse(data, off) cur_off[0] = off + typeList.data_size @@ -443,14 +443,9 @@ data_size = None def parse(self, data, off): - def move_off(sz): - off = move_off.off - move_off.off = off + sz - return off - move_off.off = off - moff = move_off + moff = man_off(off) - count, sh = _leb128(data[moff.off:moff.off + 5]) + count, sh = _leb128(data[moff():moff() + 5]) moff(sh) if count > 0: @@ -462,7 +457,7 @@ def parse_handler(): handler = _DEX_CatchHandler() - handler.parse(data, moff.off) + handler.parse(data, moff()) moff(handler.data_size) return handler @@ -473,12 +468,12 @@ # Additional handler for catching all # handler = _DEX_CatchHandler() - handler.parse1(data, moff.off) + handler.parse1(data, moff()) moff(handler.data_size) self.handlers.append(handler) pass - self.data_size = moff.off - off + self.data_size = moff() - off pass pass @@ -497,55 +492,44 @@ data_size = None def parse(self, data, off): - def move_off(sz): - off = move_off.off - move_off.off = off + sz - return off - move_off.off = off - moff = move_off + moff = man_off(off) - self.registersSize = _to_uint(data[moff.off:moff.off + 2]) - moff(2) - self.insSize = _to_uint(data[moff.off:moff.off + 2]) - moff(2) - self.outsSize = _to_uint(data[moff.off:moff.off + 2]) - moff(2) - self.triesSize = _to_uint(data[moff.off:moff.off + 2]) - moff(2) - self.debugInfoOff = _to_uint(data[moff.off:moff.off + 4]) - moff(4) - self.insnsSize = _to_uint(data[moff.off:moff.off + 4]) - moff(4) + self.registersSize = _to_uint(data[moff(2):moff()]) + self.insSize = _to_uint(data[moff(2):moff()]) + self.outsSize = _to_uint(data[moff(2):moff()]) + self.triesSize = _to_uint(data[moff(2):moff()]) + self.debugInfoOff = _to_uint(data[moff(4):moff()]) + self.insnsSize = _to_uint(data[moff(4):moff()]) moff(self.insnsSize * 2) # skip insns if self.triesSize > 0: def parse_try_item(): try_item = _DEX_Try() - try_item.parse(data, moff.off) + try_item.parse(data, moff()) moff(try_item.data_size) return try_item - moff.off = (moff.off + 3) & ~0x3 + moff.off = (moff.off + 3) & ~0x3 # align tries to 4 bytes self.try_items = [parse_try_item() for i in range(self.triesSize)] def parse_catch_handler(): catch = _DEX_Catch() - catch.parse(data, moff.off) + catch.parse(data, moff()) moff(catch.data_size) return catch # # No tries, no catch handlers # - handlersSize, sh = _uleb128(data[moff.off:moff.off + 5]) + handlersSize, sh = _uleb128(data[moff():moff() + 5]) moff(sh) self.catch_handler_items = [parse_catch_handler() for i in range(handlersSize)] pass - moff.off = (moff.off + 3) & ~0x3 - self.data_size = moff.off - off + moff.off = (moff() + 3) & ~0x3 # round code item to 4 bytes + self.data_size = moff() - off pass pass