[Variadic Generics] add tracking of pack environments for pack elements to Constraint System

This commit is contained in:
Sophia Poirier
2023-07-06 11:17:05 -07:00
parent 626c32b890
commit 63e30b5525
5 changed files with 123 additions and 28 deletions

View File

@@ -683,6 +683,21 @@ ConstraintSystem::getPackElementEnvironment(ConstraintLocator *locator,
shapeParam, contextSubs);
}
PackExpansionExpr *
ConstraintSystem::getPackEnvironment(PackElementExpr *packElement) const {
const auto match = PackEnvironments.find(packElement);
return (match == PackEnvironments.end()) ? nullptr : match->second;
}
void ConstraintSystem::addPackEnvironment(PackElementExpr *packElement,
PackExpansionExpr *packExpansion) {
assert(packElement);
assert(packExpansion);
[[maybe_unused]] const auto inserted =
PackEnvironments.insert({packElement, packExpansion}).second;
assert(inserted && "Mapping already defined?");
}
/// Extend the given depth map by adding depths for all of the subexpressions
/// of the given expression.
static void extendDepthMap(