diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-17 15:38:56 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-17 15:38:56 -0600 |
commit | 3b1571fd410096eb20a9af9ebcee124ff1ea8eac (patch) | |
tree | 13e1f50d0f68d63ecb1fff14cf9d0091a691e3f5 /boil | |
parent | 6d68e534aa53f3879ebc8a4f5803e468dc86a6bc (diff) |
Allow CFG to compile by removing generic types
Diffstat (limited to 'boil')
-rw-r--r-- | boil/library/BoilSimp.java | 35 |
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; |