diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-14 02:21:48 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-14 02:21:48 -0600 |
commit | ee60d3f9a32f75c628961f40a9bf4f1bf387ac06 (patch) | |
tree | f424f292d987f6472f9ca1f5283127797461a075 /boil/library/BoilSimp.java | |
parent | 6ecd1893b4586c7077c6969431b47ca4e0962240 (diff) |
Proper Allocation sizes for Boil VarDeclaration
Diffstat (limited to 'boil/library/BoilSimp.java')
-rw-r--r-- | boil/library/BoilSimp.java | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/boil/library/BoilSimp.java b/boil/library/BoilSimp.java index b8fee08..9e8d40a 100644 --- a/boil/library/BoilSimp.java +++ b/boil/library/BoilSimp.java @@ -160,7 +160,7 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> { } mod += "\n"; mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); + n.f3.accept(this, symt); mod += n.f4.accept(this, symt); mod += n.f5.accept(this, symt); @@ -203,8 +203,10 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> { n.f0.accept(this, symt); String id = n.f1.accept(this, symt); - mod += String.format(" %s = HeapAllocZ(32)\n", - this.tf.alias(symt.getType(id))); // FIXME add proper allocation size + TypeInstance t = symt.getType(id); + mod += String.format(" %s = HeapAllocZ(%d)\n", + this.tf.alias(t), + t.getSize()); // FIXME add proper allocation size mod += String.format(" if0 %s goto :error\n", this.tf.alias(symt.getType(id))); mod += n.f2.accept(this, symt); @@ -452,6 +454,9 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> { mod += n.f2.accept(this, symt); mod += n.f3.accept(this, symt); mod += n.f4.accept(this, symt); + + mod += String.format(" PrintIntS(%s)\n", + this.tf.retrieveRecentList(1)); return mod; } @@ -504,7 +509,7 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> { * f2 -> PrimaryExpression() */ public String visit(PlusExpression n, SymbolTable symt) { - String mod = ""; + String mod = "p"; String oper1 = n.f0.accept(this, symt); mod += n.f1.accept(this, symt); String oper2 = n.f2.accept(this, symt); @@ -617,14 +622,19 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> { mod += n.f4.accept(this, symt); mod += n.f5.accept(this, symt); - mod += String.format(" call %s(%s", - this.tf.alias(tp2), - this.tf.alias(cur)); + String call = String.format("call %s(%s", + this.tf.alias(tp2), + this.tf.alias(cur)); + + call += String.format(" %s)", + this.tf.retrieveRecentList(symt.getMethod(id2) + .getArguments() + .size())); - mod += String.format("%s)\n", - this.tf.retrieveRecentList(symt.getMethod(id2) - .getArguments() - .size())); + TypeInstance tp3 = new TypeInstance("tp3", TypeEnum.ERROR); + mod += String.format(" %s = %s\n", + this.tf.alias(tp3), + call); return mod; } |