diff options
Diffstat (limited to 'boil/library/BoilVisitor.java')
-rw-r--r-- | boil/library/BoilVisitor.java | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/boil/library/BoilVisitor.java b/boil/library/BoilVisitor.java index eb47432..5633eb8 100644 --- a/boil/library/BoilVisitor.java +++ b/boil/library/BoilVisitor.java @@ -553,12 +553,24 @@ public class BoilVisitor extends GJDepthFirst<String,String> { arrID, arr)); - int index = Integer.parseInt(n.f2.accept(this, argu)) * 4 + 4; + String indexID = this.tf.alias(this.getUniqueID()); + this.addVapor(String.format(" %s = MulS(%s %s)\n", + indexID, + n.f2.accept(this, argu), + 4)); + this.addVapor(String.format(" %s = Add(%s %s)\n", + indexID, + indexID, + 4)); + this.addVapor(String.format(" %s = Add(%s %s)\n", + indexID, + arrID, + indexID)); + String expr = n.f5.accept(this, argu); - this.addVapor(String.format(" [%s+%d] = %s\n", - arrID, - index, + this.addVapor(String.format(" [%s] = %s\n", + indexID, expr)); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", @@ -715,7 +727,7 @@ public class BoilVisitor extends GJDepthFirst<String,String> { _ret += this.tf.alias(this.getUniqueID()); /////////////////////////////////////////////////////////////// String oper1 = this.memoryRead(n.f0.accept(this, argu)); - String oper2 = this.memoryRead(n.f2.accept(this, argu)); + String oper2 = this.memoryRead(n.f2.accept(this, argu)); this.addVapor(String.format(" %s = Eq(%s %s)\n", _ret, oper1, @@ -842,14 +854,25 @@ public class BoilVisitor extends GJDepthFirst<String,String> { /////////////////////////////////////////////////////////////// String arrID = this.tf.alias(this.getUniqueID()); String arr = n.f0.accept(this, argu); - int index = Integer.parseInt(n.f2.accept(this, argu)) * 4 + 4; + String indexID = this.tf.alias(this.getUniqueID()); this.addVapor(String.format(" %s = %s\n", arrID, arr)); - this.addVapor(String.format(" %s = [%s+%d]\n", - _ret, + this.addVapor(String.format(" %s = MulS(%s %s)\n", + indexID, + n.f2.accept(this, argu), + 4)); + this.addVapor(String.format(" %s = Add(%s %s)\n", + indexID, + indexID, + 4)); + this.addVapor(String.format(" %s = Add(%s %s)\n", + indexID, arrID, - index)); + indexID)); + this.addVapor(String.format(" %s = [%s]\n", + _ret, + indexID)); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", n.getClass().getSimpleName(), |