rework StmtCondition to be based on patterns initializers and boolean

conditions instead of being wrapped around PatternBindingDecl.  When
let/else goes away, PatternBindingDecl will become a lot simpler.


Swift SVN r28055
This commit is contained in:
Chris Lattner
2015-05-01 23:33:59 +00:00
parent df55a22846
commit d5073d9e4f
9 changed files with 214 additions and 155 deletions

View File

@@ -763,17 +763,24 @@ public:
return P;
}
bool doIt(StmtCondition C) {
bool doIt(const StmtCondition &C) {
for (auto &elt : C) {
if (auto E = elt.getCondition()) {
if (auto E = elt.getConditionOrNull()) {
// Walk an expression condition normally.
E = doIt(E);
if (!E)
return true;
elt.setCondition(E);
} else if (auto CB = elt.getBinding()) {
doIt(CB);
continue;
}
auto *P = doIt(elt.getPattern());
if (!P) return true;
elt.setPattern(P);
auto *I = doIt(elt.getInitializer());
if (!I) return true;
elt.setInitializer(I);
}
return false;