diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-23 16:28:24 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-23 16:28:24 -0600 |
commit | 15569878d1e95aa0d8fcd61a84aba6f0c33efa22 (patch) | |
tree | 4077854660be60b50b71c460c4d9773ab3592f32 | |
parent | 3260ca09b23f197f408e686e8e2dd964d2ea9152 (diff) |
Allow "this" use in message send to call correct method
-rw-r--r-- | boil/library/BoilVisitor.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/boil/library/BoilVisitor.java b/boil/library/BoilVisitor.java index bdcb8de..83b1fd3 100644 --- a/boil/library/BoilVisitor.java +++ b/boil/library/BoilVisitor.java @@ -850,7 +850,16 @@ public class BoilVisitor extends GJDepthFirst<String,String> { // we'll do everything here and exit the function MinimalLogger.info("Message send found THIS"); rhs = n.f0.accept(this, argu); + ClassInstance cur = this.symt.getClass(this.symt.getActive(TypeEnum.classname)); + MinimalLogger.info("Calculating method index to call..."); + int mtdIndex = cur.getMethods() + .indexOf(this.symt.getMethod(mtd)) * 4; + this.addVapor(n.f4.accept(this, argu)); + this.addVapor(String.format(" %s = [%s+%d]\n", + rhs, + rhs, + mtdIndex)); this.addVapor(String.format(" %s = call %s(this", _ret, rhs)); @@ -1056,10 +1065,6 @@ public class BoilVisitor extends GJDepthFirst<String,String> { String thisID = this.tf.alias(this.getUniqueID()); this.addVapor(String.format(" %s = [this]\n", thisID)); - this.addVapor(String.format(" %s = [%s+%d]\n", - thisID, - thisID, - 0)); _ret += thisID; /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", |