From a1d543d9b1bf3b2bcd813a498d2d3e24de67106d Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 2 Feb 2021 15:45:19 -0800 Subject: Remove GlobalGenericParamSubstitution (#1684) The `GlobalGenericParamSubsitution` class used to be used to represent the mapping of global-scope generic parameters to their concrete arguments, so that we could make use of those concrete arguments for things like layout. That representation caused a lot of pain for other parts of the compiler, though, because everything that dealt with `Substitution`s needed to account for the possibility of global-generic-param subsitutions even if they logically could not occur in most parts of the compiler. We have since moved to a model where the values for global-scope generic parameters are stored in a single explicit global structure that is used by both layout computation and IR lowering. There is no actual code that construct `GlobalGenericParamSubstitution`s from scratch any more, so all of the support code for them was actually unused. This change removes all the unused code, and shows that the tests still pass without it (even the tests that use global-scope generic parameters). --- source/slang/slang-ast-substitutions.cpp | 71 -------------------------------- 1 file changed, 71 deletions(-) (limited to 'source/slang/slang-ast-substitutions.cpp') diff --git a/source/slang/slang-ast-substitutions.cpp b/source/slang/slang-ast-substitutions.cpp index acff8201e..6656f1fa6 100644 --- a/source/slang/slang-ast-substitutions.cpp +++ b/source/slang/slang-ast-substitutions.cpp @@ -163,75 +163,4 @@ HashCode ThisTypeSubstitution::_getHashCodeOverride() const return witness->getHashCode(); } -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GlobalGenericParamSubstitution !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -Substitutions* GlobalGenericParamSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, Substitutions* substOuter, int* ioDiff) -{ - // if we find a GlobalGenericParamSubstitution in subst that references the same type_param decl - // return a copy of that GlobalGenericParamSubstitution - int diff = 0; - - if (substOuter != outer) diff++; - - auto substActualType = as(actualType->substituteImpl(astBuilder, substSet, &diff)); - - List substConstraintArgs; - for (auto constraintArg : constraintArgs) - { - ConstraintArg substConstraintArg; - substConstraintArg.decl = constraintArg.decl; - substConstraintArg.val = constraintArg.val->substituteImpl(astBuilder, substSet, &diff); - - substConstraintArgs.add(substConstraintArg); - } - - if (!diff) - return this; - - (*ioDiff)++; - - GlobalGenericParamSubstitution* substSubst = astBuilder->create(); - substSubst->paramDecl = paramDecl; - substSubst->actualType = substActualType; - substSubst->constraintArgs = substConstraintArgs; - substSubst->outer = substOuter; - return substSubst; -} - -bool GlobalGenericParamSubstitution::_equalsOverride(Substitutions* subst) -{ - if (!subst) - return false; - if (subst == this) - return true; - - if (auto genSubst = as(subst)) - { - if (paramDecl != genSubst->paramDecl) - return false; - if (!actualType->equalsVal(genSubst->actualType)) - return false; - if (constraintArgs.getCount() != genSubst->constraintArgs.getCount()) - return false; - for (Index i = 0; i < constraintArgs.getCount(); i++) - { - if (!constraintArgs[i].val->equalsVal(genSubst->constraintArgs[i].val)) - return false; - } - return true; - } - return false; -} - -HashCode GlobalGenericParamSubstitution::_getHashCodeOverride() const -{ - HashCode rs = actualType->getHashCode(); - for (auto && a : constraintArgs) - { - rs = combineHash(rs, a.val->getHashCode()); - } - return rs; -} - - } // namespace Slang -- cgit v1.2.3