annotate graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationMethodParser.java @ 18770:2c669386b5d0

Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
author Christian Humer <christian.humer@gmail.com>
date Fri, 02 Jan 2015 14:31:51 +0100
parents 2db61eddcb97
children 08aa0372dad4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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, 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.parser;
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.lang.annotation.*;
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 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
27
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.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
29 import javax.lang.model.type.*;
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
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
31 import com.oracle.truffle.api.dsl.*;
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 import com.oracle.truffle.dsl.processor.*;
16759
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
33 import com.oracle.truffle.dsl.processor.java.*;
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
34 import com.oracle.truffle.dsl.processor.model.*;
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
35 import com.oracle.truffle.dsl.processor.model.SpecializationData.SpecializationKind;
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
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 class SpecializationMethodParser extends NodeMethodParser<SpecializationData> {
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
38
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 public SpecializationMethodParser(ProcessorContext context, NodeData operation) {
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 super(context, operation);
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
41 }
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
42
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
43 @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
44 public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) {
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 return createDefaultMethodSpec(method, mirror, true, 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
46 }
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 @Override
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
49 public SpecializationData create(TemplateMethod method, boolean invalid) {
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
50 return parseSpecialization(method);
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
51 }
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
52
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
53 @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
54 public Class<? extends Annotation> getAnnotationType() {
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 return Specialization.class;
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
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 private SpecializationData parseSpecialization(TemplateMethod method) {
16759
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
59 AnnotationValue rewriteValue = ElementUtils.getAnnotationValue(method.getMarkerAnnotation(), "rewriteOn");
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
60 List<TypeMirror> exceptionTypes = ElementUtils.getAnnotationValueList(TypeMirror.class, method.getMarkerAnnotation(), "rewriteOn");
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
61 List<SpecializationThrowsData> exceptionData = new ArrayList<>();
18770
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
62 List<TypeMirror> rewriteOnTypes = new ArrayList<>();
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
63 for (TypeMirror exceptionType : exceptionTypes) {
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
64 SpecializationThrowsData throwsData = new SpecializationThrowsData(method.getMarkerAnnotation(), rewriteValue, exceptionType);
16759
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
65 if (!ElementUtils.canThrowType(method.getMethod().getThrownTypes(), exceptionType)) {
18770
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
66 method.addError("A rewriteOn checked exception was specified but not thrown in the method's throws clause. The @%s method must specify a throws clause with the exception type '%s'.",
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
67 Specialization.class.getSimpleName(), ElementUtils.getQualifiedName(exceptionType));
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
68 }
18770
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
69 rewriteOnTypes.add(throwsData.getJavaClass());
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
70 exceptionData.add(throwsData);
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
71 }
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
72
18770
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
73 for (TypeMirror typeMirror : method.getMethod().getThrownTypes()) {
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
74 if (!ElementUtils.canThrowType(rewriteOnTypes, typeMirror)) {
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
75 method.addError(rewriteValue,
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
76 "A checked exception '%s' is thrown but is not specified using the rewriteOn property. Checked exceptions that are not used for rewriting are not handled by the DSL. Use RuntimeExceptions for this purpose instead.",
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
77 ElementUtils.getQualifiedName(typeMirror));
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
78 }
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
79 }
2c669386b5d0 Truffle-DSL: fix crash if type in rewriteOn is not of type Throwable. Improved error messages for Specialization#rewriteOn.
Christian Humer <christian.humer@gmail.com>
parents: 16851
diff changeset
80
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
81 Collections.sort(exceptionData, new Comparator<SpecializationThrowsData>() {
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
82
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
83 @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
84 public int compare(SpecializationThrowsData o1, SpecializationThrowsData o2) {
16759
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
85 return ElementUtils.compareByTypeHierarchy(o1.getJavaClass(), o2.getJavaClass());
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 });
16755
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
88 SpecializationData specialization = new SpecializationData(getNode(), method, SpecializationKind.SPECIALIZED, exceptionData);
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
89
16759
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
90 String insertBeforeName = ElementUtils.getAnnotationValue(String.class, method.getMarkerAnnotation(), "insertBefore");
16755
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
91 if (!insertBeforeName.equals("")) {
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
92 specialization.setInsertBeforeName(insertBeforeName);
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
93 }
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
94
16759
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
95 List<String> guardDefs = ElementUtils.getAnnotationValueList(String.class, specialization.getMarkerAnnotation(), "guards");
16755
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
96 List<GuardExpression> guardExpressions = new ArrayList<>();
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
97 for (String guardDef : guardDefs) {
16851
2db61eddcb97 Truffle-DSL: argument syntax support for guards
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
98 guardExpressions.add(new GuardExpression(guardDef, true));
16755
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
99 }
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
100 specialization.setGuards(guardExpressions);
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
101
16759
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
102 List<String> containsDefs = ElementUtils.getAnnotationValueList(String.class, specialization.getMarkerAnnotation(), "contains");
16755
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
103 Set<String> containsNames = specialization.getContainsNames();
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
104 containsNames.clear();
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
105 if (containsDefs != null) {
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
106 for (String include : containsDefs) {
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
107 if (!containsNames.contains(include)) {
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
108 specialization.getContainsNames().add(include);
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
109 } else {
16759
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
110 AnnotationValue value = ElementUtils.getAnnotationValue(specialization.getMarkerAnnotation(), "contains");
16755
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
111 specialization.addError(value, "Duplicate contains declaration '%s'.", include);
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
112 }
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
113 }
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
114
bd28da642eea Truffle-DSL: Several new features implemented:
Christian Humer <christian.humer@gmail.com>
parents: 13528
diff changeset
115 }
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
116
16759
23415229349b Truffle-DSL: new package structure.
Christian Humer <christian.humer@gmail.com>
parents: 16755
diff changeset
117 List<String> assumptionDefs = ElementUtils.getAnnotationValueList(String.class, specialization.getMarkerAnnotation(), "assumptions");
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
118 specialization.setAssumptions(assumptionDefs);
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
119
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
120 for (String assumption : assumptionDefs) {
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
121 if (!getNode().getAssumptions().contains(assumption)) {
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
122 specialization.addError("Undeclared assumption '%s' used. Use @NodeAssumptions to declare them.", assumption);
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
123 }
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
124 }
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
125
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
126 return specialization;
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
127 }
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
128 }