comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeSystemParser.java @ 11557:e08a9328ce92

Truffle-DSL: allow multiple implicit casts with the same source type.
author Andreas Woess <andreas.woess@jku.at>
date Mon, 09 Sep 2013 22:33:57 +0200
parents 2fb276f5e3e9
children 5a0c694ef735
comparison
equal deleted inserted replaced
11556:7ce149d349c9 11557:e08a9328ce92
106 106
107 for (TypeCastData cast : casts) { 107 for (TypeCastData cast : casts) {
108 cast.getTargetType().addTypeCast(cast); 108 cast.getTargetType().addTypeCast(cast);
109 } 109 }
110 110
111 verifyImplicitCasts(typeSystem);
112 verifyGenericTypeChecksAndCasts(typeSystem); 111 verifyGenericTypeChecksAndCasts(typeSystem);
113 verifyMethodSignatures(typeSystem); 112 verifyMethodSignatures(typeSystem);
114 verifyNamesUnique(typeSystem); 113 verifyNamesUnique(typeSystem);
115 114
116 return typeSystem; 115 return typeSystem;
117 }
118
119 private static void verifyImplicitCasts(TypeSystemData typeSystem) {
120 Set<TypeData> types = new HashSet<>();
121 Set<TypeData> duplicateSourceTypes = new HashSet<>();
122 for (ImplicitCastData cast : typeSystem.getImplicitCasts()) {
123 if (types.contains(cast.getSourceType())) {
124 duplicateSourceTypes.add(cast.getSourceType());
125 }
126 types.add(cast.getSourceType());
127 }
128 for (TypeData duplicateType : duplicateSourceTypes) {
129 for (ImplicitCastData cast : typeSystem.getImplicitCasts()) {
130 if (cast.getSourceType().equals(duplicateType)) {
131 cast.addError("Duplicate cast source type %s.", Utils.getSimpleName(duplicateType.getPrimitiveType()), ImplicitCast.class.getSimpleName());
132 }
133 }
134 }
135 } 116 }
136 117
137 private static void verifyGenericTypeChecksAndCasts(TypeSystemData typeSystem) { 118 private static void verifyGenericTypeChecksAndCasts(TypeSystemData typeSystem) {
138 for (TypeData type : typeSystem.getTypes()) { 119 for (TypeData type : typeSystem.getTypes()) {
139 if (!type.getTypeChecks().isEmpty()) { 120 if (!type.getTypeChecks().isEmpty()) {