Lines Matching refs:relation

25 void Identity(TypeRelation *const relation, Type *const source, Type *const target)
27 relation->IsIdenticalTo(source, target);
30 void WideningPrimitive(TypeRelation *const relation, Type *const source, Type *const target)
34 WideningConverter(relation->GetChecker()->AsETSChecker(), relation, target, source);
37 void NarrowingPrimitive(TypeRelation *const relation, Type *const source, Type *const target)
41 NarrowingConverter(relation->GetChecker()->AsETSChecker(), relation, target, source);
44 void WideningNarrowingPrimitive(TypeRelation *const relation, ByteType *const source, CharType *const target)
46 auto *const tempInt = relation->GetChecker()->AsETSChecker()->GetGlobalTypesHolder()->GlobalIntType();
47 WideningPrimitive(relation, source, tempInt);
48 if (!relation->IsTrue()) {
51 NarrowingPrimitive(relation, tempInt, target);
54 void WideningReference(TypeRelation *const relation, ETSObjectType *const source, ETSObjectType *const target)
56 relation->IsSupertypeOf(target, source);
59 void WideningReference(TypeRelation *const relation, ETSArrayType *const source, ETSObjectType *const target)
61 relation->IsSupertypeOf(target, source);
64 void WideningReference(TypeRelation *const relation, ETSArrayType *const source, ETSArrayType *const target)
66 relation->IsSupertypeOf(target, source);
71 bool IsAllowedNarrowingReferenceConversionObjectObject(TypeRelation *const relation, ETSObjectType *const source,
76 relation->Result(false);
77 if (relation->IsSupertypeOf(target, source) || relation->IsSupertypeOf(source, target)) {
95 source->GetDeclNode()->IsFinal() && relation->IsSupertypeOf(source, target)) {
107 relation->Result(false);
109 target->GetDeclNode()->IsFinal() && relation->IsSupertypeOf(target, source)) {
113 auto *const etsChecker = relation->GetChecker()->AsETSChecker();
114 return relation->IsIdenticalTo(etsChecker->GetNonConstantType(source), etsChecker->GetNonConstantType(target));
117 bool IsAllowedNarrowingReferenceConversion(TypeRelation *const relation, Type *const source, Type *const target)
127 relation->Result(false);
128 if (relation->IsSupertypeOf(target, source)) {
139 if (IsAllowedNarrowingReferenceConversionObjectObject(relation, source->AsETSObjectType(),
159 relation->Result(false);
160 NarrowingReference(relation, sc->AsETSObjectType(), tc->AsETSObjectType());
161 if (relation->IsTrue()) {
187 bool IsUncheckedNarrowingReferenceConversion([[maybe_unused]] TypeRelation *const relation,
208 void NarrowingReferenceImpl(TypeRelation *const relation, Type *const source, Type *const target)
212 if (!IsAllowedNarrowingReferenceConversion(relation, source, target)) {
213 Forbidden(relation);
217 if (!IsUncheckedNarrowingReferenceConversion(relation, source, target)) {
218 relation->RemoveFlags(TypeRelationFlag::UNCHECKED_CAST);
221 relation->Result(true);
225 void NarrowingReference(TypeRelation *const relation, ETSObjectType *const source, ETSObjectType *const target)
227 NarrowingReferenceImpl(relation, source, target);
230 void NarrowingReference(TypeRelation *const relation, ETSArrayType *const source, ETSArrayType *const target)
233 NarrowingReference(relation, source->ElementType()->AsETSArrayType(), target->ElementType()->AsETSArrayType());
237 NarrowingReferenceImpl(relation, source, target);
240 void NarrowingReference(TypeRelation *const relation, ETSObjectType *const source, ETSArrayType *const target)
243 NarrowingReference(relation, source, target->ElementType()->AsETSArrayType());
247 NarrowingReferenceImpl(relation, source, target);
250 static inline void RollbackBoxingIfFailed(TypeRelation *const relation)
252 if (!relation->IsTrue()) {
253 relation->GetNode()->SetBoxingUnboxingFlags(ir::BoxingUnboxingFlags::NONE);
257 ETSObjectType *Boxing(TypeRelation *const relation, Type *const source)
259 auto *const etsChecker = relation->GetChecker()->AsETSChecker();
260 const BoxingConverter boxed(etsChecker, relation, source);
261 if (!relation->IsTrue()) {
265 relation->GetNode()->AddBoxingUnboxingFlags(etsChecker->GetBoxingFlag(boxedType));
269 Type *Unboxing(TypeRelation *const relation, ETSObjectType *const source)
271 auto *const etsChecker = relation->GetChecker()->AsETSChecker();
272 const UnboxingConverter unboxed(etsChecker, relation, source);
273 if (!relation->IsTrue()) {
277 relation->GetNode()->AddBoxingUnboxingFlags(etsChecker->GetUnboxingFlag(unboxedType));
281 void UnboxingWideningPrimitive(TypeRelation *const relation, ETSObjectType *const source, Type *const target)
283 auto *const unboxedSource = Unboxing(relation, source);
284 if (!relation->IsTrue()) {
288 WideningPrimitive(relation, target, unboxedSource);
289 RollbackBoxingIfFailed(relation);
292 void UnboxingNarrowingPrimitive(TypeRelation *const relation, ETSObjectType *const source, Type *const target)
294 auto *const unboxedSource = Unboxing(relation, source);
295 if (!relation->IsTrue()) {
299 NarrowingPrimitive(relation, target, unboxedSource);
302 void UnboxingWideningNarrowingPrimitive(TypeRelation *const relation, ETSObjectType *const source, Type *const target)
304 auto *const unboxedSource = Unboxing(relation, source);
305 if (!relation->IsTrue()) {
309 WideningNarrowingPrimitive(relation, unboxedSource->AsByteType(), target->AsCharType());
312 void NarrowingReferenceUnboxing(TypeRelation *const relation, ETSObjectType *const source, Type *const target)
314 auto *const boxedTarget = relation->GetChecker()->AsETSChecker()->PrimitiveTypeAsETSBuiltinType(target);
319 NarrowingReference(relation, source, boxedTarget->AsETSObjectType());
320 if (!relation->IsTrue()) {
323 Unboxing(relation, boxedTarget->AsETSObjectType());
326 void BoxingWideningReference(TypeRelation *const relation, Type *const source, ETSObjectType *const target)
328 auto *const boxedSource = Boxing(relation, source);
329 if (!relation->IsTrue()) {
333 WideningReference(relation, boxedSource, target);
334 RollbackBoxingIfFailed(relation);
337 void String(TypeRelation *const relation, Type *const source)
340 auto *const tempInt = relation->GetChecker()->AsETSChecker()->GetGlobalTypesHolder()->GlobalIntType();
341 WideningPrimitive(relation, source, tempInt);
342 Boxing(relation, tempInt);
343 relation->GetNode()->AddAstNodeFlags(ir::AstNodeFlags::CONVERT_TO_STRING);
349 Boxing(relation, source);
350 relation->GetNode()->AddAstNodeFlags(ir::AstNodeFlags::CONVERT_TO_STRING);
357 void Forbidden(TypeRelation *const relation)
359 relation->Result(false);