// Solution to optional HW problem void IfElse::codeGen() { string falseLab = newLabel(); string afterLab; // only used if there is an else cond->codeGen(); emit("if ", cond->getPlace(), "= 0 goto ", falseLab); thenPart->codeGen(); if (optElse != NULL) { afterLab = newLabel(); emit("goto ", afterLab); } emit(falseLab, ":"); if (hasElse) { optElse->codeGen(); emit(afterLab, ":"); } }