Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/MessageContainer.java @ 16755:bd28da642eea
Truffle-DSL: Several new features implemented:
Implementation of a new code generation layout which shares code between generated nodes.
Declaration order of specializations is now used as specialization order.
Specializations do no longer perform fallthrough on respecialization, they now always respecialize from the first specialization.
Implemented support for contains relations between specializations.
Improved reachability error messages.
Preliminary support for @Implies.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 11 Aug 2014 15:53:05 +0200 |
parents | 25ecb47a6d0e |
children |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/MessageContainer.java Mon Aug 11 15:53:05 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/MessageContainer.java Mon Aug 11 15:53:05 2014 +0200 @@ -29,7 +29,7 @@ import com.oracle.truffle.dsl.processor.*; -public abstract class MessageContainer { +public abstract class MessageContainer implements Iterable<MessageContainer> { private final List<Message> messages = new ArrayList<>(); @@ -37,6 +37,10 @@ getMessages().add(new Message(null, this, String.format(text, params), Kind.WARNING)); } + public final void addWarning(AnnotationValue value, String text, Object... params) { + getMessages().add(new Message(value, this, String.format(text, params), Kind.WARNING)); + } + public final void addError(String text, Object... params) { addError(null, text, params); } @@ -51,11 +55,19 @@ public abstract Element getMessageElement(); - public final void emitMessages(ProcessorContext context, TypeElement baseElement, Log log) { - emitMessagesImpl(context, baseElement, log, new HashSet<MessageContainer>(), null); + public MessageContainer getBaseContainer() { + return null; } - private void emitMessagesImpl(ProcessorContext context, TypeElement baseElement, Log log, Set<MessageContainer> visitedSinks, List<Message> verifiedMessages) { + public Iterator<MessageContainer> iterator() { + return findChildContainers().iterator(); + } + + public final void emitMessages(ProcessorContext context, Log log) { + emitMessagesImpl(context, log, new HashSet<MessageContainer>(), null); + } + + private void emitMessagesImpl(ProcessorContext context, Log log, Set<MessageContainer> visitedSinks, List<Message> verifiedMessages) { List<Message> childMessages; if (verifiedMessages == null) { childMessages = collectMessagesWithElementChildren(new HashSet<MessageContainer>(), getMessageElement()); @@ -65,7 +77,7 @@ verifyExpectedMessages(context, log, childMessages); for (int i = getMessages().size() - 1; i >= 0; i--) { - emitDefault(context, baseElement, log, getMessages().get(i)); + emitDefault(context, log, getMessages().get(i)); } for (MessageContainer sink : findChildContainers()) { @@ -75,9 +87,9 @@ visitedSinks.add(sink); if (sink.getMessageElement() == this.getMessageElement()) { - sink.emitMessagesImpl(context, baseElement, log, visitedSinks, childMessages); + sink.emitMessagesImpl(context, log, visitedSinks, childMessages); } else { - sink.emitMessagesImpl(context, baseElement, log, visitedSinks, null); + sink.emitMessagesImpl(context, log, visitedSinks, null); } } } @@ -115,7 +127,7 @@ } } - private void emitDefault(ProcessorContext context, TypeElement baseType, Log log, Message message) { + private void emitDefault(ProcessorContext context, Log log, Message message) { Kind kind = message.getKind(); Element messageElement = getMessageElement(); @@ -127,17 +139,6 @@ String text = message.getText(); - TypeElement rootEnclosing = Utils.findRootEnclosingType(getMessageElement()); - TypeElement baseEnclosing = Utils.findRootEnclosingType(baseType); - if (rootEnclosing == null || !Utils.typeEquals(baseEnclosing.asType(), rootEnclosing.asType())) { - // redirect message - MessageContainer original = message.getOriginalContainer(); - messageElement = baseType; - messageAnnotation = null; - messageValue = null; - text = wrapText(original.getMessageElement(), original.getMessageAnnotation(), message.getText()); - } - TypeElement expectError = context.getTruffleTypes().getExpectError(); if (expectError != null) { AnnotationMirror mirror = Utils.findAnnotationMirror(messageElement.getAnnotationMirrors(), expectError); @@ -165,23 +166,6 @@ log.message(kind, messageElement, messageAnnotation, messageValue, text); } - private static String wrapText(Element element, AnnotationMirror mirror, String text) { - StringBuilder b = new StringBuilder(); - if (element != null) { - b.append("Element " + element.toString()); - } - if (mirror != null) { - b.append(" at annotation @" + Utils.getSimpleName(mirror.getAnnotationType())); - } - - if (b.length() > 0) { - b.append(" is erroneous: ").append(text); - return b.toString(); - } else { - return text; - } - } - public AnnotationMirror getMessageAnnotation() { return null; }