summaryrefslogtreecommitdiff
path: root/boil/library/BoilSimp.java
diff options
context:
space:
mode:
Diffstat (limited to 'boil/library/BoilSimp.java')
-rw-r--r--boil/library/BoilSimp.java74
1 files changed, 45 insertions, 29 deletions
diff --git a/boil/library/BoilSimp.java b/boil/library/BoilSimp.java
index 991319f..b8fee08 100644
--- a/boil/library/BoilSimp.java
+++ b/boil/library/BoilSimp.java
@@ -204,9 +204,9 @@ 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.addNewAlias(symt.getType(id))); // FIXME add proper allocation size
+ this.tf.alias(symt.getType(id))); // FIXME add proper allocation size
mod += String.format(" if0 %s goto :error\n",
- this.tf.retrieveAlias(symt.getType(id)));
+ this.tf.alias(symt.getType(id)));
mod += n.f2.accept(this, symt);
return mod;
}
@@ -372,7 +372,7 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
String mod = "";
String id = n.f0.accept(this, symt);
- mod += String.format(" [%s] = ", this.tf.retrieveAlias(symt.getType(id)));
+ mod += String.format(" [%s] = ", this.tf.alias(symt.getType(id)));
mod += n.f1.accept(this, symt);
mod += n.f2.accept(this, symt);
mod += n.f3.accept(this, symt);
@@ -508,7 +508,6 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
String oper1 = n.f0.accept(this, symt);
mod += n.f1.accept(this, symt);
String oper2 = n.f2.accept(this, symt);
- TypeInstance tp1 = new TypeInstance("tp1", TypeEnum.ERROR);
mod += String.format("Add(%s %s)",
oper1,
@@ -524,9 +523,15 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
*/
public String visit(MinusExpression n, SymbolTable symt) {
String mod = "";
- mod += n.f0.accept(this, symt);
+ String oper1 = n.f0.accept(this, symt);
mod += n.f1.accept(this, symt);
- mod += n.f2.accept(this, symt);
+ String oper2 = n.f2.accept(this, symt);
+
+ mod += String.format("Sub(%s %s)",
+ oper1,
+ oper2);
+
+
return mod;
}
@@ -537,9 +542,15 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
*/
public String visit(TimesExpression n, SymbolTable symt) {
String mod = "";
- mod += n.f0.accept(this, symt);
+ String oper1 = n.f0.accept(this, symt);
mod += n.f1.accept(this, symt);
- mod += n.f2.accept(this, symt);
+ String oper2 = n.f2.accept(this, symt);
+
+ mod += String.format("Mul(%s %s)",
+ oper1,
+ oper2);
+
+
return mod;
}
@@ -593,35 +604,27 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
.getMethods().indexOf(symt.getMethod(id2)) * 4;
mod += String.format(" %s = [%s+%d]\n",
- this.tf.addNewAlias(tp1),
- this.tf.retrieveAlias(cur),
+ this.tf.alias(tp1),
+ this.tf.alias(cur),
0);
mod += String.format(" %s = [%s+%d]\n",
- this.tf.addNewAlias(tp2),
- this.tf.retrieveAlias(tp1),
+ this.tf.alias(tp2),
+ this.tf.alias(tp1),
mtdIndex);
mod += n.f3.accept(this, symt);
- String args = n.f4.accept(this, symt);
+ mod += n.f4.accept(this, symt);
mod += n.f5.accept(this, symt);
- TypeInstance tp3 = new TypeInstance("tp3", TypeEnum.ERROR);
-
- if (!args.isEmpty())
- mod += String.format(" %s = %s\n",
- this.tf.addNewAlias(tp3),
- args);
-
mod += String.format(" call %s(%s",
- this.tf.retrieveAlias(tp2),
- this.tf.retrieveAlias(cur));
+ this.tf.alias(tp2),
+ this.tf.alias(cur));
- if (!args.isEmpty())
- mod += String.format(" %s",
- this.tf.retrieveAlias(tp3));
-
- mod += ")\n";
+ mod += String.format("%s)\n",
+ this.tf.retrieveRecentList(symt.getMethod(id2)
+ .getArguments()
+ .size()));
return mod;
}
@@ -632,8 +635,15 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
*/
public String visit(ExpressionList n, SymbolTable symt) {
String mod = "";
- mod += n.f0.accept(this, symt);
+ String rhs = n.f0.accept(this, symt);
+ TypeInstance tp1 = new TypeInstance("tp1", TypeEnum.ERROR);
+
+ mod += String.format(" %s = %s\n",
+ this.tf.alias(tp1),
+ rhs);
+
mod += n.f1.accept(this, symt);
+
return mod;
}
@@ -644,7 +654,13 @@ public class BoilSimp extends GJDepthFirst<String,SymbolTable> {
public String visit(ExpressionRest n, SymbolTable symt) {
String mod = "";
mod += n.f0.accept(this, symt);
- mod += n.f1.accept(this, symt);
+ String rhs = n.f1.accept(this, symt);
+ TypeInstance tp1 = new TypeInstance("tp1", TypeEnum.ERROR);
+
+ mod += String.format(" %s = %s\n",
+ this.tf.alias(tp1),
+ rhs);
+
return mod;
}