diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-17 23:43:31 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-17 23:43:31 -0600 |
commit | 837dbf613bb571bac5c9e48ffe5865425e6b9fee (patch) | |
tree | 67dd2409f464dd1e358fa7aea7c0cc0d3dde7a06 /boil/library | |
parent | 950155889fbb028322a11c711942c7feef234491 (diff) |
Basic, ugly "this" support in BoilSimp
Diffstat (limited to 'boil/library')
-rw-r--r-- | boil/library/BoilSimp.java | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/boil/library/BoilSimp.java b/boil/library/BoilSimp.java index e5c622c..febaa20 100644 --- a/boil/library/BoilSimp.java +++ b/boil/library/BoilSimp.java @@ -716,10 +716,11 @@ public class BoilSimp extends GJDepthFirst<String,String> { * f5 -> ")" */ public String visit(MessageSend n, String args) { + // if you have to read this, good luck String mod = ""; - // gross code was required to create proper types + classes for anonymous classes... String id; + String id2 = n.f2.f0.tokenImage; TypeInstance cur; ClassInstance cls; switch (n.f0.f0.which) { @@ -727,6 +728,20 @@ public class BoilSimp extends GJDepthFirst<String,String> { id = ((Identifier) n.f0.f0.choice).f0.tokenImage; cur = this.symt.getType(id); break; + case 4: + id = n.f0.accept(this, args); + String call_tmp = this.tf.alias(Integer.toString(this.id++)); + this.vapor += n.f4.accept(this, args); + vapor += String.format(" %s = call %s(this", + call_tmp, + id); + + vapor += String.format(" %s)\n", + this.tf.retrieveRecentList(this.symt.getMethod(id2) + .getArguments() + .size())); + + return call_tmp; case 6: id = n.f0.accept(this, args); cur = new TypeInstance(Integer.toString(this.id++), TypeEnum.ERROR); @@ -750,9 +765,8 @@ public class BoilSimp extends GJDepthFirst<String,String> { } n.f1.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"; + String tp2 = Integer.toString(this.id++); // System.out.println("id " + id); // System.out.println("cur " + cur); @@ -875,7 +889,13 @@ public class BoilSimp extends GJDepthFirst<String,String> { */ public String visit(ThisExpression n, String args) { String mod = ""; - n.f0.accept(this, args); + vapor += String.format(" %s = [this]\n", + this.tf.alias(Integer.toString(this.id++))); + vapor += String.format(" %s = [%s+%d]\n", + this.tf.alias(Integer.toString(this.id-1)), + this.tf.alias(Integer.toString(this.id-1)), + 0); + mod += this.tf.alias(Integer.toString(this.id-1)); return mod; } @@ -934,7 +954,7 @@ public class BoilSimp extends GJDepthFirst<String,String> { public String visit(BracketExpression n, String args) { String mod = ""; n.f0.accept(this, args); - n.f1.accept(this, args); + mod += n.f1.accept(this, args); n.f2.accept(this, args); return mod; } |