本文整理了Java中com.oracle.truffle.api.nodes.Node.getNodeClass()
方法的一些代码示例,展示了Node.getNodeClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getNodeClass()
方法的具体详情如下:
包路径:com.oracle.truffle.api.nodes.Node
类名称:Node
方法名:getNodeClass
暂无
代码示例来源:origin: org.graalvm.truffle/truffle-api
/** @since 0.8 or earlier */
public static NodeClass get(Node node) {
return node.getNodeClass();
}
代码示例来源:origin: com.oracle.truffle/truffle-api
/** @since 0.8 or earlier */
public static NodeClass get(Node node) {
return node.getNodeClass();
}
代码示例来源:origin: com.oracle/truffle
public static NodeClass get(Node clazz) {
return clazz.getNodeClass();
}
代码示例来源:origin: com.oracle.truffle/truffle-api
public Iterator<Node> iterator() {
return getNodeClass().makeIterator(Node.this);
}
};
代码示例来源:origin: org.graalvm.truffle/truffle-api
public Iterator<Node> iterator() {
return getNodeClass().makeIterator(Node.this);
}
};
代码示例来源:origin: org.graalvm.truffle/truffle-api
static Iterator<Node> makeIterator(Node node) {
return node.getNodeClass().makeIterator(node);
}
代码示例来源:origin: com.oracle/truffle
static Iterator<Node> makeIterator(Node node) {
return node.getNodeClass().makeIterator(node);
}
代码示例来源:origin: com.oracle.truffle/truffle-api
static Iterator<Node> makeIterator(Node node) {
return node.getNodeClass().makeIterator(node);
}
代码示例来源:origin: com.oracle/truffle
public static List<Node> findNodeChildren(Node node) {
List<Node> nodes = new ArrayList<>();
NodeClass nodeClass = node.getNodeClass();
for (NodeFieldAccessor nodeField : nodeClass.getChildFields()) {
Object child = nodeField.getObject(node);
if (child != null) {
nodes.add((Node) child);
}
}
for (NodeFieldAccessor nodeField : nodeClass.getChildrenFields()) {
Object[] children = (Object[]) nodeField.getObject(node);
if (children != null) {
for (Object child : children) {
if (child != null) {
nodes.add((Node) child);
}
}
}
}
return nodes;
}
代码示例来源:origin: com.oracle/truffle
private static LinkedHashMap<String, Node> findNamedNodeChildren(Node node) {
LinkedHashMap<String, Node> nodes = new LinkedHashMap<>();
NodeClass nodeClass = node.getNodeClass();
for (NodeFieldAccessor field : nodeClass.getFields()) {
NodeFieldKind kind = field.getKind();
if (kind == NodeFieldKind.CHILD || kind == NodeFieldKind.CHILDREN) {
Object value = field.loadValue(node);
if (value != null) {
if (kind == NodeFieldKind.CHILD) {
nodes.put(field.getName(), (Node) value);
} else if (kind == NodeFieldKind.CHILDREN) {
Object[] children = (Object[]) value;
for (int i = 0; i < children.length; i++) {
if (children[i] != null) {
nodes.put(field.getName() + "[" + i + "]", (Node) children[i]);
}
}
}
}
}
}
return nodes;
}
代码示例来源:origin: com.oracle/truffle
/**
* Finds the field in a parent node, if any, that holds a specified child node.
*
* @return the field (possibly an array) holding the child, {@code null} if not found.
*/
public static NodeFieldAccessor findChildField(Node parent, Node child) {
assert child != null;
NodeClass parentNodeClass = parent.getNodeClass();
for (NodeFieldAccessor field : parentNodeClass.getChildFields()) {
if (field.getObject(parent) == child) {
return field;
}
}
for (NodeFieldAccessor field : parentNodeClass.getChildrenFields()) {
Object arrayObject = field.getObject(parent);
if (arrayObject != null) {
Object[] array = (Object[]) arrayObject;
for (int i = 0; i < array.length; i++) {
if (array[i] == child) {
return field;
}
}
}
}
return null;
}
代码示例来源:origin: com.oracle/truffle
private void readNodeProperties(Node node) {
NodeFieldAccessor[] fields = node.getNodeClass().getFields();
for (NodeFieldAccessor field : fields) {
if (field.getKind() == NodeFieldKind.DATA) {
String key = field.getName();
if (getPropertyElement(node, key) == null) {
Object value = field.loadValue(node);
setNodeProperty(node, key, value);
}
}
}
}
代码示例来源:origin: com.oracle/truffle
static boolean forEachChildRecursive(Node parent, NodeVisitor visitor) {
NodeClass parentNodeClass = parent.getNodeClass();
for (NodeFieldAccessor field : parentNodeClass.getChildFields()) {
if (!visitChild((Node) field.getObject(parent), visitor)) {
return false;
}
}
for (NodeFieldAccessor field : parentNodeClass.getChildrenFields()) {
Object arrayObject = field.getObject(parent);
if (arrayObject == null) {
continue;
}
Object[] array = (Object[]) arrayObject;
for (int i = 0; i < array.length; i++) {
if (!visitChild((Node) array[i], visitor)) {
return false;
}
}
}
return true;
}
代码示例来源:origin: com.oracle/truffle
private static String getNodeFieldName(Node parent, Node node, String defaultName) {
NodeFieldAccessor[] fields = parent.getNodeClass().getFields();
for (NodeFieldAccessor field : fields) {
Object value = field.loadValue(parent);
if (field.getKind() == NodeFieldKind.CHILD && value == node) {
return field.getName();
} else if (field.getKind() == NodeFieldKind.CHILDREN) {
int index = 0;
for (Object arrayNode : (Object[]) value) {
if (arrayNode == node) {
return field.getName() + "[" + index + "]";
}
index++;
}
}
}
return defaultName;
}
代码示例来源:origin: com.oracle/truffle
public static boolean replaceChild(Node parent, Node oldChild, Node newChild) {
NodeClass nodeClass = parent.getNodeClass();
for (NodeFieldAccessor nodeField : nodeClass.getChildFields()) {
if (nodeField.getObject(parent) == oldChild) {
assert assertAssignable(nodeField, newChild);
nodeField.putObject(parent, newChild);
return true;
}
}
for (NodeFieldAccessor nodeField : nodeClass.getChildrenFields()) {
Object arrayObject = nodeField.getObject(parent);
if (arrayObject != null) {
Object[] array = (Object[]) arrayObject;
for (int i = 0; i < array.length; i++) {
if (array[i] == oldChild) {
assert assertAssignable(nodeField, newChild);
array[i] = newChild;
return true;
}
}
}
}
return false;
}
代码示例来源:origin: com.oracle.truffle/truffle-api
private static String getNodeFieldName(Node parent, Node node, String defaultName) {
NodeClass nodeClass = parent.getNodeClass();
for (Object field : nodeClass.getNodeFields()) {
if (nodeClass.isChildField(field)) {
if (nodeClass.getFieldObject(field, parent) == node) {
return nodeClass.getFieldName(field);
}
} else if (nodeClass.isChildrenField(field)) {
int index = 0;
for (Object arrayNode : (Object[]) nodeClass.getFieldObject(field, parent)) {
if (arrayNode == node) {
return nodeClass.getFieldName(field) + "[" + index + "]";
}
index++;
}
} else if (nodeClass.nodeFieldsOrderedByKind()) {
break;
}
}
return defaultName;
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
static boolean forEachChildRecursive(Node parent, NodeVisitor visitor) {
NodeClass nodeClass = parent.getNodeClass();
for (Object field : nodeClass.getNodeFields()) {
if (nodeClass.isChildField(field)) {
if (!visitChild((Node) nodeClass.getFieldObject(field, parent), visitor)) {
return false;
}
} else if (nodeClass.isChildrenField(field)) {
Object arrayObject = nodeClass.getFieldObject(field, parent);
if (arrayObject == null) {
continue;
}
Object[] array = (Object[]) arrayObject;
for (int i = 0; i < array.length; i++) {
if (!visitChild((Node) array[i], visitor)) {
return false;
}
}
} else if (nodeClass.nodeFieldsOrderedByKind()) {
break;
}
}
return true;
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
private static String getNodeFieldName(Node parent, Node node, String defaultName) {
NodeClass nodeClass = parent.getNodeClass();
for (Object field : nodeClass.getNodeFields()) {
if (nodeClass.isChildField(field)) {
if (nodeClass.getFieldObject(field, parent) == node) {
return nodeClass.getFieldName(field);
}
} else if (nodeClass.isChildrenField(field)) {
int index = 0;
for (Object arrayNode : (Object[]) nodeClass.getFieldObject(field, parent)) {
if (arrayNode == node) {
return nodeClass.getFieldName(field) + "[" + index + "]";
}
index++;
}
} else if (nodeClass.nodeFieldsOrderedByKind()) {
break;
}
}
return defaultName;
}
代码示例来源:origin: com.oracle.truffle/truffle-api
static int adoptChildrenAndCountHelper(Node currentNode) {
int count = 0;
NodeClass clazz = currentNode.getNodeClass();
for (Object field : clazz.getNodeFields()) {
if (clazz.isChildField(field)) {
Object child = clazz.getFieldObject(field, currentNode);
if (child != null) {
Node node = (Node) child;
count += currentNode.adoptAndCountHelper(node);
}
} else if (clazz.isChildrenField(field)) {
Object arrayObject = clazz.getFieldObject(field, currentNode);
if (arrayObject == null) {
continue;
}
Object[] array = (Object[]) arrayObject;
for (int i = 0; i < array.length; i++) {
Object child = array[i];
if (child != null) {
Node node = (Node) child;
count += currentNode.adoptAndCountHelper(node);
}
}
} else if (clazz.nodeFieldsOrderedByKind()) {
break;
}
}
return count;
}
代码示例来源:origin: com.oracle.truffle/truffle-api
static boolean forEachChildRecursive(Node parent, NodeVisitor visitor) {
NodeClass nodeClass = parent.getNodeClass();
for (Object field : nodeClass.getNodeFields()) {
if (nodeClass.isChildField(field)) {
if (!visitChild((Node) nodeClass.getFieldObject(field, parent), visitor)) {
return false;
}
} else if (nodeClass.isChildrenField(field)) {
Object arrayObject = nodeClass.getFieldObject(field, parent);
if (arrayObject == null) {
continue;
}
Object[] array = (Object[]) arrayObject;
for (int i = 0; i < array.length; i++) {
if (!visitChild((Node) array[i], visitor)) {
return false;
}
}
} else if (nodeClass.nodeFieldsOrderedByKind()) {
break;
}
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!