Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 15775:4293efaaab76
Add description and language to the NodeInfo annotation
author | Christian Wirth <christian.wirth@oracle.com> |
---|---|
date | Mon, 19 May 2014 18:52:39 +0200 |
parents | dd624471bd30 |
children | 915ebb306fcc |
line wrap: on
line diff
--- 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 ""; + } }