com.oracle.truffle.api.nodes.Node.getChildren()方法的使用及代码示例

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

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

Node.getChildren介绍

[英]Iterator over the children of this node.
[中]迭代此节点的子节点。

代码示例

代码示例来源:origin: com.oracle.truffle/truffle-api

/** @since 0.8 or earlier */
public static <T> T findFirstNodeInstance(Node root, Class<T> clazz) {
  if (clazz.isInstance(root)) {
    return clazz.cast(root);
  }
  for (Node child : root.getChildren()) {
    T node = findFirstNodeInstance(child, clazz);
    if (node != null) {
      return node;
    }
  }
  return null;
}

代码示例来源:origin: org.graalvm.truffle/truffle-api

/** @since 0.8 or earlier */
public static <T> T findFirstNodeInstance(Node root, Class<T> clazz) {
  if (clazz.isInstance(root)) {
    return clazz.cast(root);
  }
  for (Node child : root.getChildren()) {
    T node = findFirstNodeInstance(child, clazz);
    if (node != null) {
      return node;
    }
  }
  return null;
}

代码示例来源:origin: com.oracle/truffle

private void adoptUnadoptedHelper() {
  Iterable<Node> children = this.getChildren();
  for (Node child : children) {
    if (child != null && child.getParent() == null) {
      this.adoptUnadoptedHelper(child);
    }
  }
}

代码示例来源:origin: com.oracle/truffle

private void adoptHelper() {
  Iterable<Node> children = this.getChildren();
  for (Node child : children) {
    if (child != null && child.getParent() != this) {
      this.adoptHelper(child);
    }
  }
}

代码示例来源:origin: com.oracle/truffle

private static void printCompactTree(PrintWriter p, Node parent, Node node, int level) {
  if (node == null) {
    return;
  }
  for (int i = 0; i < level; i++) {
    p.print("  ");
  }
  if (parent == null) {
    p.println(nodeName(node));
  } else {
    p.print(getNodeFieldName(parent, node, "unknownField"));
    p.print(" = ");
    p.println(nodeName(node));
  }
  for (Node child : node.getChildren()) {
    printCompactTree(p, node, child, level + 1);
  }
  p.flush();
}

代码示例来源:origin: com.oracle.truffle/truffle-api

private static void printCompactTree(PrintWriter p, Node parent, Node node, int level) {
  if (node == null) {
    return;
  }
  for (int i = 0; i < level; i++) {
    p.print("  ");
  }
  if (parent == null) {
    p.println(nodeName(node));
  } else {
    p.print(getNodeFieldName(parent, node, "unknownField"));
    p.print(" = ");
    p.println(nodeName(node));
  }
  for (Node child : node.getChildren()) {
    printCompactTree(p, node, child, level + 1);
  }
  p.flush();
}

代码示例来源:origin: org.graalvm.truffle/truffle-api

private static void printCompactTree(PrintWriter p, Node parent, Node node, int level) {
  if (node == null) {
    return;
  }
  for (int i = 0; i < level; i++) {
    p.print("  ");
  }
  if (parent == null) {
    p.println(nodeName(node));
  } else {
    p.print(getNodeFieldName(parent, node, "unknownField"));
    p.print(" = ");
    p.println(nodeName(node));
  }
  for (Node child : node.getChildren()) {
    printCompactTree(p, node, child, level + 1);
  }
  p.flush();
}

代码示例来源:origin: com.oracle/truffle

private static void printSourceAttributionTree(PrintWriter p, Node parent, Node node, int level) {
  if (node == null) {
    return;
  }
  if (parent == null) {
    // Add some preliminary information before starting with the root node
    final SourceSection sourceSection = node.getSourceSection();
    if (sourceSection != null) {
      final String txt = sourceSection.getSource().getCode();
      p.println("Full source len=(" + txt.length() + ")  ___" + txt + "___");
      p.println("AST source attribution:");
    }
  }
  final StringBuilder sb = new StringBuilder();
  for (int i = 0; i < level; i++) {
    sb.append("| ");
  }
  if (parent != null) {
    sb.append(getNodeFieldName(parent, node, ""));
  }
  sb.append("  (" + node.getClass().getSimpleName() + ")  ");
  sb.append(printSyntaxTags(node));
  sb.append(displaySourceAttribution(node));
  p.println(sb.toString());
  for (Node child : node.getChildren()) {
    printSourceAttributionTree(p, node, child, level + 1);
  }
  p.flush();
}

