GCC Code Coverage Report


Directory: ../
File: src/symboltablebuilder/ScopeHandle.cpp
Date: 2025-08-26 18:26:32
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 6 6 100.0%
Branches: 4 8 50.0%

Line Branch Exec Source
1 // Copyright (c) 2021-2025 ChilliBits. All rights reserved.
2
3 #include "ScopeHandle.h"
4
5 #include "CompilerPass.h"
6 #include <ast/ASTNodes.h>
7 #include <irgenerator/IRGenerator.h>
8 #include <symboltablebuilder/Scope.h>
9
10 namespace spice::compiler {
11
12 8281 ScopeHandle::ScopeHandle(CompilerPass *pass, Scope *childScope, const ScopeType &scopeType)
13 16562 : DeferredLogic([=]() { pass->changeToParentScope(scopeType); }) {
14
1/2
✓ Branch 0 (5→6) taken 8281 times.
✗ Branch 1 (5→7) not taken.
8281 pass->changeToScope(childScope, scopeType);
15 8281 }
16
17 8241 ScopeHandle::ScopeHandle(CompilerPass *pass, const std::string &childScopeId, const ScopeType &scopeType)
18 8241 : ScopeHandle(pass, pass->currentScope->getChildScope(childScopeId), scopeType) {}
19
20 7560 ScopeHandle::ScopeHandle(IRGenerator *generator, Scope *childScope, const ScopeType &scopeType, const ASTNode *node)
21 22680 : DeferredLogic([=]() {
22 7560 generator->changeToParentScope(scopeType);
23 7560 generator->diGenerator.popLexicalBlock();
24 7560 }) {
25
1/2
✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 7560 times.
7560 assert(scopeType != ScopeType::FUNC_PROC_BODY); // Functions/procedures manage scopes manually
26
1/2
✓ Branch 0 (7→8) taken 7560 times.
✗ Branch 1 (7→10) not taken.
7560 generator->changeToScope(childScope, scopeType);
27
1/2
✓ Branch 0 (8→9) taken 7560 times.
✗ Branch 1 (8→10) not taken.
7560 generator->diGenerator.pushLexicalBlock(node);
28 7560 }
29
30 7560 ScopeHandle::ScopeHandle(IRGenerator *generator, const std::string &childScopeId, const ScopeType &scopeType, const ASTNode *node)
31 7560 : ScopeHandle(generator, generator->currentScope->getChildScope(childScopeId), scopeType, node) {}
32
33 } // namespace spice::compiler
34