Search in sources :

Example 1 with TypeMemberTreeNode

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeMemberTreeNode in project binnavi by google.

the class ViewReferencesTableModel method addCompoundTypeSubstitutionToTree.

/**
   * Adds a {@link TypeSubstitution type substitution} for the given {@link INaviInstruction
   * instruction} to the tree. The types passed to this function need to be compund types.
   *
   * @param operandNode The {@link INaviOperandTreeNode operand node} which holds the
   *        {@link TypeSubstitution type substitution}.
   * @param instruction The {@link INaviInstruction instruction} which holds the
   *        {@link INaviOperandTreeNode operand node}.
   * @param typeSubstitution A {@link TypeSubstitution type substitution} which is a compound type.
   *        Must be of a compound {@link BaseTypeCategory base type category}.
   */
private void addCompoundTypeSubstitutionToTree(final INaviOperandTreeNode operandNode, final INaviInstruction instruction, final TypeSubstitution typeSubstitution) {
    final long completeOffset = operandNode.hasAddendSibling() ? (operandNode.determineAddendValue() * 8 + typeSubstitution.getOffset()) : typeSubstitution.getOffset();
    final WalkResult walkResult = BaseTypeHelpers.findMember(typeSubstitution.getBaseType(), completeOffset);
    if (!walkResult.isValid()) {
        return;
    }
    addBaseType(typeSubstitution.getBaseType());
    DefaultMutableTreeNode currentNode = baseTypeToTreeNode.get(typeSubstitution.getBaseType());
    for (TypeMember typeMember : walkResult.getPath()) {
        TypeMemberTreeNode nextNode = checkTypeMemberNodeExists(typeMember, currentNode);
        if (nextNode == null) {
            nextNode = new TypeMemberTreeNode(typeMember);
            typeMemberToTreeNode.put(typeMember, nextNode);
            insertNodeInto(nextNode, currentNode, currentNode.getChildCount());
        }
        currentNode = nextNode;
    }
    insertNodeInto(multiIndex.putTypeSubstitution(typeSubstitution, instruction), currentNode, currentNode.getChildCount());
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TypeMember(com.google.security.zynamics.binnavi.disassembly.types.TypeMember) WalkResult(com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult) TypeMemberTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeMemberTreeNode)

Example 2 with TypeMemberTreeNode

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeMemberTreeNode in project binnavi by google.

the class ViewReferencesTableModel method removeFromTree.

/**
   * Given a {@link DefaultMutableTreeNode node} removes the node from the tree. Also it removes all
   * parent nodes which after the removal of the child have no other children any more.
   *
   * @param node The {@link DefaultMutableTreeNode node} which to remove from the tree.
   */
private void removeFromTree(DefaultMutableTreeNode node) {
    Preconditions.checkNotNull(node, "Error: node argument can not be null.");
    Preconditions.checkArgument(!node.isRoot(), "Error: node argument can not be the root node.");
    final Set<DefaultMutableTreeNode> nodesToDelete = Sets.newHashSet();
    nodesToDelete.add(node);
    while (node.getSiblingCount() == 1 && node.getParent() != getRoot()) {
        node = (DefaultMutableTreeNode) node.getParent();
        nodesToDelete.add(node);
    }
    for (DefaultMutableTreeNode currentNode : nodesToDelete) {
        removeNodeFromParent(currentNode);
        if (currentNode instanceof InstructionNode) {
            multiIndex.removeInstructionNode((InstructionNode) currentNode);
        }
        if (currentNode instanceof BaseTypeTreeNode) {
            baseTypeToTreeNode.remove(((BaseTypeTreeNode) currentNode).getBaseType());
        }
        if (currentNode instanceof TypeMemberTreeNode) {
            typeMemberToTreeNode.remove(((TypeMemberTreeNode) currentNode).getTypeMember(), currentNode);
        }
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) BaseTypeTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode) TypeMemberTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeMemberTreeNode)

Aggregations

TypeMemberTreeNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypeMemberTreeNode)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 BaseTypeTreeNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.types.BaseTypeTreeNode)1 WalkResult (com.google.security.zynamics.binnavi.disassembly.types.BaseTypeHelpers.WalkResult)1 TypeMember (com.google.security.zynamics.binnavi.disassembly.types.TypeMember)1