diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-16 14:52:06 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-16 14:52:06 -0800 |
| commit | 68f529af8d0eb8ec45a2d73e82c4ee372015ce01 (patch) | |
| tree | 9895842d33893b9a233f58964cfa55b3974d6134 /source/slang/check.cpp | |
| parent | 59691aeeb013c5bb7cdaa31a6fc572eebd8be610 (diff) | |
| parent | a74a5494b34e2b41a294042ab8b3e7bce115dcba (diff) | |
Merge pull request #370 from csyonghe/master
bug fixes to get falcor example shader code to compile.
Diffstat (limited to 'source/slang/check.cpp')
| -rw-r--r-- | source/slang/check.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index f7bb2ae1f..3fe4f8c5d 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -1681,7 +1681,7 @@ namespace Slang { // TODO: actually implement matching here. For now we'll // just pretend that things are satisfied in order to make progress.. - requirementDict.Add(requiredMemberDeclRef, DeclRef<Decl>(memberDecl, nullptr)); + requirementDict.AddIfNotExists(requiredMemberDeclRef, DeclRef<Decl>(memberDecl, nullptr)); return true; } @@ -1927,10 +1927,16 @@ namespace Slang // (via the given `inheritanceDecl`) actually provides // members to satisfy all the requirements in the interface. bool checkInterfaceConformance( + HashSet<DeclRef<InterfaceDecl>> & checkedInterfaceDeclRef, DeclRef<AggTypeDeclBase> typeDeclRef, InheritanceDecl* inheritanceDecl, DeclRef<InterfaceDecl> interfaceDeclRef) { + if (!checkedInterfaceDeclRef.Contains(interfaceDeclRef)) + checkedInterfaceDeclRef.Add(interfaceDeclRef); + else + return true; + bool result = true; // We need to check the declaration of the interface @@ -1960,6 +1966,7 @@ namespace Slang // // TODO: we *really* need a linearization step here!!!! result = result && checkConformanceToType( + checkedInterfaceDeclRef, typeDeclRef, inheritanceDecl, getBaseType(requiredInheritanceDeclRef)); @@ -1985,6 +1992,7 @@ namespace Slang } bool checkConformanceToType( + HashSet<DeclRef<InterfaceDecl>>& checkedInterfaceDeclRefs, DeclRef<AggTypeDeclBase> typeDeclRef, InheritanceDecl* inheritanceDecl, Type* baseType) @@ -1998,6 +2006,7 @@ namespace Slang // We need to check that it provides all of the members // required by that interface. return checkInterfaceConformance( + checkedInterfaceDeclRefs, typeDeclRef, inheritanceDecl, baseInterfaceDeclRef); @@ -2019,7 +2028,8 @@ namespace Slang // Look at the type being inherited from, and validate // appropriately. auto baseType = inheritanceDecl->base.type; - return checkConformanceToType(typeDecl, inheritanceDecl, baseType.As<Type>()); + HashSet<DeclRef<InterfaceDecl>> checkdInterfaceDeclRefs; + return checkConformanceToType(checkdInterfaceDeclRefs, typeDecl, inheritanceDecl, baseType.As<Type>()); } bool checkConformance( @@ -2107,7 +2117,6 @@ namespace Slang { checkDecl(member); } - decl->SetCheckState(getCheckedState()); } @@ -4672,9 +4681,12 @@ namespace Slang // Create a witness that attests to the fact that `type` // is equal to itself. RefPtr<Val> createTypeEqualityWitness( - Type* /*type*/) + Type* type) { - SLANG_UNEXPECTED("unimplemented"); + RefPtr<TypeEqualityWitness> rs = new TypeEqualityWitness(); + rs->sub = type; + rs->sup = type; + return rs; } // If `sub` is a subtype of `sup`, then return a value that @@ -7141,4 +7153,8 @@ namespace Slang return subst; } + void checkDecl(SemanticsVisitor* visitor, Decl* decl) + { + visitor->checkDecl(decl); + } } |
