diff options
| author | Yong He <yonghe@outlook.com> | 2023-10-25 07:45:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-25 22:45:23 +0800 |
| commit | f8bf75cf1ae0aeee155996a917c2925bc500f3e2 (patch) | |
| tree | 07b418cfdc3fe106c492162624cfdaeb7a453be9 /source/slang/slang-ast-base.cpp | |
| parent | d8f4c9424c69a3d406fabf56a25dd3eda4bc7d51 (diff) | |
Support generic interfaces. (#3278)
* Initial support for generic interfaces.
* Cleanup.
* Add generic syntax for interfaces.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
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; + } + } |
