summaryrefslogtreecommitdiff
path: root/boil/library/BoilSimp.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-17 21:32:16 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-17 21:32:16 -0600
commitf121f24a80d49e9bacb890d729f0ae64047ed6d8 (patch)
treee6c879a9f6db1ce4676e8aff66b26e5ea8c46784 /boil/library/BoilSimp.java
parenta2629207350dbad42251431e58bace2ff333d613 (diff)
Alias each class variable to a temporary in BoilSimp.MethodDeclaration
Diffstat (limited to 'boil/library/BoilSimp.java')
-rw-r--r--boil/library/BoilSimp.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/boil/library/BoilSimp.java b/boil/library/BoilSimp.java
index 8d36c8e..6d8e401 100644
--- a/boil/library/BoilSimp.java
+++ b/boil/library/BoilSimp.java
@@ -275,11 +275,16 @@ public class BoilSimp extends GJDepthFirst<String,String> {
n.f6.accept(this, args);
// spill out all class attributes, if they're not used, who cares
- for (TypeInstance attr : this.symt.getMethod(id)
- .getClassInstance()
- .getLocals()) {
- this.vapor += String.format(" %s = this\n",
- this.tf.alias(attr.getName()));
+ this.vapor += String.format(" %s = this\n",
+ this.tf.alias(Integer.toString(this.id++)));
+ ClassInstance parent = this.symt.getMethod(id).getClassInstance();
+ int attr_index = parent.getMethods().size() * 4;
+ for (TypeInstance attr : parent.getLocals()) {
+ this.vapor += String.format(" %s = [%s+%d]\n",
+ this.tf.alias(attr.getName()),
+ this.tf.alias(Integer.toString(this.id-1)),
+ attr_index);
+ attr_index += 4;
}
n.f7.accept(this, args);
@@ -296,7 +301,6 @@ public class BoilSimp extends GJDepthFirst<String,String> {
TypeInstance sym = this.symt.getType(((Identifier) ((PrimaryExpression) n.f10.f0.choice).f0.choice).f0.tokenImage);
ClassInstance cls = symt.getClass(symt.getActive(TypeEnum.classname));
- int attr_index;
if ((attr_index = this.getVarIndex(cls, sym)) >=0) {
ret = String.format("[%s+%d]",
ret,
@@ -440,9 +444,7 @@ public class BoilSimp extends GJDepthFirst<String,String> {
ClassInstance cls = this.symt.getClass(this.symt.getActive(TypeEnum.classname));
int attr_index = 0;
- if (expr.contains("functable") || // is this an allocation... :)
- (attr_index = this.getVarIndex(cls, t)) >=0
-
+ if (expr.contains("functable") // is this an allocation... :)
) {
lhs = String.format("[%s+%d]",
lhs,