summaryrefslogtreecommitdiff
path: root/boil/library/BoilSimp.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-15 22:30:43 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-15 22:30:43 -0600
commit3415badef847db518daa9b46c6274ac3fb89f56d (patch)
treeb32c7d9408416dab208d7670fd51da47710efad8 /boil/library/BoilSimp.java
parent4d8e11688a54ef6b2cf0ba85f7879b5d8dbeec48 (diff)
HW3 Test runner script
Diffstat (limited to 'boil/library/BoilSimp.java')
-rw-r--r--boil/library/BoilSimp.java46
1 files changed, 33 insertions, 13 deletions
diff --git a/boil/library/BoilSimp.java b/boil/library/BoilSimp.java
index 9a69b2c..fd5b389 100644
--- a/boil/library/BoilSimp.java
+++ b/boil/library/BoilSimp.java
@@ -166,7 +166,7 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
}
this.vapor += "\n";
n.f2.accept(this, symt);
- n.f3.accept(this, symt);
+ // n.f3.accept(this, symt);
n.f4.accept(this, symt);
n.f5.accept(this, symt);
@@ -212,7 +212,7 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
TypeInstance t = symt.getType(id);
this.vapor += String.format(" %s = HeapAllocZ(%d)\n",
this.tf.alias(t),
- t.getSize()); // FIXME add proper allocation size
+ t.getSize());
this.vapor += String.format(" if0 %s goto :error\n",
this.tf.alias(symt.getType(id)));
n.f2.accept(this, symt);
@@ -254,19 +254,22 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
for (TypeInstance attr : symt.getMethod(id)
.getClassInstance()
.getLocals()) {
- String.format(" %s = this\n",
- this.tf.alias(attr));
+ this.vapor += String.format(" %s = this\n",
+ this.tf.alias(attr));
}
n.f7.accept(this, symt);
n.f8.accept(this, symt);
n.f9.accept(this, symt);
- n.f10.accept(this, symt); // FIXME
+ String ret = n.f10.accept(this, symt); // FIXME
n.f11.accept(this, symt);
n.f12.accept(this, symt);
- this.vapor += " ret\n\n";
-
+ TypeInstance tp1 = new TypeInstance("tp1", TypeEnum.ERROR);
+ this.vapor += String.format(" %s = %s\n ret %s\n\n",
+ this.tf.alias(tp1),
+ ret,
+ this.tf.alias(tp1));
symt.removeActive(TypeEnum.method);
return mod;
@@ -389,10 +392,20 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
String mod = "";
String id = n.f0.accept(this, symt);
- vapor += String.format(" [%s] = ", this.tf.alias(symt.getType(id)));
+
+ ClassInstance cls;
+ int attr_index = (cls = symt.getClass(symt.getActive(TypeEnum.classname)))
+ .getLocals().indexOf(symt.getType(id)) * 4;
+
+ if (attr_index < 0)
+ attr_index = 0;
+ else
+ attr_index += cls.getMethods().size() * 4;
+
n.f1.accept(this, symt);
- vapor += n.f2.accept(this, symt);
+ n.f2.accept(this, symt);
n.f3.accept(this, symt);
+
return mod;
}
@@ -472,8 +485,8 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
TypeInstance tp1 = new TypeInstance("tp1", TypeEnum.ERROR);
vapor += String.format(" %s = %s\n",
- this.tf.alias(tp1),
- expr);
+ this.tf.alias(tp1),
+ expr);
vapor += String.format(" PrintIntS(%s)\n",
this.tf.retrieveRecentList(1));
@@ -625,6 +638,9 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
TypeInstance cur = symt.getType(id);
+ System.out.println("id: " + id);
+ System.out.println("id2: " + id2);
+ System.out.println("cur: " + symt.getType(id));
int mtdIndex = cur.getClassInstance()
.getMethods().indexOf(symt.getMethod(id2)) * 4;
@@ -778,11 +794,15 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
String mod = "";
n.f0.accept(this, symt);
String cls = n.f1.accept(this, symt);
- mod += String.format(":functable_%s\n", cls);
+ vapor += String.format(" [%s+%d] = :functable_%s\n",
+ this.tf.retrieveRecentList(1),
+ 0,
+ cls);
+ System.out.println(vapor);
n.f2.accept(this, symt);
n.f3.accept(this, symt);
- return mod;
+ return cls;
}
/**