Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java @ 18332:65a160d9d259
Truffle: add NodeInterface and require that all child fields be of this type
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Mon, 10 Nov 2014 19:29:08 +0100 |
parents | c88ab4f1f04a |
children | e3c95cbbb50c |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Mon Nov 10 19:08:52 2014 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Mon Nov 10 19:29:08 2014 +0100 @@ -224,9 +224,13 @@ this.clazz = clazz; } + private static boolean isNodeType(Class<?> clazz) { + return Node.class.isAssignableFrom(clazz) || (clazz.isInterface() && NodeInterface.class.isAssignableFrom(clazz)); + } + private static void checkChildField(Field field) { - if (!(Node.class.isAssignableFrom(field.getType()) || field.getType().isInterface())) { - throw new AssertionError("@Child field type must be a subclass of Node or an interface (" + field + ")"); + if (!isNodeType(field.getType())) { + throw new AssertionError("@Child field type must be a subclass of Node or an interface extending NodeInterface (" + field + ")"); } if (Modifier.isFinal(field.getModifiers())) { throw new AssertionError("@Child field must not be final (" + field + ")"); @@ -234,8 +238,8 @@ } private static void checkChildrenField(Field field) { - if (!(field.getType().isArray() && (Node.class.isAssignableFrom(field.getType().getComponentType()) || field.getType().getComponentType().isInterface()))) { - throw new AssertionError("@Children field type must be an array of a subclass of Node or an interface (" + field + ")"); + if (!(field.getType().isArray() && isNodeType(field.getType().getComponentType()))) { + throw new AssertionError("@Children field type must be an array of a subclass of Node or an interface extending NodeInterface (" + field + ")"); } if (!Modifier.isFinal(field.getModifiers())) { throw new AssertionError("@Children field must be final (" + field + ")");