comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java @ 19348:ef292a5bb79d

Truffle-DSL: fix findbugs comparison warnings.
author Christian Humer <christian.humer@gmail.com>
date Fri, 13 Feb 2015 11:37:13 +0100
parents 37bbcabf7744
children e9e99d8dca54
comparison
equal deleted inserted replaced
19347:91dea7a100d2 19348:ef292a5bb79d
211 for (ExecutableTypeData execType : implementedExecutables) { 211 for (ExecutableTypeData execType : implementedExecutables) {
212 clazz.add(createExecutableTypeOverride(implementedExecutables, execType)); 212 clazz.add(createExecutableTypeOverride(implementedExecutables, execType));
213 } 213 }
214 clazz.add(createGetCostMethod()); 214 clazz.add(createGetCostMethod());
215 215
216 avoidFindbugsProblems(clazz);
217
216 if (singleSpecializable) { 218 if (singleSpecializable) {
217 if (node.needsRewrites(context)) { 219 if (node.needsRewrites(context)) {
218 clazz.add(createUnsupportedMethod()); 220 clazz.add(createUnsupportedMethod());
219 } 221 }
220 } else { 222 } else {
232 builder.end(); 234 builder.end();
233 } 235 }
234 } 236 }
235 237
236 return clazz; 238 return clazz;
239 }
240
241 private void avoidFindbugsProblems(CodeTypeElement clazz) {
242 TypeElement type = context.getEnvironment().getElementUtils().getTypeElement("edu.umd.cs.findbugs.annotations.SuppressFBWarnings");
243 if (type == null) {
244 return;
245 }
246 boolean foundComparison = false;
247 outer: for (SpecializationData specialization : node.getSpecializations()) {
248 for (GuardExpression guard : specialization.getGuards()) {
249 if (guard.getExpression().containsComparisons()) {
250 foundComparison = true;
251 break outer;
252 }
253 }
254 }
255
256 if (foundComparison) {
257 CodeAnnotationMirror annotation = new CodeAnnotationMirror((DeclaredType) type.asType());
258 annotation.setElementValue(annotation.findExecutableElement("value"), new CodeAnnotationValue("SA_LOCAL_SELF_COMPARISON"));
259 clazz.addAnnotationMirror(annotation);
260 }
237 } 261 }
238 262
239 private Element createUnsupportedMethod() { 263 private Element createUnsupportedMethod() {
240 LocalContext locals = LocalContext.load(this); 264 LocalContext locals = LocalContext.load(this);
241 CodeExecutableElement method = locals.createMethod(modifiers(PROTECTED), getType(UnsupportedSpecializationException.class), "unsupported"); 265 CodeExecutableElement method = locals.createMethod(modifiers(PROTECTED), getType(UnsupportedSpecializationException.class), "unsupported");