diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-12 14:15:56 -0800 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-01-12 14:15:56 -0800 |
| commit | df6eeb93c1718334779ae328db277cdf7a9d7b04 (patch) | |
| tree | f4d53d3106cdc717727701e46411a1ebe23105fb /source/slang/mangle.cpp | |
| parent | 8daafcc2e4bf7b2dfb66d7a3b7ac60c86b2d926c (diff) | |
Refactor substitution representation in DeclRefBase (#363)
This commit changes the type of `DeclRefBase::substitutions` from `RefPtr<Substitutions>` to `SubstitutionSet`, which is a new type defined as following:
```
struct SubstitutionSet
{
RefPtr<GenericSubstitution> genericSubstitutions;
RefPtr<ThisTypeSubstitution> thisTypeSubstitution;
RefPtr<GlobalGenericParamSubstitution> globalGenParamSubstitutions;
}
```
This change get rid of most helper functions to retreive the substitution of a certain type, as well as surgery operations to insert a `ThisTypeSubstitution` or `GlobalGenericTypeSubstittuion` at top or bottom of the substitution chain. It also simplies type comparison when certain type of substitution should not be considered as part of type definition.
Diffstat (limited to 'source/slang/mangle.cpp')
| -rw-r--r-- | source/slang/mangle.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/source/slang/mangle.cpp b/source/slang/mangle.cpp index 5b8e519b9..070c2b172 100644 --- a/source/slang/mangle.cpp +++ b/source/slang/mangle.cpp @@ -186,7 +186,7 @@ namespace Slang // TODO: this needs to be centralized RefPtr<GenericSubstitution> getOutermostGenericSubst( - RefPtr<Substitutions> inSubst) + RefPtr<GenericSubstitution> inSubst) { for (auto subst = inSubst; subst; subst = subst->outer) { @@ -233,7 +233,7 @@ namespace Slang // There are two cases here: either we have specializations // in place for the parent generic declaration, or we don't. - auto subst = getOutermostGenericSubst(declRef.substitutions); + auto subst = getOutermostGenericSubst(declRef.substitutions.genericSubstitutions); if( subst && subst->genericDecl == parentGenericDeclRef.getDecl() ) { // This is the case where we *do* have substitutions. @@ -378,20 +378,15 @@ namespace Slang DeclRef<Decl>(declRef.decl, declRef.substitutions)); } - String mangleSpecializedFuncName(String baseName, RefPtr<Substitutions> subst) + String mangleSpecializedFuncName(String baseName, SubstitutionSet subst) { ManglingContext context; emitRaw(&context, baseName.Buffer()); emitRaw(&context, "_G"); - while (subst) + if (auto genSubst = subst.genericSubstitutions) { - if (auto genSubst = subst.As<GenericSubstitution>()) - { - for (auto a : genSubst->args) - emitVal(&context, a); - break; - } - subst = subst->outer; + for (auto a : genSubst->args) + emitVal(&context, a); } return context.sb.ProduceString(); } |
