diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-20 15:37:11 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-20 15:37:11 -0800 |
| commit | a62be597990966b9516995650baf750ee6a0146b (patch) | |
| tree | 1741b3d5b5859319f278aa6ab821a2f801fd8e08 /source/slang/slang-check-conformance.cpp | |
| parent | 4d20fd329956ac89408b1628a8291fea01bc9a6d (diff) | |
Support link time type specialization. (#3604)
Diffstat (limited to 'source/slang/slang-check-conformance.cpp')
| -rw-r--r-- | source/slang/slang-check-conformance.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source/slang/slang-check-conformance.cpp b/source/slang/slang-check-conformance.cpp index 4376b1135..726572d08 100644 --- a/source/slang/slang-check-conformance.cpp +++ b/source/slang/slang-check-conformance.cpp @@ -242,6 +242,59 @@ namespace Slang return isSubtype(type, m_astBuilder->getDiffInterfaceType()); } + bool SemanticsVisitor::doesTypeHaveTag(Type* type, TypeTag tag) + { + if (auto arrayType = as<ArrayExpressionType>(type)) + { + return doesTypeHaveTag(arrayType->getElementType(), tag); + } + if (auto modifiedType = as<ModifiedType>(type)) + { + return doesTypeHaveTag(modifiedType->getBase(), tag); + } + if (auto declRefType = as<DeclRefType>(type)) + { + if (auto aggTypeDecl = as<AggTypeDecl>(declRefType->getDeclRef())) + return aggTypeDecl.getDecl()->hasTag(tag); + } + return false; + } + + TypeTag SemanticsVisitor::getTypeTags(Type* type) + { + if (auto arrayType = as<ArrayExpressionType>(type)) + { + return getTypeTags(arrayType->getElementType()); + } + if (auto modifiedType = as<ModifiedType>(type)) + { + return getTypeTags(modifiedType->getBase()); + } + if (auto declRefType = as<DeclRefType>(type)) + { + if (auto aggTypeDecl = as<AggTypeDecl>(declRefType->getDeclRef())) + return aggTypeDecl.getDecl()->typeTags; + } + return TypeTag::None; + } + + + Type* SemanticsVisitor::getBufferElementType(Type* type) + { + if (auto arrType = as<ArrayExpressionType>(type)) + return getBufferElementType(arrType->getElementType()); + if (auto modifiedType = as<ModifiedType>(type)) + return getBufferElementType(modifiedType->getBase()); + if (auto constantBuffer = as<ConstantBufferType>(type)) + return constantBuffer->getElementType(); + if (auto structuredBuffer = as<HLSLStructuredBufferTypeBase>(type)) + return structuredBuffer->getElementType(); + if (auto storageBuffer = as<GLSLShaderStorageBufferType>(type)) + return storageBuffer->getElementType(); + return nullptr; + } + + SubtypeWitness* SemanticsVisitor::tryGetInterfaceConformanceWitness( Type* type, Type* interfaceType) |
