diff options
Diffstat (limited to 'source/slang/slang-ast-support-types.cpp')
| -rw-r--r-- | source/slang/slang-ast-support-types.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/slang/slang-ast-support-types.cpp b/source/slang/slang-ast-support-types.cpp index 1f30e0238..b550eaa68 100644 --- a/source/slang/slang-ast-support-types.cpp +++ b/source/slang/slang-ast-support-types.cpp @@ -1,6 +1,7 @@ #include "slang-ast-support-types.h" #include "slang-ast-base.h" #include "slang-ast-type.h" +#include "slang-ast-expr.h" namespace Slang { @@ -34,4 +35,31 @@ void removeModifier(ModifiableSyntaxNode* syntax, Modifier* toRemove) prev = modifier; } } + +Expr* getInnerMostExprFromHigherOrderExpr(Expr* expr) +{ + HashSet<Expr*> workListSet; + while (auto higherOrder = as<HigherOrderInvokeExpr>(expr)) + { + if (workListSet.Add(higherOrder)) + { + expr = higherOrder->baseFunction; + } + else + { + // Circularity, return null. + return nullptr; + } + } + return expr; +} + +UnownedStringSlice getHigherOrderOperatorName(HigherOrderInvokeExpr* expr) +{ + if (as<ForwardDifferentiateExpr>(expr)) + return UnownedStringSlice("fwd_diff"); + else if (as<BackwardDifferentiateExpr>(expr)) + return UnownedStringSlice("bwd_diff"); + return UnownedStringSlice(); +} } |
