Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeData.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 | efe58aa92f86 |
children |
comparison
equal
deleted
inserted
replaced
16754:55fd5be68a52 | 16755:bd28da642eea |
---|---|
109 } | 109 } |
110 return index - o.index; | 110 return index - o.index; |
111 } | 111 } |
112 | 112 |
113 @Override | 113 @Override |
114 public int hashCode() { | |
115 return Objects.hash(index, primitiveType); | |
116 } | |
117 | |
118 @Override | |
119 public boolean equals(Object obj) { | |
120 if (!(obj instanceof TypeData)) { | |
121 return false; | |
122 } | |
123 TypeData otherType = (TypeData) obj; | |
124 return index == otherType.index && Utils.typeEquals(primitiveType, otherType.primitiveType); | |
125 } | |
126 | |
127 @Override | |
114 public String toString() { | 128 public String toString() { |
115 return getClass().getSimpleName() + "[" + Utils.getSimpleName(primitiveType) + "]"; | 129 return getClass().getSimpleName() + "[" + Utils.getSimpleName(primitiveType) + "]"; |
116 } | 130 } |
117 | 131 |
118 public boolean equalsType(TypeData actualTypeData) { | 132 public boolean equalsType(TypeData actualTypeData) { |
119 return Utils.typeEquals(boxedType, actualTypeData.boxedType); | 133 return Utils.typeEquals(boxedType, actualTypeData.boxedType); |
120 } | 134 } |
121 | 135 |
122 public boolean needsCastTo(ProcessorContext context, TypeData targetType) { | 136 public boolean needsCastTo(TypeData targetType) { |
123 return Utils.needsCastTo(context, getPrimitiveType(), targetType.getPrimitiveType()); | 137 return Utils.needsCastTo(getPrimitiveType(), targetType.getPrimitiveType()); |
138 } | |
139 | |
140 public boolean needsCastTo(TypeMirror targetType) { | |
141 return Utils.needsCastTo(getPrimitiveType(), targetType); | |
124 } | 142 } |
125 | 143 |
126 public boolean isPrimitive() { | 144 public boolean isPrimitive() { |
127 return Utils.isPrimitive(getPrimitiveType()); | 145 return Utils.isPrimitive(getPrimitiveType()); |
128 } | 146 } |
129 | 147 |
148 public boolean isImplicitSubtypeOf(TypeData other) { | |
149 List<ImplicitCastData> casts = other.getTypeSystem().lookupByTargetType(other); | |
150 for (ImplicitCastData cast : casts) { | |
151 if (isSubtypeOf(cast.getSourceType())) { | |
152 return true; | |
153 } | |
154 } | |
155 return isSubtypeOf(other); | |
156 } | |
157 | |
158 public boolean isSubtypeOf(TypeData other) { | |
159 return Utils.isSubtype(boxedType, other.boxedType); | |
160 } | |
161 | |
162 public boolean intersects(TypeData type) { | |
163 if (this.equals(type)) { | |
164 return true; | |
165 } | |
166 if (type.isGeneric() || isGeneric()) { | |
167 return true; | |
168 } | |
169 return isSubtypeOf(type) || type.isSubtypeOf(this); | |
170 } | |
130 } | 171 } |