Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java @ 18762:0ef23ff7d5a1
SL: make lookup of NodeInfo annotation more rebust.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 29 Dec 2014 23:38:59 +0100 |
parents | e3c95cbbb50c |
children | 286aef83a9a7 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java Mon Dec 29 23:38:54 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java Mon Dec 29 23:38:59 2014 +0100 @@ -126,7 +126,7 @@ /* Instantiate the builtin node. This node performs the actual functionality. */ SLBuiltinNode builtinBodyNode = factory.createNode(argumentNodes, this); /* The name of the builtin function is specified via an annotation on the node class. */ - String name = builtinBodyNode.getClass().getAnnotation(NodeInfo.class).shortName(); + String name = lookupNodeInfo(builtinBodyNode.getClass()).shortName(); /* Wrap the builtin in a RootNode. Truffle requires all AST to start with a RootNode. */ SLRootNode rootNode = new SLRootNode(this, new FrameDescriptor(), builtinBodyNode, name); @@ -134,6 +134,18 @@ getFunctionRegistry().register(name, rootNode); } + public static NodeInfo lookupNodeInfo(Class<?> clazz) { + if (clazz == null) { + return null; + } + NodeInfo info = clazz.getAnnotation(NodeInfo.class); + if (info != null) { + return info; + } else { + return lookupNodeInfo(clazz.getSuperclass()); + } + } + /** * This function will parse the given source code, parse the code using the {@link Parser}, and * then execute the function named main. To use this method with instrumentation,