summaryrefslogtreecommitdiff
path: root/source/slang/slang-syntax.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-syntax.cpp')
-rw-r--r--source/slang/slang-syntax.cpp146
1 files changed, 144 insertions, 2 deletions
diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp
index 1dcaafec5..334273870 100644
--- a/source/slang/slang-syntax.cpp
+++ b/source/slang/slang-syntax.cpp
@@ -184,12 +184,154 @@ static bool _checkSubClassRange()
return SLANG_OK;
}
+ // Free functions
-void Type::accept(IValVisitor* visitor, void* extra)
+const RefPtr<Decl>* adjustFilterCursorImpl(const SyntaxClassBase::ClassInfo& clsInfo, MemberFilterStyle filterStyle, const RefPtr<Decl>* ptr, const RefPtr<Decl>* end)
{
- accept((ITypeVisitor*)visitor, extra);
+ switch (filterStyle)
+ {
+ default:
+ case MemberFilterStyle::All:
+ {
+ for (; ptr != end; ptr++)
+ {
+ Decl* decl = *ptr;
+ if (decl->getClassInfo().isSubClassOf(clsInfo))
+ {
+ return ptr;
+ }
+ }
+ break;
+ }
+ case MemberFilterStyle::Instance:
+ {
+ for (; ptr != end; ptr++)
+ {
+ Decl* decl = *ptr;
+ if (decl->getClassInfo().isSubClassOf(clsInfo) && !decl->HasModifier<HLSLStaticModifier>())
+ {
+ return ptr;
+ }
+ }
+ break;
+ }
+ case MemberFilterStyle::Static:
+ {
+ for (; ptr != end; ptr++)
+ {
+ Decl* decl = *ptr;
+ if (decl->getClassInfo().isSubClassOf(clsInfo) && decl->HasModifier<HLSLStaticModifier>())
+ {
+ return ptr;
+ }
+ }
+ break;
+ }
+ }
+ return end;
+}
+
+const RefPtr<Decl>* getFilterCursorByIndexImpl(const SyntaxClassBase::ClassInfo& clsInfo, MemberFilterStyle filterStyle, const RefPtr<Decl>* ptr, const RefPtr<Decl>* end, Index index)
+{
+ switch (filterStyle)
+ {
+ default:
+ case MemberFilterStyle::All:
+ {
+ for (; ptr != end; ptr++)
+ {
+ Decl* decl = *ptr;
+ if (decl->getClassInfo().isSubClassOf(clsInfo))
+ {
+ if (index <= 0)
+ {
+ return ptr;
+ }
+ index--;
+ }
+ }
+ break;
+ }
+ case MemberFilterStyle::Instance:
+ {
+ for (; ptr != end; ptr++)
+ {
+ Decl* decl = *ptr;
+ if (decl->getClassInfo().isSubClassOf(clsInfo) && !decl->HasModifier<HLSLStaticModifier>())
+ {
+ if (index <= 0)
+ {
+ return ptr;
+ }
+ index--;
+ }
+ }
+ break;
+ }
+ case MemberFilterStyle::Static:
+ {
+ for (; ptr != end; ptr++)
+ {
+ Decl* decl = *ptr;
+ if (decl->getClassInfo().isSubClassOf(clsInfo) && decl->HasModifier<HLSLStaticModifier>())
+ {
+ if (index <= 0)
+ {
+ return ptr;
+ }
+ index--;
+ }
+ }
+ break;
+ }
+ }
+ return nullptr;
}
+Index getFilterCountImpl(const SyntaxClassBase::ClassInfo& clsInfo, MemberFilterStyle filterStyle, const RefPtr<Decl>* ptr, const RefPtr<Decl>* end)
+{
+ Index count = 0;
+ switch (filterStyle)
+ {
+ default:
+ case MemberFilterStyle::All:
+ {
+ for (; ptr != end; ptr++)
+ {
+ Decl* decl = *ptr;
+ count += Index(decl->getClassInfo().isSubClassOf(clsInfo));
+ }
+ break;
+ }
+ case MemberFilterStyle::Instance:
+ {
+ for (; ptr != end; ptr++)
+ {
+ Decl* decl = *ptr;
+ count += Index(decl->getClassInfo().isSubClassOf(clsInfo)&& !decl->HasModifier<HLSLStaticModifier>());
+ }
+ break;
+ }
+ case MemberFilterStyle::Static:
+ {
+ for (; ptr != end; ptr++)
+ {
+ Decl* decl = *ptr;
+ count += Index(decl->getClassInfo().isSubClassOf(clsInfo) && decl->HasModifier<HLSLStaticModifier>());
+ }
+ break;
+ }
+ }
+ return count;
+}
+
+ // Type
+
+ void Type::accept(IValVisitor* visitor, void* extra)
+ {
+ accept((ITypeVisitor*)visitor, extra);
+ }
+
// TypeExp
bool TypeExp::Equals(Type* other)