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