Fixing two NPEs in case of missing else and missing main.

This commit is contained in:
Stefano Sanfilippo 2014-11-27 22:10:10 +01:00
parent 764e21abd6
commit d0f3d30643

View File

@ -89,10 +89,12 @@ void Branch::emit(std::ostream &stream, int indent) {
} }
} }
stream << " else {\n"; if (els != nullptr) {
els->emit(stream, indent + 1); stream << " else {\n";
emitIndent(stream, indent); els->emit(stream, indent + 1);
stream << "}"; emitIndent(stream, indent);
stream << "}";
}
} }
void VarDeclaration::emit(std::ostream &stream, int indent) { void VarDeclaration::emit(std::ostream &stream, int indent) {
@ -186,6 +188,8 @@ void Program::emit(std::ostream &stream, int indent) {
f->emit(stream); f->emit(stream);
} }
main->emit(stream); if (main != nullptr) {
main->emit(stream);
}
} }