GCC Code Coverage Report


Directory: ../
File: src/model/GenericType.h
Date: 2024-11-22 23:10:59
Exec Total Coverage
Lines: 3 3 100.0%
Functions: 2 2 100.0%
Branches: 2 4 50.0%

Line Branch Exec Source
1 // Copyright (c) 2021-2024 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <string>
6 #include <utility>
7
8 #include <symboltablebuilder/QualType.h>
9 #include <symboltablebuilder/Type.h>
10
11 #include "../../lib/json/json.hpp"
12
13 namespace spice::compiler {
14
15 // Typedefs
16 using TypeMapping = std::unordered_map</*typeName=*/std::string, /*concreteType=*/QualType>;
17
18 class GenericType : public QualType {
19 public:
20 // Constructors
21
2/4
✓ Branch 1 taken 3332 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3332 times.
✗ Branch 5 not taken.
9996 explicit GenericType(const QualType &type) : QualType(type){};
22 explicit GenericType(const std::string &name) : QualType(TY_GENERIC, name) {}
23 722 GenericType(const std::string &name, QualTypeList typeConditions)
24 722 : QualType(TY_GENERIC, name), typeConditions(std::move(typeConditions)) {}
25 GenericType() = default;
26
27 // Public methods
28 [[nodiscard]] bool checkConditionsOf(const QualType &qualType, bool ignoreArraySize = false, bool ignoreSpecifiers = false) const;
29
30 // Public members
31 bool used = false;
32
33 private:
34 // Members
35 QualTypeList typeConditions = {QualType(TY_DYN)};
36
37 // Private methods
38 [[nodiscard]] bool checkTypeConditionOf(const QualType &qualType, bool ignoreArraySize, bool ignoreSpecifiers) const;
39 };
40
41 } // namespace spice::compiler
42