代码示例来源:origin: com.oracle.truffle/truffle-api

private static void printSourceAttributionTree(PrintWriter p, Node parent, Node node, int level) {
  if (node == null) {
    return;
  }
  if (parent == null) {
    // Add some preliminary information before starting with the root node
    final SourceSection sourceSection = node.getSourceSection();
    if (sourceSection != null) {
      final String txt = sourceSection.getSource().getCharacters().toString();
      p.println("Full source len=(" + txt.length() + ")  ___" + txt + "___");
      p.println("AST source attribution:");
    }
  }
  final StringBuilder sb = new StringBuilder();
  for (int i = 0; i < level; i++) {
    sb.append("| ");
  }
  if (parent != null) {
    sb.append(getNodeFieldName(parent, node, ""));
  }
  sb.append("  (" + node.getClass().getSimpleName() + ")  ");
  sb.append(printSyntaxTags(node));
  sb.append(displaySourceAttribution(node));
  p.println(sb.toString());
  for (Node child : node.getChildren()) {
    printSourceAttributionTree(p, node, child, level + 1);
  }
  p.flush();
}

代码示例来源:origin: org.graalvm.truffle/truffle-api

private static void printSourceAttributionTree(PrintWriter p, Node parent, Node node, int level) {
  if (node == null) {
    return;
  }
  if (parent == null) {
    // Add some preliminary information before starting with the root node
    final SourceSection sourceSection = node.getSourceSection();
    if (sourceSection != null) {
      final String txt = sourceSection.getSource().getCharacters().toString();
      p.println("Full source len=(" + txt.length() + ")  ___" + txt + "___");
      p.println("AST source attribution:");
    }
  }
  final StringBuilder sb = new StringBuilder();
  for (int i = 0; i < level; i++) {
    sb.append("| ");
  }
  if (parent != null) {
    sb.append(getNodeFieldName(parent, node, ""));
  }
  sb.append("  (" + node.getClass().getSimpleName() + ")  ");
  sb.append(printSyntaxTags(node));
  sb.append(displaySourceAttribution(node));
  p.println(sb.toString());
  for (Node child : node.getChildren()) {
    printSourceAttributionTree(p, node, child, level + 1);
  }
  p.flush();
}

代码示例来源:origin: com.oracle/truffle

public static boolean verify(Node root) {
  Iterable<Node> children = root.getChildren();
  for (Node child : children) {
    if (child != null) {
      if (child.getParent() != root) {
        throw new AssertionError(toStringWithClass(child) + ": actual parent=" + toStringWithClass(child.getParent()) + " expected parent=" + toStringWithClass(root));
      }
      verify(child);
    }
  }
  return true;
}

代码示例来源:origin: com.oracle.truffle/truffle-api

/** @since 0.8 or earlier */
public static boolean verify(Node root) {
  Iterable<Node> children = root.getChildren();
  for (Node child : children) {
    if (child != null) {
      if (child.getParent() != root) {
        throw new AssertionError(toStringWithClass(child) + ": actual parent=" + toStringWithClass(child.getParent()) + " expected parent=" + toStringWithClass(root));
      }
      verify(child);
    }
  }
  return true;
}

代码示例来源:origin: org.graalvm.truffle/truffle-api

/** @since 0.8 or earlier */
public static boolean verify(Node root) {
  Iterable<Node> children = root.getChildren();
  for (Node child : children) {
    if (child != null) {
      if (child.getParent() != root) {
        throw new AssertionError(toStringWithClass(child) + ": actual parent=" + toStringWithClass(child.getParent()) + " expected parent=" + toStringWithClass(root));
      }
      verify(child);
    }
  }
  return true;
}

相关文章