diff options
Diffstat (limited to 'boil/library')
-rw-r--r-- | boil/library/BoilSimp.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/boil/library/BoilSimp.java b/boil/library/BoilSimp.java index 6d8e401..e5c622c 100644 --- a/boil/library/BoilSimp.java +++ b/boil/library/BoilSimp.java @@ -491,13 +491,32 @@ public class BoilSimp extends GJDepthFirst<String,String> { */ public String visit(IfStatement n, String args) { String mod = ""; + int if_id = this.id++; n.f0.accept(this, args); n.f1.accept(this, args); - n.f2.accept(this, args); + String cond = n.f2.accept(this, args); + + vapor += String.format(" %s = %s\n", + this.tf.alias(Integer.toString(this.id++)), + cond); + vapor += String.format(" if0 %s goto :if%d_else\nif%d_body:\n", + this.tf.alias(Integer.toString(this.id-1)), + if_id, + if_id); + n.f3.accept(this, args); n.f4.accept(this, args); + + vapor += String.format(" goto :if%d_end\nif%d_else:\n", + if_id, + if_id); + n.f5.accept(this, args); n.f6.accept(this, args); + + vapor += String.format("if%d_end:\n", + if_id); + return mod; } @@ -830,7 +849,7 @@ public class BoilSimp extends GJDepthFirst<String,String> { */ public String visit(TrueLiteral n, String args) { String mod = ""; - n.f0.accept(this, args); + mod += "1"; return mod; } @@ -839,7 +858,7 @@ public class BoilSimp extends GJDepthFirst<String,String> { */ public String visit(FalseLiteral n, String args) { String mod = ""; - n.f0.accept(this, args); + mod += "0"; return mod; } |