Fix null-pointer when trying to dump null statements.

(cherry picked from commit 69a96112e8)
This commit is contained in:
Henry Wong 2016-10-23 03:30:20 -04:00 committed by Martin Whitaker
parent b3cf533b3c
commit 1a8b19baf2
1 changed files with 32 additions and 8 deletions

View File

@ -928,7 +928,10 @@ void PDisable::dump(ostream&out, unsigned ind) const
void PDoWhile::dump(ostream&out, unsigned ind) const void PDoWhile::dump(ostream&out, unsigned ind) const
{ {
out << setw(ind) << "" << "do" << endl; out << setw(ind) << "" << "do" << endl;
if (statement_)
statement_->dump(out, ind+3); statement_->dump(out, ind+3);
else
out << setw(ind+3) << "" << "/* NOOP */" << endl;
out << setw(ind) << "" << "while (" << *cond_ << ");" << endl; out << setw(ind) << "" << "while (" << *cond_ << ");" << endl;
} }
@ -991,13 +994,19 @@ void PForeach::dump(ostream&fd, unsigned ind) const
} }
fd << "] /* " << get_fileline() << " */" << endl; fd << "] /* " << get_fileline() << " */" << endl;
if (statement_)
statement_->dump(fd, ind+3); statement_->dump(fd, ind+3);
else
fd << setw(ind+3) << "" << "/* NOOP */" << endl;
} }
void PForever::dump(ostream&out, unsigned ind) const void PForever::dump(ostream&out, unsigned ind) const
{ {
out << setw(ind) << "" << "forever /* " << get_fileline() << " */" << endl; out << setw(ind) << "" << "forever /* " << get_fileline() << " */" << endl;
if (statement_)
statement_->dump(out, ind+3); statement_->dump(out, ind+3);
else
out << setw(ind+3) << "" << "/* NOOP */" << endl;
} }
void PForStatement::dump(ostream&out, unsigned ind) const void PForStatement::dump(ostream&out, unsigned ind) const
@ -1005,7 +1014,10 @@ void PForStatement::dump(ostream&out, unsigned ind) const
out << setw(ind) << "" << "for (" << *name1_ << " = " << *expr1_ out << setw(ind) << "" << "for (" << *name1_ << " = " << *expr1_
<< "; " << *cond_ << "; <for_step>)" << endl; << "; " << *cond_ << "; <for_step>)" << endl;
step_->dump(out, ind+6); step_->dump(out, ind+6);
if (statement_)
statement_->dump(out, ind+3); statement_->dump(out, ind+3);
else
out << setw(ind+3) << "" << "/* NOOP */" << endl;
} }
void PFunction::dump(ostream&out, unsigned ind) const void PFunction::dump(ostream&out, unsigned ind) const
@ -1049,7 +1061,10 @@ void PRelease::dump(ostream&out, unsigned ind) const
void PRepeat::dump(ostream&out, unsigned ind) const void PRepeat::dump(ostream&out, unsigned ind) const
{ {
out << setw(ind) << "" << "repeat (" << *expr_ << ")" << endl; out << setw(ind) << "" << "repeat (" << *expr_ << ")" << endl;
if (statement_)
statement_->dump(out, ind+3); statement_->dump(out, ind+3);
else
out << setw(ind+3) << "" << "/* NOOP */" << endl;
} }
void PReturn::dump(ostream&fd, unsigned ind) const void PReturn::dump(ostream&fd, unsigned ind) const
@ -1132,7 +1147,10 @@ void PTrigger::dump(ostream&out, unsigned ind) const
void PWhile::dump(ostream&out, unsigned ind) const void PWhile::dump(ostream&out, unsigned ind) const
{ {
out << setw(ind) << "" << "while (" << *cond_ << ")" << endl; out << setw(ind) << "" << "while (" << *cond_ << ")" << endl;
if (statement_)
statement_->dump(out, ind+3); statement_->dump(out, ind+3);
else
out << setw(ind+3) << "" << "/* NOOP */" << endl;
} }
void PProcess::dump(ostream&out, unsigned ind) const void PProcess::dump(ostream&out, unsigned ind) const
@ -1142,7 +1160,10 @@ void PProcess::dump(ostream&out, unsigned ind) const
dump_attributes_map(out, attributes, ind+2); dump_attributes_map(out, attributes, ind+2);
if (statement_)
statement_->dump(out, ind+2); statement_->dump(out, ind+2);
else
out << setw(ind+2) << "" << "/* NOOP */" << endl;
} }
void AProcess::dump(ostream&out, unsigned ind) const void AProcess::dump(ostream&out, unsigned ind) const
@ -1163,7 +1184,10 @@ void AProcess::dump(ostream&out, unsigned ind) const
dump_attributes_map(out, attributes, ind+2); dump_attributes_map(out, attributes, ind+2);
if (statement_)
statement_->dump(out, ind+2); statement_->dump(out, ind+2);
else
out << setw(ind+2) << "" << "/* NOOP */" << endl;
} }
void PSpecPath::dump(std::ostream&out, unsigned ind) const void PSpecPath::dump(std::ostream&out, unsigned ind) const