comparison paraspace/dex_deptracker.py @ 52:67aa8ca8fff3

untested dex_deptracker.update_offset()
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 21 Jun 2011 18:36:45 +0800
parents 38fdd422f611
children 705356005362
comparison
equal deleted inserted replaced
51:00d106f6c427 52:67aa8ca8fff3
263 pass 263 pass
264 264
265 return all_dep_decls 265 return all_dep_decls
266 266
267 267
268 class _marker(dexfile.relocatable): 268 class _marker(dexfile.null_relocatable):
269 back_type = None 269 back_type = None
270 pass 270 pass
271 271
272 class _uid_marker(_marker): 272 class _uid_marker(_marker):
273 uid_seq = 0 273 uid_seq = 0
694 depon_dep_map = dict(depon_dep_lst) 694 depon_dep_map = dict(depon_dep_lst)
695 pass 695 pass
696 696
697 697
698 def update_offset(dexroot, all_dep_decls): 698 def update_offset(dexroot, all_dep_decls):
699 depon_dep_map = _build_sub_depon_dep(all_dep_decls) 699 from dexfile import man_off
700 700
701 def skip_dep(obj, parents, name_path): 701 moff = man_off(0)
702 if name_path in all_dep_decls: 702 queue = [dexroot]
703 return True 703
704 return False 704 while queue:
705 705 obj = queue.pop()
706 for obj, parents, name_path in \ 706 if isinstance(obj, _marker):
707 _travel_dex_relocatable(dexroot, skip_func=skip_dep): 707 obj.set_marker(moff())
708 if name_path not in depon_dep_map: 708 pass
709 continue 709 if isinstance(obj, dexfile.relocatable):
710 moff(obj.sizeof())
711 pass
712
713 if isinstance(obj, dexfile.ref):
714 continue
715 if not isinstance(obj, dexfile.relocatable):
716 continue
717
718 children = list(obj.children())
719 attrs = [_dex_tree_get_child(obj, child)
720 for child in children]
721 attrs.reverse()
722 queue = queue + attrs
710 pass 723 pass
711 pass 724 pass
712 725
713 726
714 ## \brief Restore to raw value before linking for dependencies. 727 ## \brief Restore to raw value before linking for dependencies.