GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 17 / 0 / 17
Functions: 100.0% 6 / 0 / 6
Branches: 50.0% 4 / 0 / 8

src/symboltablebuilder/ScopeHandle.cpp
Line Branch Exec Source
1 // Copyright (c) 2021-2026 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 9746 ScopeHandle::ScopeHandle(CompilerPass *pass, Scope *childScope, const ScopeType &scopeType)
13 19492 : DeferredLogic([=] { pass->changeToParentScope(scopeType); }) {
14
1/2
✓ Branch 5 → 6 taken 9746 times.
✗ Branch 5 → 7 not taken.
9746 pass->changeToScope(childScope, scopeType);
15 9746 }
16
17 9709 ScopeHandle::ScopeHandle(CompilerPass *pass, const std::string &childScopeId, const ScopeType &scopeType)
18 9709 : ScopeHandle(pass, pass->currentScope->getChildScope(childScopeId), scopeType) {}
19
20 9022 ScopeHandle::ScopeHandle(IRGenerator *generator, Scope *childScope, const ScopeType &scopeType, const ASTNode *node)
21 27066 : DeferredLogic([=] {
22 9022 generator->changeToParentScope(scopeType);
23 9022 generator->diGenerator.popLexicalBlock();
24 9022 }) {
25
1/2
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 9022 times.
9022 assert(scopeType != ScopeType::FUNC_PROC_BODY); // Functions/procedures manage scopes manually
26
1/2
✓ Branch 7 → 8 taken 9022 times.
✗ Branch 7 → 10 not taken.
9022 generator->changeToScope(childScope, scopeType);
27
1/2
✓ Branch 8 → 9 taken 9022 times.
✗ Branch 8 → 10 not taken.
9022 generator->diGenerator.pushLexicalBlock(node);
28 9022 }
29
30 9022 ScopeHandle::ScopeHandle(IRGenerator *generator, const std::string &childScopeId, const ScopeType &scopeType, const ASTNode *node)
31 9022 : ScopeHandle(generator, generator->currentScope->getChildScope(childScopeId), scopeType, node) {}
32
33 } // namespace spice::compiler
34