GCC Code Coverage Report


Directory: ../
File: src/symboltablebuilder/ScopeHandle.cpp
Date: 2024-11-22 23:10:59
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-2024 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 6511 ScopeHandle::ScopeHandle(CompilerPass *pass, Scope *childScope, const ScopeType &scopeType)
13 13022 : DeferredLogic([=]() { pass->changeToParentScope(scopeType); }) {
14
1/2
✓ Branch 1 taken 6511 times.
✗ Branch 2 not taken.
6511 pass->changeToScope(childScope, scopeType);
15 6511 }
16
17 6474 ScopeHandle::ScopeHandle(CompilerPass *pass, const std::string &childScopeId, const ScopeType &scopeType)
18 6474 : ScopeHandle(pass, pass->currentScope->getChildScope(childScopeId), scopeType) {}
19
20 5889 ScopeHandle::ScopeHandle(IRGenerator *generator, Scope *childScope, const ScopeType &scopeType, const ASTNode *node)
21 17667 : DeferredLogic([=]() {
22 5889 generator->changeToParentScope(scopeType);
23 5889 generator->diGenerator.popLexicalBlock();
24 5889 }) {
25
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5889 times.
5889 assert(scopeType != ScopeType::FUNC_PROC_BODY); // Functions/procedures manage scopes manually
26
1/2
✓ Branch 1 taken 5889 times.
✗ Branch 2 not taken.
5889 generator->changeToScope(childScope, scopeType);
27
1/2
✓ Branch 1 taken 5889 times.
✗ Branch 2 not taken.
5889 generator->diGenerator.pushLexicalBlock(node);
28 5889 }
29
30 5889 ScopeHandle::ScopeHandle(IRGenerator *generator, const std::string &childScopeId, const ScopeType &scopeType, const ASTNode *node)
31 5889 : ScopeHandle(generator, generator->currentScope->getChildScope(childScopeId), scopeType, node) {}
32
33 } // namespace spice::compiler
34