diff options
| author | Yong He <yonghe@outlook.com> | 2024-08-23 21:45:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-23 21:45:59 -0700 |
| commit | b2ca2d5a4efeae807d3c3f48f60235e47413b559 (patch) | |
| tree | 643d2bab5776e5f8f7cfa722975af9e826d77c9d /source/slang/slang-mangle.cpp | |
| parent | e4088cd602bd4d5a72fea67a787b1319acfc044d (diff) | |
Make variadic generics work with interfaces and forward autodiff. (#4905)
Diffstat (limited to 'source/slang/slang-mangle.cpp')
| -rw-r--r-- | source/slang/slang-mangle.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp index 7951ddc38..5a0d41f09 100644 --- a/source/slang/slang-mangle.cpp +++ b/source/slang/slang-mangle.cpp @@ -608,6 +608,48 @@ namespace Slang { emitType(context, getResultType(context->astBuilder, callableDeclRef)); } + + // Include key modifiers in the mangled name so we never deduplicate + // things like a nonmutating method and a mutating method. + bool isMutating = false; + bool isRefThis = false; + bool isFwdDiff = false; + bool isBwdDiff = false; + bool isNoDiffThis = false; + for (auto modifier : callableDeclRef.getDecl()->modifiers) + { + if (as<MutatingAttribute>(modifier)) + { + isMutating = true; + } + else if (as<RefAttribute>(modifier)) + { + isRefThis = true; + } + else if (as<ForwardDifferentiableAttribute>(modifier)) + { + isFwdDiff = true; + } + else if (as<BackwardDifferentiableAttribute>(modifier)) + { + isBwdDiff = true; + } + else if (as<NoDiffThisAttribute>(modifier)) + { + isNoDiffThis = true; + } + } + + if (isMutating) + emitRaw(context, "m"); + if (isRefThis) + emitRaw(context, "r"); + if (isFwdDiff) + emitRaw(context, "f"); + if (isBwdDiff) + emitRaw(context, "b"); + if (isNoDiffThis) + emitRaw(context, "n"); } } |
