summaryrefslogtreecommitdiff
path: root/boil/library/BoilSimp.java
diff options
context:
space:
mode:
Diffstat (limited to 'boil/library/BoilSimp.java')
-rw-r--r--boil/library/BoilSimp.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/boil/library/BoilSimp.java b/boil/library/BoilSimp.java
index 0d45485..03e18fb 100644
--- a/boil/library/BoilSimp.java
+++ b/boil/library/BoilSimp.java
@@ -373,7 +373,7 @@ public class BoilSimp extends GJDepthFirst<String,String> {
*/
public String visit(Statement n, String args) {
String mod = "";
- n.f0.accept(this, args);
+ mod += n.f0.accept(this, args);
return mod;
}
@@ -422,12 +422,6 @@ public class BoilSimp extends GJDepthFirst<String,String> {
return mod;
}
- // if (t == null ) { // anonymous?
- // t = new TypeInstance(Integer.toString(this.id++), TypeEnum.classname); // FIXME maybe this is wrong for arrays?
- // t.addClassInstance(this.symt.getClass(cls));
- // }
-
-
/**
* f0 -> Identifier()
* f1 -> "["
@@ -479,11 +473,26 @@ public class BoilSimp extends GJDepthFirst<String,String> {
*/
public String visit(WhileStatement n, String args) {
String mod = "";
+ int while_id = this.id++;
+ vapor += String.format("while%d_test:\n",
+ while_id);
n.f0.accept(this, args);
n.f1.accept(this, args);
- n.f2.accept(this, args);
+ String expr = n.f2.accept(this, args);
+ vapor += String.format(" %s = %s\n",
+ this.tf.alias(Integer.toString(this.id++)),
+ expr);
+ vapor += String.format(" if0 %s goto :while%d_end\nwhile%d_body:\n",
+ this.tf.alias(Integer.toString(this.id-1)),
+ while_id,
+ while_id);
+
n.f3.accept(this, args);
n.f4.accept(this, args);
+
+ vapor += String.format(" goto :while%d_test\nwhile%d_end:\n",
+ while_id,
+ while_id);
return mod;
}
@@ -548,9 +557,13 @@ public class BoilSimp extends GJDepthFirst<String,String> {
*/
public String visit(CompareExpression n, String args) {
String mod = "";
- n.f0.accept(this, args);
+ String oper1 = n.f0.accept(this, args);
n.f1.accept(this, args);
- n.f2.accept(this, args);
+ String oper2 = n.f2.accept(this, args);
+
+ mod += String.format("LtS(%s %s)",
+ oper1,
+ oper2);
return mod;
}
@@ -675,6 +688,8 @@ public class BoilSimp extends GJDepthFirst<String,String> {
String tp1 = Integer.toString(this.id++); // TypeFactory likes to know who it's renting to
String tp2 = "tp2";
+ System.out.println("id " + id);
+ System.out.println("cur " + cur);
int mtdIndex = cur.getClassInstance().getMethods()
.indexOf(this.symt.getMethod(id2)) * 4;