From c1e124b957fa840f7bd8da9ffc6871140cfabf16 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Tue, 9 Apr 2024 21:51:27 -0600 Subject: Finished Vaporize.MessageSend --- vaporize/library/VaporizeSimp.java | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'vaporize/library/VaporizeSimp.java') diff --git a/vaporize/library/VaporizeSimp.java b/vaporize/library/VaporizeSimp.java index 44121a9..a77f579 100644 --- a/vaporize/library/VaporizeSimp.java +++ b/vaporize/library/VaporizeSimp.java @@ -570,9 +570,31 @@ public class VaporizeSimp extends GJDepthFirst { */ public String visit(MessageSend n, SymbolTable symt) { String mod = ""; - mod += n.f0.accept(this, symt); + String id = n.f0.accept(this, symt); mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); + String id2 = n.f2.accept(this, symt); + TypeInstance tp1 = new TypeInstance("tp1", TypeEnum.ERROR); // TypeFactory likes to know who it's renting to + TypeInstance tp2 = new TypeInstance("tp2", TypeEnum.ERROR); + + TypeInstance cur = symt.getType(id); + int mtdIndex = cur.getClassInstance() + .getMethods().indexOf(symt.getMethod(id2)) * 4; + + mod += String.format(" %s = [%s+%d]\n", + this.tf.addNewAlias(tp1), + this.tf.retrieveAlias(cur), + 0); + + mod += String.format(" %s = [%s+%d]\n", + this.tf.addNewAlias(tp2), + this.tf.retrieveAlias(tp1), + mtdIndex); + + mod += String.format(" call %s(%s)\n", + this.tf.retrieveAlias(tp2), + this.tf.retrieveAlias(cur)); + + mod += n.f3.accept(this, symt); mod += n.f4.accept(this, symt); mod += n.f5.accept(this, symt); -- cgit v1.2.3