# HG changeset patch # User Thinker K.F. Li # Date 1308652605 -28800 # Node ID 67aa8ca8fff310106f06a0168d46dd3ebc7efbbc # Parent 00d106f6c427fbe49de59b825c4ea1f55114d9e1 untested dex_deptracker.update_offset() diff -r 00d106f6c427 -r 67aa8ca8fff3 paraspace/dex_deptracker.py --- a/paraspace/dex_deptracker.py Mon Jun 20 22:19:37 2011 +0800 +++ b/paraspace/dex_deptracker.py Tue Jun 21 18:36:45 2011 +0800 @@ -265,7 +265,7 @@ return all_dep_decls -class _marker(dexfile.relocatable): +class _marker(dexfile.null_relocatable): back_type = None pass @@ -696,17 +696,30 @@ def update_offset(dexroot, all_dep_decls): - depon_dep_map = _build_sub_depon_dep(all_dep_decls) - - def skip_dep(obj, parents, name_path): - if name_path in all_dep_decls: - return True - return False + from dexfile import man_off + + moff = man_off(0) + queue = [dexroot] - for obj, parents, name_path in \ - _travel_dex_relocatable(dexroot, skip_func=skip_dep): - if name_path not in depon_dep_map: + while queue: + obj = queue.pop() + if isinstance(obj, _marker): + obj.set_marker(moff()) + pass + if isinstance(obj, dexfile.relocatable): + moff(obj.sizeof()) + pass + + if isinstance(obj, dexfile.ref): continue + if not isinstance(obj, dexfile.relocatable): + continue + + children = list(obj.children()) + attrs = [_dex_tree_get_child(obj, child) + for child in children] + attrs.reverse() + queue = queue + attrs pass pass