From a0458266d7cd5d802b8c51e6a997b4bf0d9beb82 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 3 Nov 2017 09:38:02 -0400 Subject: in-progress work --- source/slang/lower.cpp | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'source/slang/lower.cpp') diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index b810d9643..b8696df47 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -779,20 +779,6 @@ struct LoweringVisitor translateDeclRef(DeclRef(type->declRef)).As()); } - RefPtr visitGenericConstraintDeclRefType(GenericConstraintDeclRefType* type) - { - // not supported by lowering - SLANG_UNREACHABLE("visitGenericConstraintDeclRefType in LowerVisitor"); - return nullptr; - } - - RefPtr visitAssocTypeDeclRefType(AssocTypeDeclRefType* type) - { - // not supported by lowering - SLANG_UNREACHABLE("visitAssocTypeDeclRefType in LowerVisitor"); - return nullptr; - } - RefPtr visitTypeType(TypeType* type) { return getTypeType(lowerType(type->type)); @@ -2569,14 +2555,23 @@ struct LoweringVisitor Substitutions* inSubstitutions) { if (!inSubstitutions) return nullptr; - - RefPtr result = new Substitutions(); - result->genericDecl = translateDeclRef(inSubstitutions->genericDecl).As(); - for (auto arg : inSubstitutions->args) + if (auto genSubst = dynamic_cast(inSubstitutions)) { - result->args.Add(translateVal(arg)); + RefPtr result = new GenericSubstitution(); + result->genericDecl = translateDeclRef(genSubst->genericDecl).As(); + for (auto arg : genSubst->args) + { + result->args.Add(translateVal(arg)); + } + return result; } - return result; + else if (auto thisSubst = dynamic_cast(inSubstitutions)) + { + RefPtr result = new ThisTypeSubstitution(); + result->sourceType = translateVal(result->sourceType); + return result; + } + return nullptr; } static Decl* getModifiedDecl(Decl* decl) @@ -2733,7 +2728,11 @@ struct LoweringVisitor RefPtr tryToFindLayout( Decl* decl) { - auto loweredParent = translateDeclRef(decl->ParentDecl); + RefPtr loweredParent; + if (auto genericParentDecl = decl->ParentDecl->As()) + loweredParent = translateDeclRef(genericParentDecl->ParentDecl); + else + loweredParent = translateDeclRef(decl->ParentDecl); if (loweredParent) { auto layoutMod = loweredParent->FindModifier(); @@ -3831,7 +3830,7 @@ struct LoweringVisitor "Vector").As(); auto vectorTypeDecl = vectorGenericDecl->inner; - auto substitutions = new Substitutions(); + auto substitutions = new GenericSubstitution(); substitutions->genericDecl = vectorGenericDecl.Ptr(); substitutions->args.Add(elementType); substitutions->args.Add(elementCount); -- cgit v1.2.3