de.gaalop.cfg.Node类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(84)

本文整理了Java中de.gaalop.cfg.Node类的一些代码示例,展示了Node类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node类的具体详情如下:
包路径:de.gaalop.cfg.Node
类名称:Node

Node介绍

[英]This abstract class serves as the base class for all control flow nodes in a control flow graph.

Please note that all implementing classes should provide a meaningful implementation of Object#toString(), Object#hashCode() and Object#equals(Object).
[中]此抽象类用作控制流图中所有控制流节点的基类。
请注意,所有实现类都应该提供对象#toString()、对象#hashCode()和对象#equals(Object)的有意义的实现。

代码示例

代码示例来源:origin: CallForSanity/Gaalop

/**
 * Returns the type of a ControlFlowGraphNode
 * @param node The node
 * @return The type of the given node
 */
public static CFGNodeType getTypeOfCFGNode(Node node) {
  if (node == null) {
    return null;
  }
  node.accept(getter);
  return getter.type;
}

代码示例来源:origin: CallForSanity/Gaalop

/**
   * Inserts another node right before this node.
   * <p/>
   * The new node is added as a successor of all predecessors of this node and this node is set as the successor of the new
   * node.
   * 
   * @param newNode The node that should be inserted.
   */
  public void insertBefore(SequentialNode newNode) {
    newNode.setSuccessor(this);
    Set<Node> predecessors = new HashSet<Node>(getPredecessors());
    for (Node predecessor : predecessors) {
      predecessor.replaceSuccessor(this, newNode);
    }
    predecessors.clear(); // previous predecessors are no predecessors anymore
    addPredecessor(newNode);
  }
}

代码示例来源:origin: CallForSanity/Gaalop

/**
 * Removes the given node from the control flow graph. The graph will be traversed in order to find the node to be
 * removed. Once the desired node is found, its predecessors are rewired to have the old node's successor as direct
 * successors.
 * 
 * @param node node to be removed
 */
public void removeNode(SequentialNode node) {
  Node successor = node.getSuccessor();
  successor.removePredecessor(node);
  Set<Node> predecessors = new HashSet<Node>(node.getPredecessors());
  for (Node predecessor : predecessors) {
    successor.addPredecessor(predecessor);
    predecessor.replaceSuccessor(node, successor);
  }
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void replaceSuccessor(Node oldSuccessor, Node newSuccessor) {
  if (successor == oldSuccessor) {
    successor = null;
    oldSuccessor.removePredecessor(this);
    newSuccessor.removePredecessor(oldSuccessor);
    newSuccessor.addPredecessor(this);
    successor = newSuccessor;
  }
}

代码示例来源:origin: CallForSanity/Gaalop

private void addPredecessorEdges(Node node) {
  // Add edges back to predecessors
  for (Node predecessor : node.getPredecessors()) {
    addBackwardsEdge(node, predecessor);
  }
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void replaceSuccessor(Node oldSuccessor, Node newSuccessor) {
  if (oldSuccessor == body) {
    newSuccessor.removePredecessor(oldSuccessor);
    newSuccessor.addPredecessor(this);
    body = (SequentialNode) newSuccessor;
  } else {
    super.replaceSuccessor(oldSuccessor, newSuccessor);
  }
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void visit(Macro node) {
  // ignore body of macro
  node.getSuccessor().accept(this);
}

代码示例来源:origin: CallForSanity/Gaalop

/**
 * Inserts a node after this sequential node and its successor. This method will rewire the nodes to keep the graph
 * consistent. It will do the following:
 * <ol>
 * <li>Remove the connection between this node and its successor.</li>
 * <li>Add a bi-directional connection between this node and the new node.</li>
 * <li>Add a bi-directional connection between the new node and this nodes old successor.</li>
 * </ol>
 * 
 * @param newNode The new node that should be inserted in the control flow after this one.
 */
public void insertAfter(SequentialNode newNode) {
  Node oldSuccessor = successor;
  successor = newNode;
  newNode.addPredecessor(this);
  if (oldSuccessor != null) {
    newNode.successor = oldSuccessor;
    oldSuccessor.removePredecessor(this);
    oldSuccessor.addPredecessor(newNode);
  }
}

代码示例来源:origin: CallForSanity/Gaalop

/**
 * {@inheritDoc}
 *
 * This empty implementation visits the successor node by default.
 */
@Override
public void visit(BreakNode node) {
  node.getSuccessor().accept(this);
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void replaceSuccessor(Node oldSuccessor, Node newSuccessor) {
  if (oldSuccessor == positive) {
    newSuccessor.removePredecessor(oldSuccessor);
    newSuccessor.addPredecessor(this);
    // cast is safe since branch of if-then-else cannot be the end node
    setPositive((SequentialNode) newSuccessor);
  } else if (oldSuccessor == negative) {
    newSuccessor.removePredecessor(oldSuccessor);
    newSuccessor.addPredecessor(this);
    // cast is safe since branch of if-then-else cannot be the end node
    setNegative((SequentialNode) newSuccessor);
  } else {
    super.replaceSuccessor(oldSuccessor, newSuccessor);
  }
}

代码示例来源:origin: CallForSanity/Gaalop

/**
 * {@inheritDoc}
 *
 * This empty implementation visits the successor node by default.
 */
@Override
public void visit(Macro node) {
  node.getSuccessor().accept(this);
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void visit(StartNode node) {
  code.append("\\begin{align*}\n");
  node.getSuccessor().accept(this);
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void visit(BreakNode breakNode) {
  code.append("\\text{break}\\\\");
  breakNode.getSuccessor().accept(this);
}

代码示例来源:origin: CallForSanity/Gaalop

/**
 * {@inheritDoc}
 * 
 * This empty implementation visits the successor node by default.
 */
@Override
public void visit(AssignmentNode node) {
  node.getSuccessor().accept(this);
}

代码示例来源:origin: CallForSanity/Gaalop

/**
 * {@inheritDoc}
 * 
 * This empty implementation visits the successor node by default.
 */
@Override
public void visit(StoreResultNode node) {
  node.getSuccessor().accept(this);
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void visit(StoreResultNode node) {
  System.out.println("MyStoreResultVisit");

  node.getSuccessor().accept(this);
  // TODO Auto-generated method stub
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void visit(StartNode node) {
  // just do nothing, because only MulitvectorComponent is important
  node.getSuccessor().accept(this);
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void visit(Macro node) {
  // ignore body of macro
  node.getSuccessor().accept(this);
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
  public void visit(ColorNode node) {
    node.getSuccessor().accept(this);
  }
}

代码示例来源:origin: CallForSanity/Gaalop

@Override
public void visit(ExpressionStatement node) {
  nodeList.addLast(node);
  node.getSuccessor().accept(this);
}

相关文章

微信公众号

最新文章

更多