diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-05 16:39:38 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-05 16:39:38 -0500 |
| commit | 296e89ca4f3d6d99126bf2ee59666bc946add431 (patch) | |
| tree | bff41e36c9b6843d83a5ca5e83645310be6687f3 /source/slang/lower.cpp | |
| parent | c6fb1de9547bd24a693915b758cc35499f1d949f (diff) | |
| parent | ff7c46a11787ca6ecebf0a224772a41efef33fc0 (diff) | |
Merge pull request #243 from csyonghe/master
Adding associated types
Diffstat (limited to 'source/slang/lower.cpp')
| -rw-r--r-- | source/slang/lower.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index 73854a5c7..44ad5c272 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -2554,14 +2554,24 @@ struct LoweringVisitor Substitutions* inSubstitutions) { if (!inSubstitutions) return nullptr; - - RefPtr<Substitutions> result = new Substitutions(); - result->genericDecl = translateDeclRef(inSubstitutions->genericDecl).As<GenericDecl>(); - for (auto arg : inSubstitutions->args) + if (auto genSubst = dynamic_cast<GenericSubstitution*>(inSubstitutions)) + { + RefPtr<GenericSubstitution> result = new GenericSubstitution(); + result->genericDecl = translateDeclRef(genSubst->genericDecl).As<GenericDecl>(); + for (auto arg : genSubst->args) + { + result->args.Add(translateVal(arg)); + } + return result; + } + else if (auto thisSubst = dynamic_cast<ThisTypeSubstitution*>(inSubstitutions)) { - result->args.Add(translateVal(arg)); + RefPtr<ThisTypeSubstitution> result = new ThisTypeSubstitution(); + if (result->sourceType) + result->sourceType = translateVal(result->sourceType); + return result; } - return result; + return nullptr; } static Decl* getModifiedDecl(Decl* decl) @@ -2718,7 +2728,11 @@ struct LoweringVisitor RefPtr<VarLayout> tryToFindLayout( Decl* decl) { - auto loweredParent = translateDeclRef(decl->ParentDecl); + RefPtr<Decl> loweredParent; + if (auto genericParentDecl = decl->ParentDecl->As<GenericDecl>()) + loweredParent = translateDeclRef(genericParentDecl->ParentDecl); + else + loweredParent = translateDeclRef(decl->ParentDecl); if (loweredParent) { auto layoutMod = loweredParent->FindModifier<ComputedLayoutModifier>(); @@ -2820,6 +2834,13 @@ struct LoweringVisitor return LoweredDecl(); } + LoweredDecl visitAssocTypeDecl(AssocTypeDecl * /*assocType*/) + { + // not supported + SLANG_UNREACHABLE("visitAssocTypeDecl in LowerVisitor"); + UNREACHABLE_RETURN(LoweredDecl()); + } + LoweredDecl visitTypeDefDecl(TypeDefDecl* decl) { if (shared->target == CodeGenTarget::GLSL) @@ -3809,7 +3830,7 @@ struct LoweringVisitor "Vector").As<GenericDecl>(); auto vectorTypeDecl = vectorGenericDecl->inner; - auto substs = new Substitutions(); + auto substs = new GenericSubstitution(); substs->genericDecl = vectorGenericDecl.Ptr(); substs->args.Add(elementType); substs->args.Add(elementCount); |
