diff options
| author | Yong He <yonghe@outlook.com> | 2022-08-16 17:11:54 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-16 17:11:54 -0700 |
| commit | 42f49937ffa69c82e333e886952eed027e12340e (patch) | |
| tree | 08e3e9821dd40e23476060215d589e29092adb53 /source/slang/slang-check-decl.cpp | |
| parent | e68fab2bda5d979f8d991fc41122bb9aa71849a6 (diff) | |
Add gfx interface definition in Slang. (#2364)
* Add gfx interface definition in Slang.
- add gfx interface definitons in Slang.
- fix slang compiler to correctly type-check `out` interface argument.
- modify gfx interface to be fully COM compatible
- add convenient ShaderProgram creation methods to gfx.
* Fix compile errors and warnings.
* Update project files
* Fix cuda.
* Properly implement queryInterface in command encoder impls.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 22567c889..f2a339643 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -3063,10 +3063,37 @@ namespace Slang InheritanceDecl* inheritanceDecl, ContainerDecl* parentDecl) { + auto superType = inheritanceDecl->base.type; + if( auto declRefType = as<DeclRefType>(subType) ) { auto declRef = declRefType->declRef; + if (auto superDeclRefType = as<DeclRefType>(superType)) + { + auto superTypeDecl = superDeclRefType->declRef.getDecl(); + if (superTypeDecl->findModifier<ComInterfaceAttribute>()) + { + // A struct cannot implement a COM Interface. + if (auto classDecl = as<ClassDecl>(superTypeDecl)) + { + // OK. + SLANG_UNUSED(classDecl); + } + else if (auto subInterfaceDecl = as<InterfaceDecl>(superTypeDecl)) + { + if (!subInterfaceDecl->findModifier<ComInterfaceAttribute>()) + { + getSink()->diagnose(inheritanceDecl, Diagnostics::interfaceInheritingComMustBeCom); + } + } + else if (auto structDecl = as<StructDecl>(superTypeDecl)) + { + getSink()->diagnose(inheritanceDecl, Diagnostics::structCannotImplementComInterface); + } + } + } + // Don't check conformances for abstract types that // are being used to express *required* conformances. if (auto assocTypeDeclRef = declRef.as<AssocTypeDecl>()) @@ -3089,11 +3116,12 @@ namespace Slang // code to work. return true; } + + } // Look at the type being inherited from, and validate // appropriately. - auto superType = inheritanceDecl->base.type; DeclaredSubtypeWitness* subIsSuperWitness = m_astBuilder->create<DeclaredSubtypeWitness>(); subIsSuperWitness->declRef = makeDeclRef(inheritanceDecl); |
