diff options
-rw-r--r-- | boil/library/BoilSimp.java | 46 | ||||
-rw-r--r-- | misc/PrintFilter.java | 2 |
2 files changed, 32 insertions, 16 deletions
diff --git a/boil/library/BoilSimp.java b/boil/library/BoilSimp.java index 03e18fb..4de7633 100644 --- a/boil/library/BoilSimp.java +++ b/boil/library/BoilSimp.java @@ -216,14 +216,14 @@ public class BoilSimp extends GJDepthFirst<String,String> { String mod = ""; String cls = n.f0.accept(this, args); - String id = n.f1.accept(this, args); + String id = n.f1.f0.tokenImage; TypeInstance t = this.symt.getType(id); this.vapor += String.format(" %s = HeapAllocZ(%d)\n", this.tf.alias(t.getName()), t.getSize()); - this.vapor += String.format(" if0 %s goto :error\n", - this.tf.alias(this.symt.getType(id).getName())); + // this.vapor += String.format(" if0 %s goto :error\n", + // this.tf.alias(this.symt.getType(id).getName())); n.f2.accept(this, args); return mod; } @@ -274,6 +274,13 @@ public class BoilSimp extends GJDepthFirst<String,String> { n.f11.accept(this, args); n.f12.accept(this, args); + // minor cleanup + if (n.f10.f0.which == 8 && // primary expression + ((PrimaryExpression) n.f10.f0.choice).f0.which == 3) + ret = String.format("[%s+%d]", + ret, + 0); + this.vapor += String.format(" %s = %s\n ret %s\n\n", this.tf.alias(Integer.toString(this.id++)), ret, @@ -661,35 +668,45 @@ public class BoilSimp extends GJDepthFirst<String,String> { */ public String visit(MessageSend n, String args) { String mod = ""; - String id = n.f0.accept(this, args); // gross code was required to create proper types + classes for anonymous classes... + String id; TypeInstance cur; ClassInstance cls; - if (this.symt.getType(id) != null) { + switch (n.f0.f0.which) { + case 3: + id = ((Identifier) n.f0.f0.choice).f0.tokenImage; cur = this.symt.getType(id); - } else { + break; + case 6: + id = n.f0.accept(this, args); cur = new TypeInstance(Integer.toString(this.id++), TypeEnum.ERROR); cur.addClassInstance(this.symt.getClass(id.substring(id.indexOf('_')+1))); this.vapor += String.format(" %s = HeapAllocZ(%d)\n", this.tf.alias(cur.getName()), cur.getSize()); - this.vapor += String.format(" if0 %s goto :error\n", - this.tf.alias(cur.getName())); + // this.vapor += String.format(" if0 %s goto :error\n", + // this.tf.alias(cur.getName())); this.vapor += String.format(" [%s+%d] = %s\n", this.tf.alias(cur.getName()), 0, id); + break; + default: + System.out.println("ERROR! MessageSend is not implemented for passed case! :("); + id = null; + cur = null; } + n.f1.accept(this, args); - String id2 = n.f2.accept(this, args); + String id2 = n.f2.f0.tokenImage; 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); + // System.out.println("id " + id); + // System.out.println("cur " + cur); int mtdIndex = cur.getClassInstance().getMethods() .indexOf(this.symt.getMethod(id2)) * 4; @@ -801,8 +818,7 @@ public class BoilSimp extends GJDepthFirst<String,String> { */ public String visit(Identifier n, String args) { String mod = ""; - mod += n.f0.tokenImage; - return mod; + return this.tf.alias(n.f0.tokenImage); } /** @@ -840,9 +856,9 @@ public class BoilSimp extends GJDepthFirst<String,String> { public String visit(AllocationExpression n, String args) { String mod = ""; n.f0.accept(this, args); - String cls = n.f1.accept(this, args); + n.f1.accept(this, args); mod += String.format(":functable_%s", - cls); + n.f1.f0.tokenImage); // System.out.println(vapor); n.f2.accept(this, args); diff --git a/misc/PrintFilter.java b/misc/PrintFilter.java index 971ef04..e3be310 100644 --- a/misc/PrintFilter.java +++ b/misc/PrintFilter.java @@ -4,7 +4,7 @@ package misc; public class PrintFilter { public static void print(String message, boolean newline) { - boolean debug = true; + boolean debug = false; if (debug) { System.out.print(message); if (newline) |