From f8bf75cf1ae0aeee155996a917c2925bc500f3e2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 25 Oct 2023 07:45:23 -0700 Subject: Support generic interfaces. (#3278) * Initial support for generic interfaces. * Cleanup. * Add generic syntax for interfaces. --------- Co-authored-by: Yong He --- source/slang/slang-ast-base.cpp | 55 ++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'source/slang/slang-ast-base.cpp') 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(this); - m_defaultDeclRefEpoch = currentEpoch; + const Index currentEpoch = astBuilder->getEpoch(); + if (currentEpoch != m_defaultDeclRefEpoch || !m_defaultDeclRef) + { + m_defaultDeclRef = astBuilder->getOrCreate(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; + } + } -- cgit v1.2.3