# HG changeset patch # User Christian Humer # Date 1419892739 -3600 # Node ID 0ef23ff7d5a1a6a56b99e5a0abd5b2345aeb2af0 # Parent a665483c38819e43c71874f21f0d1f9cfe3d7899 SL: make lookup of NodeInfo annotation more rebust. diff -r a665483c3881 -r 0ef23ff7d5a1 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java Mon Dec 29 23:38:54 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java Mon Dec 29 23:38:59 2014 +0100 @@ -244,8 +244,11 @@ } } result.append(": operation"); - if (ex.getNode() != null && ex.getNode().getClass().getAnnotation(NodeInfo.class) != null) { - result.append(" \"").append(ex.getNode().getClass().getAnnotation(NodeInfo.class).shortName()).append("\""); + if (ex.getNode() != null) { + NodeInfo nodeInfo = SLContext.lookupNodeInfo(ex.getNode().getClass()); + if (nodeInfo != null) { + result.append(" \"").append(nodeInfo.shortName()).append("\""); + } } result.append(" not defined for"); diff -r a665483c3881 -r 0ef23ff7d5a1 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java --- 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,