From a5efbb1b775afb2f6b29b37d39947c41744bb005 Mon Sep 17 00:00:00 2001 From: Ronan Date: Sat, 26 Apr 2025 21:04:01 +0200 Subject: Added getCanonicalGenericConstraints2 (sorts constraints and allows more generic expressions) (#6787) --- source/slang/slang-ast-decl.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/slang/slang-ast-decl.cpp') diff --git a/source/slang/slang-ast-decl.cpp b/source/slang/slang-ast-decl.cpp index 530f983d9..4c5d32f71 100644 --- a/source/slang/slang-ast-decl.cpp +++ b/source/slang/slang-ast-decl.cpp @@ -105,6 +105,20 @@ void ContainerDecl::buildMemberDictionary() SLANG_ASSERT(isMemberDictionaryValid()); } +Index ContainerDecl::getDeclIndex(Decl* decl) +{ + if (Index* ptr = mapDeclMemberToIndex.tryGetValue(decl)) + { + return *ptr; + } + Index res = members.findFirstIndex([&](Decl* d) { return d == decl; }); + if (res >= Index(0)) + { + mapDeclMemberToIndex[decl] = res; + } + return res; +} + bool isLocalVar(const Decl* decl) { const auto varDecl = as(decl); -- cgit v1.2.3