diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-09 21:51:27 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-09 21:51:27 -0600 |
commit | c1e124b957fa840f7bd8da9ffc6871140cfabf16 (patch) | |
tree | 46140a2cad0b9ff95ed0e5728b47bb1c46d1cca5 /vaporize/library | |
parent | 0de1debf8b72c460d6974de8a8ab9cbbdeecb160 (diff) |
Finished Vaporize.MessageSend
Diffstat (limited to 'vaporize/library')
-rw-r--r-- | vaporize/library/TypeFactory.java | 2 | ||||
-rw-r--r-- | vaporize/library/VaporizeSimp.java | 26 |
2 files changed, 25 insertions, 3 deletions
diff --git a/vaporize/library/TypeFactory.java b/vaporize/library/TypeFactory.java index 0166e3c..b73862f 100644 --- a/vaporize/library/TypeFactory.java +++ b/vaporize/library/TypeFactory.java @@ -14,7 +14,7 @@ public class TypeFactory { } public String addNewAlias(TypeInstance t) { - String alias = String.format("t.%d", type_num); + String alias = String.format("t.%d", this.type_num++); this.map.put(t, alias); return alias; } 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<String,SymbolTable> { */ 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); |