Mercurial > hg > graal-compiler
comparison 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 |
comparison
equal
deleted
inserted
replaced
18761:a665483c3881 | 18762:0ef23ff7d5a1 |
---|---|
124 argumentNodes[i] = new SLReadArgumentNode(null, i); | 124 argumentNodes[i] = new SLReadArgumentNode(null, i); |
125 } | 125 } |
126 /* Instantiate the builtin node. This node performs the actual functionality. */ | 126 /* Instantiate the builtin node. This node performs the actual functionality. */ |
127 SLBuiltinNode builtinBodyNode = factory.createNode(argumentNodes, this); | 127 SLBuiltinNode builtinBodyNode = factory.createNode(argumentNodes, this); |
128 /* The name of the builtin function is specified via an annotation on the node class. */ | 128 /* The name of the builtin function is specified via an annotation on the node class. */ |
129 String name = builtinBodyNode.getClass().getAnnotation(NodeInfo.class).shortName(); | 129 String name = lookupNodeInfo(builtinBodyNode.getClass()).shortName(); |
130 /* Wrap the builtin in a RootNode. Truffle requires all AST to start with a RootNode. */ | 130 /* Wrap the builtin in a RootNode. Truffle requires all AST to start with a RootNode. */ |
131 SLRootNode rootNode = new SLRootNode(this, new FrameDescriptor(), builtinBodyNode, name); | 131 SLRootNode rootNode = new SLRootNode(this, new FrameDescriptor(), builtinBodyNode, name); |
132 | 132 |
133 /* Register the builtin function in our function registry. */ | 133 /* Register the builtin function in our function registry. */ |
134 getFunctionRegistry().register(name, rootNode); | 134 getFunctionRegistry().register(name, rootNode); |
135 } | |
136 | |
137 public static NodeInfo lookupNodeInfo(Class<?> clazz) { | |
138 if (clazz == null) { | |
139 return null; | |
140 } | |
141 NodeInfo info = clazz.getAnnotation(NodeInfo.class); | |
142 if (info != null) { | |
143 return info; | |
144 } else { | |
145 return lookupNodeInfo(clazz.getSuperclass()); | |
146 } | |
135 } | 147 } |
136 | 148 |
137 /** | 149 /** |
138 * This function will parse the given source code, parse the code using the {@link Parser}, and | 150 * This function will parse the given source code, parse the code using the {@link Parser}, and |
139 * then execute the function named main. To use this method with instrumentation, | 151 * then execute the function named main. To use this method with instrumentation, |