Mercurial > paraspace
changeset 55:6e4cf6905729
Seeking parents in reversed order for _build_associations()
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 24 Jun 2011 00:33:08 +0800 |
parents | 870312703ba1 |
children | 7f23def22a95 |
files | paraspace/dex_deptracker.py paraspace/dexfile.py paraspace/tests/dexfile_test.py |
diffstat | 3 files changed, 35 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/dex_deptracker.py Thu Jun 23 09:32:51 2011 +0800 +++ b/paraspace/dex_deptracker.py Fri Jun 24 00:33:08 2011 +0800 @@ -166,7 +166,14 @@ def _dex_tree_get_child(obj, child_name): child_parts = child_name.split('.') + last_child_part = '' for child_part in child_parts: + if isinstance(obj, dexfile.cond) and not obj.is_true: + raise AttributeError, \ + 'dexfile.cond is not true for %s of %s' % \ + (last_child_part, child_name) + last_child_part = child_part + if isinstance(obj, list): idx = int(child_part) obj = obj[idx] @@ -587,14 +594,17 @@ for obj, parents, name_path in \ _travel_dex_relocatable(root_obj): if isinstance(obj, dexfile._objs_asso): - for parent in parents: + rev_parents = list(parents) + rev_parents.reverse() + for parent in rev_parents: if isinstance(parent, dexfile.composite): break pass + print parent, obj.left left_elts = _dex_tree_get_child(parent, obj.left) right_elts = _dex_tree_get_child(parent, obj.right) - obj.build_associations() + obj.build_associations(left_elts, right_elts) pass pass pass
--- a/paraspace/dexfile.py Thu Jun 23 09:32:51 2011 +0800 +++ b/paraspace/dexfile.py Fri Jun 24 00:33:08 2011 +0800 @@ -366,6 +366,21 @@ # def build_associations(self, left, right): raise NotImplementedError, 'build_associations is not implemented' + + def parse(self, parent, data, off): + return self + + def sizeof(self, obj): + return 0 + + def to_str(self): + return '' + + def compute_size(self): + pass + + def children(self): + return [] pass @@ -1061,7 +1076,7 @@ child_names = \ 'registersSize insSize outsSize triesSize debugInfoOff ' \ 'insnsSize insns padding try_items handlers_size ' \ - 'catch_handler_items padding2'.split() + 'catch_handler_items try_catch_asso padding2'.split() pass
--- a/paraspace/tests/dexfile_test.py Thu Jun 23 09:32:51 2011 +0800 +++ b/paraspace/tests/dexfile_test.py Fri Jun 24 00:33:08 2011 +0800 @@ -248,6 +248,13 @@ code_item = dex.codeItems.items[0] assert code_item.debugInfoOff.__class__.__name__ == '_DEX_DebugInfoItem' + + code_item = dex.codeItems.items[4] + assert code_item.try_items.value + try_item = code_item.try_items.value.items[0] + assert try_item.catch_ref is not None + catch_item = code_item.catch_handler_items.value.items[0] + assert catch_item.try_ref is not None anno_dir_item = dex.annotationsDirectoryItems.items[0] assert isinstance(anno_dir_item.classAnnotationsOffRef.value,