public void replaceChild(ExecutionNode oldChild, ExecutionNode newChild) { removeChild(oldChild); newChild.setParent(this); }
private void removeFromNodePile(MethodLocation location) { List<ExecutionNode> nodePile = locationToNodePile.remove(location); Map<MethodLocation, ExecutionNode> locationToChildNodeToRemove = new HashMap<>(); for (ExecutionNode removedNode : nodePile) { ExecutionNode parentNode = removedNode.getParent(); if (parentNode == null) { continue; } parentNode.removeChild(removedNode); recreateLocations.add(parentNode.getOp().getLocation()); // reexecuteLocations.add(parentNode.getOp().getLocation()); for (ExecutionNode childNode : removedNode.getChildren()) { Op childOp = childNode.getOp(); boolean pseudoChild = childOp instanceof FillArrayDataPayloadOp || childOp instanceof SwitchPayloadOp; if (!pseudoChild) { reparentNode(childNode, parentNode); } else { // pseudo child // Implementation was altered such that dexlib removed something, probably nop padding for (ExecutionNode grandChildNode : childNode.getChildren()) { reparentNode(grandChildNode, parentNode); } locationToChildNodeToRemove.put(childOp.getLocation(), childNode); } } } for (Entry<MethodLocation, ExecutionNode> entry : locationToChildNodeToRemove.entrySet()) { List<ExecutionNode> pile = locationToNodePile.get(entry.getKey()); pile.remove(entry.getValue()); } }
ExecutionContext newContext; if (shiftedParent != null) { shiftedParent.removeChild(shiftedNode); reparentNode(newNode, shiftedParent);