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 | 113037 | ScopeHandle::ScopeHandle(CompilerPass *pass, Scope *childScope, const ScopeType &scopeType) | |
| 13 | 226074 | : DeferredLogic([=] { pass->changeToParentScope(scopeType); }) { | |
| 14 |
1/2✓ Branch 5 → 6 taken 113037 times.
✗ Branch 5 → 7 not taken.
|
113037 | pass->changeToScope(childScope, scopeType); |
| 15 | 113037 | } | |
| 16 | |||
| 17 | 112716 | ScopeHandle::ScopeHandle(CompilerPass *pass, const std::string &childScopeId, const ScopeType &scopeType) | |
| 18 | 112716 | : ScopeHandle(pass, pass->currentScope->getChildScope(childScopeId), scopeType) {} | |
| 19 | |||
| 20 | 103023 | ScopeHandle::ScopeHandle(IRGenerator *generator, Scope *childScope, const ScopeType &scopeType, const ASTNode *node) | |
| 21 | 103023 | : DeferredLogic([=] { | |
| 22 | 103023 | generator->changeToParentScope(scopeType); | |
| 23 | 103023 | generator->diGenerator.popLexicalBlock(); | |
| 24 | 103023 | }) { | |
| 25 |
1/2✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 103023 times.
|
103023 | assert(scopeType != ScopeType::FUNC_PROC_BODY); // Functions/procedures manage scopes manually |
| 26 |
1/2✓ Branch 7 → 8 taken 103023 times.
✗ Branch 7 → 10 not taken.
|
103023 | generator->changeToScope(childScope, scopeType); |
| 27 |
1/2✓ Branch 8 → 9 taken 103023 times.
✗ Branch 8 → 10 not taken.
|
103023 | generator->diGenerator.pushLexicalBlock(node); |
| 28 | 103023 | } | |
| 29 | |||
| 30 | 103023 | ScopeHandle::ScopeHandle(IRGenerator *generator, const std::string &childScopeId, const ScopeType &scopeType, const ASTNode *node) | |
| 31 | 103023 | : ScopeHandle(generator, generator->currentScope->getChildScope(childScopeId), scopeType, node) {} | |
| 32 | |||
| 33 | 203292 | ExprScopeHandle::ExprScopeHandle(CompilerPass *pass, const ExprNode *expr) | |
| 34 |
3/6✓ Branch 2 → 3 taken 203292 times.
✗ Branch 2 → 9 not taken.
✓ Branch 3 → 4 taken 203292 times.
✗ Branch 3 → 7 not taken.
✓ Branch 4 → 5 taken 203292 times.
✗ Branch 4 → 7 not taken.
|
203292 | : ExprScopeHandle(pass, pass->currentScope->getChildScope(expr->getExprScopeId())) {} |
| 35 | |||
| 36 | 203292 | ExprScopeHandle::ExprScopeHandle(CompilerPass *pass, Scope *exprScope) | |
| 37 | 203292 | : DeferredLogic([=] { | |
| 38 |
2/2✓ Branch 2 → 3 taken 203248 times.
✓ Branch 2 → 4 taken 44 times.
|
203292 | if (exprScope != nullptr) |
| 39 | 203248 | pass->changeToParentScope(ScopeType::EXPR_BODY); | |
| 40 | 203292 | }), | |
| 41 | 203292 | exprScope(exprScope) { | |
| 42 |
2/2✓ Branch 5 → 6 taken 203248 times.
✓ Branch 5 → 7 taken 44 times.
|
203292 | if (exprScope != nullptr) |
| 43 |
1/2✓ Branch 6 → 7 taken 203248 times.
✗ Branch 6 → 8 not taken.
|
203248 | pass->changeToScope(exprScope, ScopeType::EXPR_BODY); |
| 44 | 203292 | } | |
| 45 | |||
| 46 | } // namespace spice::compiler | ||
| 47 |