ref: 87f8ea372e925ddb1ab531130bfd3e989e73c5b5
parent: 814d466b8deea3209cb4178a3862eb803defca72
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Apr 24 14:29:11 EDT 2014
Add else clause in if statements
--- a/stmt.c
+++ b/stmt.c
@@ -263,19 +263,22 @@
static void
If(Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
{
- Symbol *end = label(NULL, 1);
+ Symbol *end, *lelse = label(NULL, 1);
Node *np;
expect(IF);
np = condition();
NEGATE(np, 1);
- emitjump(end, np);
+ emitjump(lelse, np);
stmt(lbreak, lcont, lswitch);
if (accept(ELSE)) {
- emitlabel(end);
+ end = label(NULL, 1);
+ emitjump(end, NULL);
+ emitlabel(lelse);
stmt(lbreak, lcont, lswitch);
- } else {
emitlabel(end);
+ } else {
+ emitlabel(lelse);
}
}