summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boil/library/BoilSimp.java25
-rw-r--r--boil/tests/ex42.java2
-rw-r--r--boil/tests/ex43.java22
3 files changed, 45 insertions, 4 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;
}
diff --git a/boil/tests/ex42.java b/boil/tests/ex42.java
index 05af17a..8ea74b3 100644
--- a/boil/tests/ex42.java
+++ b/boil/tests/ex42.java
@@ -2,7 +2,7 @@ class ex42 {
public static void main(String[] z) {
A a ;
a = new A() ;
- System.out.println(a.Init()) ;
+ System.out.println(a.Init(42, 10000, true, 156, 123)) ;
}
}
diff --git a/boil/tests/ex43.java b/boil/tests/ex43.java
new file mode 100644
index 0000000..80657d9
--- /dev/null
+++ b/boil/tests/ex43.java
@@ -0,0 +1,22 @@
+class ex43 {
+ public static void main(String[] z) {
+ A a ;
+ a = new A() ;
+ System.out.println(a.foo()) ;
+ }
+}
+
+class A {
+
+ public int foo() {
+ int v ;
+ v = 1 ;
+ if (5 < v) {
+ System.out.println(1) ;
+ } else {
+ System.out.println(0) ;
+ }
+ return v ;
+ }
+
+}