diff options
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); |
