# HG changeset patch # User Christian Wirth # Date 1400518359 -7200 # Node ID 4293efaaab76517b7fec9fbd41032f383f39d4f8 # Parent 402a74c6bc14118b6ae2e78527e47d726cad9950 Add description and language to the NodeInfo annotation diff -r 402a74c6bc14 -r 4293efaaab76 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Mon May 19 17:21:35 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Mon May 19 18:52:39 2014 +0200 @@ -506,4 +506,31 @@ throw new RuntimeException(e); } } + + /** + * Returns a user-readable description of the purpose of the Node, or "" if no description is + * available. + */ + public String getDescription() { + NodeInfo info = getClass().getAnnotation(NodeInfo.class); + if (info != null) { + return info.description(); + } + return ""; + } + + /** + * Returns a string representing the language this node has been implemented for. If the + * language is unknown, returns "". + */ + public String getLanguage() { + NodeInfo info = getClass().getAnnotation(NodeInfo.class); + if (info != null && info.language() != null && info.language().length() > 0) { + return info.language(); + } + if (parent != null) { + return parent.getLanguage(); + } + return ""; + } } diff -r 402a74c6bc14 -r 4293efaaab76 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeInfo.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeInfo.java Mon May 19 17:21:35 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeInfo.java Mon May 19 18:52:39 2014 +0200 @@ -35,7 +35,7 @@ /** * Short name representing the node that can be used for debugging. - * + * * @return the short name */ String shortName() default ""; @@ -43,10 +43,26 @@ /** * Provides a rough estimate for the cost of the annotated {@link Node}. This estimate can be * used by runtime systems or guest languages to implement heuristics based on Truffle ASTs. - * + * * @see Node#getCost() * @see NodeCost */ NodeCost cost() default NodeCost.MONOMORPHIC; + /** + * A human readable explanation of the purpose of the annotated {@link Node}. Can be used e.g. + * for debugging or visualization purposes. + * + * @return the description + */ + String description() default ""; + + /** + * A description, providing a user-readable explanation of the source language of the annotated + * {@link Node}. Can be used e.g. for debugging or visualization purposes. Typically this + * information is set only in an abstract base node for the language implementation. + * + * @return the description + */ + String language() default ""; } diff -r 402a74c6bc14 -r 4293efaaab76 graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeElement.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeElement.java Mon May 19 17:21:35 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeElement.java Mon May 19 18:52:39 2014 +0200 @@ -112,7 +112,7 @@ /** * Support JDK8 langtools. - * + * * @param annotationType */ public A[] getAnnotationsByType(Class annotationType) { @@ -121,7 +121,7 @@ /** * Support for some JDK8 builds. (remove after jdk8 is released) - * + * * @param annotationType */ public A[] getAnnotations(Class annotationType) { @@ -130,7 +130,7 @@ /** * Support for some JDK8 builds. (remove after jdk8 is released) - * + * * @param annotationType */ public A getAnnotation(Class annotationType) {