diff options
Diffstat (limited to 'source/slang/slang-ast-base.cpp')
| -rw-r--r-- | source/slang/slang-ast-base.cpp | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/source/slang/slang-ast-base.cpp b/source/slang/slang-ast-base.cpp index 60be7a563..d4904d2de 100644 --- a/source/slang/slang-ast-base.cpp +++ b/source/slang/slang-ast-base.cpp @@ -3,34 +3,43 @@ namespace Slang { -void NodeBase::_initDebug(ASTNodeType inAstNodeType, ASTBuilder* inAstBuilder) -{ + void NodeBase::_initDebug(ASTNodeType inAstNodeType, ASTBuilder* inAstBuilder) + { #ifdef _DEBUG - SLANG_UNUSED(inAstNodeType); - static int32_t uidCounter = 0; - static int32_t breakValue = 0; - uidCounter++; - _debugUID = uidCounter; - if (inAstBuilder->getId() == -1) - _debugUID = -_debugUID; - if (breakValue != 0 && _debugUID == breakValue) - SLANG_BREAKPOINT(0) + SLANG_UNUSED(inAstNodeType); + static int32_t uidCounter = 0; + static int32_t breakValue = 0; + uidCounter++; + _debugUID = uidCounter; + if (inAstBuilder->getId() == -1) + _debugUID = -_debugUID; + if (breakValue != 0 && _debugUID == breakValue) + SLANG_BREAKPOINT(0) #else - SLANG_UNUSED(inAstNodeType); - SLANG_UNUSED(inAstBuilder); + SLANG_UNUSED(inAstNodeType); + SLANG_UNUSED(inAstBuilder); #endif -} -DeclRefBase* Decl::getDefaultDeclRef() -{ - if (auto astBuilder = getCurrentASTBuilder()) + } + DeclRefBase* Decl::getDefaultDeclRef() { - const Index currentEpoch = astBuilder->getEpoch(); - if (currentEpoch != m_defaultDeclRefEpoch || !m_defaultDeclRef) + if (auto astBuilder = getCurrentASTBuilder()) { - m_defaultDeclRef = astBuilder->getOrCreate<DirectDeclRef>(this); - m_defaultDeclRefEpoch = currentEpoch; + const Index currentEpoch = astBuilder->getEpoch(); + if (currentEpoch != m_defaultDeclRefEpoch || !m_defaultDeclRef) + { + m_defaultDeclRef = astBuilder->getOrCreate<DirectDeclRef>(this); + m_defaultDeclRefEpoch = currentEpoch; + } } + return m_defaultDeclRef; } - return m_defaultDeclRef; -} + + bool Decl::isChildOf(Decl* other) const + { + for (auto parent = parentDecl; parent; parent = parent->parentDecl) + if (parent == other) + return true; + return false; + } + } |
