Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2021-2024 ChilliBits. All rights reserved. | ||
2 | |||
3 | #include "GenericType.h" | ||
4 | |||
5 | namespace spice::compiler { | ||
6 | |||
7 | /** | ||
8 | * Checks if the given symbol qualType matches all conditions to get a manifestation of the current generic qualType | ||
9 | * | ||
10 | * @param qualType Qualified qualType to be checked | ||
11 | * @param ignoreArraySize Ignore the array size for qualType comparison | ||
12 | * @param ignoreSpecifiers Ignore the qualType specifiers for qualType comparison | ||
13 | * @return True or false | ||
14 | */ | ||
15 | 5942 | bool GenericType::checkConditionsOf(const QualType &qualType, bool ignoreArraySize, bool ignoreSpecifiers) const { | |
16 | 5942 | return checkTypeConditionOf(qualType, ignoreArraySize, ignoreSpecifiers); | |
17 | } | ||
18 | |||
19 | /** | ||
20 | * Checks if the given qualType matches all qualType conditions to get a manifestation of the current generic qualType | ||
21 | * | ||
22 | * @param qualType Qualified type to be checked | ||
23 | * @param ignoreArraySize Ignore the array size for qualType comparison | ||
24 | * @param ignoreSpecifiers Ignore the qualType specifiers for qualType comparison | ||
25 | * @return True or false | ||
26 | */ | ||
27 | 5942 | bool GenericType::checkTypeConditionOf(const QualType &qualType, bool ignoreArraySize, bool ignoreSpecifiers) const { | |
28 | // Succeed if no qualType conditions are set | ||
29 |
2/2✓ Branch 1 taken 1246 times.
✓ Branch 2 taken 4696 times.
|
5942 | if (typeConditions.empty()) |
30 | 1246 | return true; | |
31 | // Succeed if the given qual type is generic and matches the current one | ||
32 |
6/6✓ Branch 1 taken 326 times.
✓ Branch 2 taken 4370 times.
✓ Branch 4 taken 299 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 299 times.
✓ Branch 7 taken 4397 times.
|
4696 | if (qualType.hasAnyGenericParts() && qualType == *this) |
33 | 299 | return true; | |
34 | // Check type conditions | ||
35 | 4397 | return std::ranges::any_of(typeConditions, [&](const QualType &typeCondition) { | |
36 |
4/4✓ Branch 1 taken 6007 times.
✓ Branch 2 taken 1402 times.
✓ Branch 4 taken 783 times.
✓ Branch 5 taken 5224 times.
|
7409 | return typeCondition.is(TY_DYN) || typeCondition.matches(qualType, ignoreArraySize, ignoreSpecifiers, ignoreSpecifiers); |
37 | 4397 | }); | |
38 | } | ||
39 | |||
40 | } // namespace spice::compiler | ||
41 |