standardize naming of tuples and tuple patterns on "elements".

Previously some parts of the compiler referred to them as "fields",
and most referred to them as "elements".  Use the more generic 'elements'
nomenclature because that's what we refer to other things in the compiler
(e.g. the elements of a bracestmt).

At the same time, make the API better by providing "getElement" consistently
and using it, instead of getElements()[i].

NFC.



Swift SVN r26894
This commit is contained in:
Chris Lattner
2015-04-02 20:23:49 +00:00
parent a85cc9c6e9
commit 79ed57f9f2
69 changed files with 397 additions and 378 deletions

View File

@@ -103,7 +103,7 @@ static void dumpPattern(const Pattern *p, llvm::raw_ostream &os) {
os << "var " << cast<NamedPattern>(p)->getBodyName();
return;
case PatternKind::Tuple: {
unsigned numFields = cast<TuplePattern>(p)->getNumFields();
unsigned numFields = cast<TuplePattern>(p)->getNumElements();
if (numFields == 0)
os << "()";
else if (numFields == 1)
@@ -212,7 +212,7 @@ static unsigned getNumSpecializationsRecursive(const Pattern *p, unsigned n) {
// Tuple and nominal-type patterns are not themselves directly refutable.
case PatternKind::Tuple: {
auto tuple = cast<TuplePattern>(p);
for (auto &elt : tuple->getFields())
for (auto &elt : tuple->getElements())
n = getNumSpecializationsRecursive(elt.getPattern(), n);
return n;
}
@@ -1397,7 +1397,7 @@ emitTupleDispatch(ArrayRef<RowToSpecialize> rows, ConsumableManagedValue src,
specializedRows[i].RowIndex = rows[i].RowIndex;
auto pattern = cast<TuplePattern>(rows[i].Pattern);
for (auto &elt : pattern->getFields()) {
for (auto &elt : pattern->getElements()) {
specializedRows[i].Patterns.push_back(elt.getPattern());
}
}