From 15569878d1e95aa0d8fcd61a84aba6f0c33efa22 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Tue, 23 Apr 2024 16:28:24 -0600 Subject: Allow "this" use in message send to call correct method --- boil/library/BoilVisitor.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'boil') 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 { // 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 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", -- cgit v1.2.3