diff options
Diffstat (limited to 'source/slang/slang-syntax.cpp')
| -rw-r--r-- | source/slang/slang-syntax.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp index 62de6599c..accbdb27e 100644 --- a/source/slang/slang-syntax.cpp +++ b/source/slang/slang-syntax.cpp @@ -641,17 +641,37 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt return declRef.substituteImpl(astBuilder, substitutions, &diff); } - Expr* DeclRefBase::substitute(ASTBuilder* /* astBuilder*/, Expr* expr) const + SubstExpr<Expr> DeclRefBase::substitute(ASTBuilder* /* astBuilder*/, Expr* expr) const { - // No substitutions? Easy. - if (!substitutions) - return expr; + return SubstExpr<Expr>(expr, substitutions); + } + + SubstExpr<Expr> substituteExpr(SubstitutionSet const& substs, Expr* expr) + { + return SubstExpr<Expr>(expr, substs); + } + + DeclRef<Decl> substituteDeclRef(SubstitutionSet const& substs, ASTBuilder* astBuilder, DeclRef<Decl> const& declRef) + { + if(!substs) + return declRef; + + int diff = 0; + auto declRefBase = declRef.substituteImpl(astBuilder, substs, &diff); + return DeclRef<Decl>(declRefBase.decl, declRefBase.substitutions); + } - SLANG_UNIMPLEMENTED_X("generic substitution into expressions"); + Type* substituteType(SubstitutionSet const& substs, ASTBuilder* astBuilder, Type* type) + { + if(!type) return nullptr; + if(!substs) return type; + + SLANG_ASSERT(type); - UNREACHABLE_RETURN(expr); + return Slang::as<Type>(type->substitute(astBuilder, substs)); } + void buildMemberDictionary(ContainerDecl* decl); InterfaceDecl* findOuterInterfaceDecl(Decl* decl) @@ -854,7 +874,7 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt return nullptr; } - DeclRefBase DeclRefBase::substituteImpl(ASTBuilder* astBuilder, SubstitutionSet substSet, int* ioDiff) + DeclRefBase DeclRefBase::substituteImpl(ASTBuilder* astBuilder, SubstitutionSet substSet, int* ioDiff) const { // Nothing to do when we have no declaration. if(!decl) |
