summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boil/library/BoilSimp.java32
-rw-r--r--boil/tests/ex33.java2
-rw-r--r--st/AbstractInstance.java2
3 files changed, 24 insertions, 12 deletions
diff --git a/boil/library/BoilSimp.java b/boil/library/BoilSimp.java
index fd5b389..081b205 100644
--- a/boil/library/BoilSimp.java
+++ b/boil/library/BoilSimp.java
@@ -207,9 +207,10 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
public String visit(VarDeclaration n, SymbolTable symt) {
String mod = "";
- n.f0.accept(this, symt);
+ String cls = n.f0.accept(this, symt);
String id = n.f1.accept(this, symt);
TypeInstance t = symt.getType(id);
+
this.vapor += String.format(" %s = HeapAllocZ(%d)\n",
this.tf.alias(t),
t.getSize());
@@ -403,12 +404,23 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
attr_index += cls.getMethods().size() * 4;
n.f1.accept(this, symt);
- n.f2.accept(this, symt);
+ String expr = n.f2.accept(this, symt);
n.f3.accept(this, symt);
+ this.vapor += String.format(" [%s+%d] = %s\n",
+ this.tf.retrieveRecentList(1),
+ attr_index,
+ expr);
+
return mod;
}
+ // if (t == null ) { // anonymous?
+ // t = new TypeInstance("tp1", TypeEnum.classname); // FIXME maybe this is wrong for arrays?
+ // t.addClassInstance(symt.getClass(cls));
+ // }
+
+
/**
* f0 -> Identifier()
* f1 -> "["
@@ -638,9 +650,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));
+ // 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;
@@ -794,15 +806,13 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
String mod = "";
n.f0.accept(this, symt);
String cls = n.f1.accept(this, symt);
- vapor += String.format(" [%s+%d] = :functable_%s\n",
- this.tf.retrieveRecentList(1),
- 0,
- cls);
+ mod += String.format(":functable_%s",
+ cls);
- System.out.println(vapor);
+ // System.out.println(vapor);
n.f2.accept(this, symt);
n.f3.accept(this, symt);
- return cls;
+ return mod;
}
/**
diff --git a/boil/tests/ex33.java b/boil/tests/ex33.java
index d0eb045..d7f23ed 100644
--- a/boil/tests/ex33.java
+++ b/boil/tests/ex33.java
@@ -10,8 +10,10 @@ class ex33 {
class A {
int o ;
+ int q ;
public int foo(int a, int b) {
+ o = 3 ;
return 22 ;
}
diff --git a/st/AbstractInstance.java b/st/AbstractInstance.java
index 7214e6a..ddf7156 100644
--- a/st/AbstractInstance.java
+++ b/st/AbstractInstance.java
@@ -42,7 +42,7 @@ public abstract class AbstractInstance {
}
}
- protected void addClassInstance(ClassInstance cls) {
+ public void addClassInstance(ClassInstance cls) {
this.cls = cls;
}