Mercurial > paraspace
diff paraspace/dex_deptracker.py @ 41:c5cfc796af8b
Use value_ref & cond in dexfile.py to avoid 0 offset value
Some object would use zero value for an invalid dependency offset, it
causes an key error. We use dexfile.cond and add dexfile.value_ref
class to build dependencies conditional.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 19 Jun 2011 13:47:35 +0800 |
parents | 0c0a659187c2 |
children | 8ca4a6bc6b79 |
line wrap: on
line diff
--- a/paraspace/dex_deptracker.py Sat Jun 18 23:59:37 2011 +0800 +++ b/paraspace/dex_deptracker.py Sun Jun 19 13:47:35 2011 +0800 @@ -484,8 +484,6 @@ if type(attr) == type and issubclass(attr, dexfile.composite) and attr in marked_types] - import pprint - pprint.pprint(marked_type_refs) def patch_ref(name_path, depon_path): depon, depon_parent = _resolve_name_path(depon_path) @@ -532,6 +530,16 @@ pass +def _build_refs(root_obj): + for obj, parents, name_path in \ + _travel_dex_relocatable(root_obj): + if not isinstance(obj, dexfile.value_ref): + continue + obj.set_value(parents) + pass + pass + + def _link_dependencies(root_obj, all_dep_decls): markers_info = {} depon_src_map = {} @@ -562,6 +570,9 @@ if name_path not in all_dep_decls: continue + if obj is None and isinstance(parents[-1], dexfile.cond): + continue + dep = all_dep_decls[name_path] dep_type = dep[0] if dep_type == dexfile.depend_off_rel: