# HG changeset patch # User Thinker K.F. Li # Date 1308488911 -28800 # Node ID 94e80f7a61b56dec0f438d2d5bf237c62833acd6 # Parent 71218ba3bc8a1fcf72dd460f1d79396da2f80518 Add dex_deptracker.restore_dependencies() diff -r 71218ba3bc8a -r 94e80f7a61b5 paraspace/dex_deptracker.py --- a/paraspace/dex_deptracker.py Sun Jun 19 20:53:28 2011 +0800 +++ b/paraspace/dex_deptracker.py Sun Jun 19 21:08:31 2011 +0800 @@ -667,6 +667,43 @@ pass +## \brief Restore to raw value before linking for dependencies. +# +def restore_dependencies(dexroot, all_dep_decls): + for obj, parents, name_path in \ + _travel_dex_relocatable(dexroot): + if name_path not in all_dep_decls: + continue + + imm_parent = parents[-1] + if isinstance(imm_parent, dexfile.cond) and not imm_parent.is_true: + continue + + dep = all_dep_decls[name_path] + dep_type = dep[0] + if dep_type == dexfile.depend_off_rel: + depon1 = _rel_offset_marker.find_depon(dep[1], parents) + depon2 = _rel_offset_marker.find_depon(dep[2], parents) + + name = name_path.split('.')[-1] + off = depon2.data_offset - depon1.data_offset + _dex_tree_set_child(imm_parent, name, off) + elif dep_type == dexfile.depend_off: + depon_name_path = dep[1] + depon = markers_info[depon_name_path][obj] + name = name_path.split('.')[-1] + _dex_tree_set_child(imm_parent, name, depon.data_offset) + elif dep_type == dexfile.depend_idx: + depon_name_path = dep[1] + depon = markers_info[depon_name_path][obj] + name = name_path.split('.')[-1] + _dex_tree_set_child(imm_parent, name, depon.data_idx) + else: + raise TypeError, 'invalid depend type %s' % (repr(dep_type)) + pass + pass + + def _sync_dependencies(): pass