GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 4 / 0 / 4
Functions: 100.0% 3 / 0 / 3
Branches: -% 0 / 0 / 0

src/symboltablebuilder/SymbolTableEntry.h
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <string>
6 #include <utility>
7
8 #include <symboltablebuilder/Lifecycle.h>
9 #include <symboltablebuilder/QualType.h>
10
11 #include <nlohmann/json.hpp>
12
13 // Forward declarations
14 namespace spice::compiler {
15
16 // Forward declarations
17 class Scope;
18 class ASTNode;
19 struct CodeLoc;
20
21 /**
22 * Entry of a symbol table, representing an individual symbol with all its properties
23 */
24 class SymbolTableEntry final {
25 public:
26 // Constructors
27 168591 SymbolTableEntry(std::string name, const QualType &qualType, Scope *scope, ASTNode *declNode, size_t orderIndex, bool global)
28 337182 : name(std::move(name)), scope(scope), declNode(declNode), orderIndex(orderIndex), global(global), qualType(qualType) {}
29
30 // Public methods
31 [[nodiscard]] const QualType &getQualType() const;
32 void updateType(const QualType &newType, bool overwriteExistingType);
33 void updateState(const LifecycleState &newState, const ASTNode *node);
34 [[nodiscard]] const CodeLoc &getDeclCodeLoc() const;
35 [[nodiscard]] bool isField() const;
36 25838 [[nodiscard]] const Lifecycle &getLifecycle() const { return lifecycle; }
37 1096 [[nodiscard]] bool isInitialized() const { return lifecycle.isInitialized(); }
38 [[nodiscard]] nlohmann::ordered_json toJSON() const;
39
40 // Public members
41 const std::string name;
42 Scope *scope;
43 ASTNode *declNode;
44 const size_t orderIndex;
45 const bool global;
46 bool isVolatile = false;
47 bool isParam = false;
48 bool anonymous = false;
49 bool used = false;
50 bool omitDtorCall = false;
51 bool isImplicitField = false;
52
53 private:
54 // Members
55 QualType qualType;
56 Lifecycle lifecycle;
57 };
58
59 } // namespace spice::compiler
60