Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java @ 18761:a665483c3881
Truffle-DSL: new node layout implementation.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 29 Dec 2014 23:38:54 +0100 |
parents | 13cf9b6b325c |
children | 62c43fcf5be2 |
rev | line source |
---|---|
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
23 package com.oracle.truffle.dsl.processor.model; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import java.util.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import javax.lang.model.element.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import javax.tools.Diagnostic.Kind; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.dsl.processor.*; |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
31 import com.oracle.truffle.dsl.processor.java.*; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
33 public abstract class MessageContainer implements Iterable<MessageContainer> { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 private final List<Message> messages = new ArrayList<>(); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 public final void addWarning(String text, Object... params) { |
16832
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
38 getMessages().add(new Message(null, null, this, String.format(text, params), Kind.WARNING)); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
41 public final void addWarning(AnnotationValue value, String text, Object... params) { |
16832
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
42 getMessages().add(new Message(null, value, this, String.format(text, params), Kind.WARNING)); |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
43 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
44 |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 public final void addError(String text, Object... params) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 addError(null, text, params); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 public final void addError(AnnotationValue value, String text, Object... params) { |
16832
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
50 getMessages().add(new Message(null, value, this, String.format(text, params), Kind.ERROR)); |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
51 } |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
52 |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
53 public final void addError(AnnotationMirror mirror, AnnotationValue value, String text, Object... params) { |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
54 getMessages().add(new Message(mirror, value, this, String.format(text, params), Kind.ERROR)); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 protected List<MessageContainer> findChildContainers() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 return Collections.emptyList(); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 public abstract Element getMessageElement(); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
63 public MessageContainer getBaseContainer() { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
64 return null; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
67 public Iterator<MessageContainer> iterator() { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
68 return findChildContainers().iterator(); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
69 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
70 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
71 public final void emitMessages(ProcessorContext context, Log log) { |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
72 emitMessagesImpl(context, log, new HashSet<MessageContainer>(), null); |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
73 } |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
74 |
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
75 private void emitMessagesImpl(ProcessorContext context, Log log, Set<MessageContainer> visitedSinks, List<Message> verifiedMessages) { |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
76 List<Message> childMessages; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
77 if (verifiedMessages == null) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
78 childMessages = collectMessagesWithElementChildren(new HashSet<MessageContainer>(), getMessageElement()); |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
79 } else { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
80 childMessages = verifiedMessages; |
11466
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
81 } |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
82 verifyExpectedMessages(context, log, childMessages); |
11466
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
83 |
13527
25ecb47a6d0e
Truffle-DSL: Added support for references to child arrays in @ShortCircuit;
Christian Humer <christian.humer@gmail.com>
parents:
11542
diff
changeset
|
84 for (int i = getMessages().size() - 1; i >= 0; i--) { |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
85 emitDefault(context, log, getMessages().get(i)); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 for (MessageContainer sink : findChildContainers()) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 if (visitedSinks.contains(sink)) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 continue; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 visitedSinks.add(sink); |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
94 if (sink.getMessageElement() == this.getMessageElement()) { |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
95 sink.emitMessagesImpl(context, log, visitedSinks, childMessages); |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
96 } else { |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
97 sink.emitMessagesImpl(context, log, visitedSinks, null); |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
98 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
99 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
100 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
101 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
102 private List<Message> collectMessagesWithElementChildren(Set<MessageContainer> visitedSinks, Element e) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
103 if (visitedSinks.contains(this)) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
104 return Collections.emptyList(); |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
105 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
106 visitedSinks.add(this); |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
107 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
108 List<Message> foundMessages = new ArrayList<>(); |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
109 if (ElementUtils.typeEquals(getMessageElement().asType(), e.asType())) { |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
110 foundMessages.addAll(getMessages()); |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
111 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
112 for (MessageContainer sink : findChildContainers()) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
113 foundMessages.addAll(sink.collectMessagesWithElementChildren(visitedSinks, e)); |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
114 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
115 return foundMessages; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
116 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
117 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
118 private void verifyExpectedMessages(ProcessorContext context, Log log, List<Message> msgs) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
119 TypeElement expectError = context.getTruffleTypes().getExpectError(); |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
120 if (expectError != null) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
121 Element element = getMessageElement(); |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
122 AnnotationMirror mirror = ElementUtils.findAnnotationMirror(element.getAnnotationMirrors(), expectError); |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
123 if (mirror != null) { |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
124 List<String> values = ElementUtils.getAnnotationValueList(String.class, mirror, "value"); |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
125 if (values == null) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
126 values = Collections.emptyList(); |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
127 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
128 if (values.size() != msgs.size()) { |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
129 log.message(Kind.ERROR, element, mirror, ElementUtils.getAnnotationValue(mirror, "value"), String.format("Error count expected %s but was %s.", values.size(), msgs.size())); |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
130 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
131 } |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
132 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
133 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
134 |
16755
bd28da642eea
Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents:
13527
diff
changeset
|
135 private void emitDefault(ProcessorContext context, Log log, Message message) { |
11466
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
136 Kind kind = message.getKind(); |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
137 |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
138 Element messageElement = getMessageElement(); |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
139 AnnotationMirror messageAnnotation = getMessageAnnotation(); |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
140 AnnotationValue messageValue = getMessageAnnotationValue(); |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
141 if (message.getAnnotationValue() != null) { |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
142 messageValue = message.getAnnotationValue(); |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
143 } |
16832
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
144 if (message.getAnnotationMirror() != null) { |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
145 messageAnnotation = message.getAnnotationMirror(); |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
146 } |
11466
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
147 |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
148 String text = message.getText(); |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
149 |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
150 TypeElement expectError = context.getTruffleTypes().getExpectError(); |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
151 if (expectError != null) { |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
152 AnnotationMirror mirror = ElementUtils.findAnnotationMirror(messageElement.getAnnotationMirrors(), expectError); |
11466
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
153 if (mirror != null) { |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
154 List<String> expectedTexts = ElementUtils.getAnnotationValueList(String.class, mirror, "value"); |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
155 boolean found = false; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
156 for (String expectedText : expectedTexts) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
157 if (expectedText.endsWith("%") && text.startsWith(expectedText.substring(0, expectedText.length() - 1))) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
158 found = true; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
159 break; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
160 } else if (text.equals(expectedText)) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
161 found = true; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
162 break; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
163 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
164 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
165 if (!found) { |
16759
23415229349b
Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents:
16755
diff
changeset
|
166 log.message(kind, messageElement, mirror, ElementUtils.getAnnotationValue(mirror, "value"), "Message expected one of '%s' but was '%s'.", expectedTexts, text); |
11466
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
167 } else { |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
168 return; |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
169 } |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
11466
diff
changeset
|
170 |
11466
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
171 } |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
172 } |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
173 |
4830676526e3
Truffle-DSL: added infrastructure to assert for DSL error messages.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
174 log.message(kind, messageElement, messageAnnotation, messageValue, text); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
175 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
176 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
177 public AnnotationMirror getMessageAnnotation() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
178 return null; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
179 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
180 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
181 public AnnotationValue getMessageAnnotationValue() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
182 return null; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
183 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
184 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
185 public final boolean hasErrors() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
186 return hasErrorsImpl(new HashSet<MessageContainer>()); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
187 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
188 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
189 public final List<Message> collectMessages() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
190 List<Message> collectedMessages = new ArrayList<>(); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
191 collectMessagesImpl(collectedMessages, new HashSet<MessageContainer>()); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
192 return collectedMessages; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
193 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
194 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
195 private void collectMessagesImpl(List<Message> collectedMessages, Set<MessageContainer> visitedSinks) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
196 collectedMessages.addAll(getMessages()); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
197 for (MessageContainer sink : findChildContainers()) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
198 if (visitedSinks.contains(sink)) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
199 return; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
200 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
201 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
202 visitedSinks.add(sink); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
203 sink.collectMessagesImpl(collectedMessages, visitedSinks); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
204 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
205 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
206 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
207 private boolean hasErrorsImpl(Set<MessageContainer> visitedSinks) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
208 for (Message msg : getMessages()) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
209 if (msg.getKind() == Kind.ERROR) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
210 return true; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
211 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
212 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
213 for (MessageContainer sink : findChildContainers()) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
214 if (visitedSinks.contains(sink)) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
215 return false; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
216 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
217 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
218 visitedSinks.add(sink); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
219 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
220 if (sink.hasErrorsImpl(visitedSinks)) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
221 return true; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
222 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
223 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
224 return false; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
225 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
226 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
227 public List<Message> getMessages() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
228 return messages; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
229 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
230 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
231 public static final class Message { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
232 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
233 private final MessageContainer originalContainer; |
16832
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
234 private final AnnotationMirror annotationMirror; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
235 private final AnnotationValue annotationValue; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
236 private final String text; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
237 private final Kind kind; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
238 |
16832
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
239 public Message(AnnotationMirror annotationMirror, AnnotationValue annotationValue, MessageContainer originalContainer, String text, Kind kind) { |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
240 this.annotationMirror = annotationMirror; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
241 this.annotationValue = annotationValue; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
242 this.originalContainer = originalContainer; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
243 this.text = text; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
244 this.kind = kind; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
245 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
246 |
16832
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
247 public AnnotationMirror getAnnotationMirror() { |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
248 return annotationMirror; |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
249 } |
13cf9b6b325c
Truffle-DSL: implemented import guards feature.
Christian Humer <christian.humer@gmail.com>
parents:
16759
diff
changeset
|
250 |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
251 public AnnotationValue getAnnotationValue() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
252 return annotationValue; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
253 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
254 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
255 public MessageContainer getOriginalContainer() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
256 return originalContainer; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
257 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
258 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
259 public String getText() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
260 return text; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
261 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
262 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
263 public Kind getKind() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
264 return kind; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
265 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
266 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
267 @Override |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
268 public String toString() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
269 return kind + ": " + text; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
270 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
271 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
272 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
273 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
274 } |