diff options
Diffstat (limited to 'vaporize')
| -rw-r--r-- | vaporize/library/VaporizeSimp.java | 40 | ||||
| -rw-r--r-- | vaporize/tests_easy/ex31.java | 4 | 
2 files changed, 30 insertions, 14 deletions
| diff --git a/vaporize/library/VaporizeSimp.java b/vaporize/library/VaporizeSimp.java index a77f579..a7faf88 100644 --- a/vaporize/library/VaporizeSimp.java +++ b/vaporize/library/VaporizeSimp.java @@ -233,17 +233,18 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> {          String mod = "";          mod += n.f0.accept(this, symt); -        mod += n.f1.accept(this, symt); +        n.f1.accept(this, symt);          n.f2.accept(this, symt); -        mod += "func " + symt.getActive(TypeEnum.classname) + "_" + id + "(this)\n"; +        mod += "func " + symt.getActive(TypeEnum.classname) + "_" + id + "(this";          mod += n.f3.accept(this, symt); -        mod += n.f4.accept(this, symt); +        String args = n.f4.accept(this, symt); +        mod += String.format("%s)\n", args);          mod += n.f5.accept(this, symt);          mod += n.f6.accept(this, symt);          mod += n.f7.accept(this, symt);          mod += n.f8.accept(this, symt);          mod += n.f9.accept(this, symt); -        mod += n.f10.accept(this, symt); +        n.f10.accept(this, symt); // FIXME          mod += n.f11.accept(this, symt);          mod += n.f12.accept(this, symt); @@ -260,7 +261,9 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> {       */      public String visit(FormalParameterList n, SymbolTable symt) {          String mod = ""; -        mod += n.f0.accept(this, symt); +        String arg = n.f0.accept(this, symt); +        if (arg != null) +            mod += " " + arg;          mod += n.f1.accept(this, symt);          return mod;      } @@ -283,7 +286,9 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> {      public String visit(FormalParameterRest n, SymbolTable symt) {          String mod = "";          mod += n.f0.accept(this, symt); -        mod += n.f1.accept(this, symt); +        String arg = n.f1.accept(this, symt); +        if (arg != null) +            mod += " " + arg;          return mod;      } @@ -326,7 +331,7 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> {       */      public String visit(IntegerType n, SymbolTable symt) {          String mod = ""; -        mod += n.f0.accept(this, symt); +        mod += n.f0.accept(this, symt);;          return mod;      } @@ -500,9 +505,16 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> {       */      public String visit(PlusExpression 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); +        TypeInstance tp1 = new TypeInstance("tp1", TypeEnum.ERROR); + +        mod += String.format("  %s = AddS(%s %s)\n", +                             this.tf.addNewAlias(tp1), +                             oper1, +                             oper2); +          return mod;      } @@ -590,14 +602,14 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> {                               this.tf.retrieveAlias(tp1),                               mtdIndex); +        mod += n.f3.accept(this, symt); +        mod = n.f4.accept(this, symt); +        mod += n.f5.accept(this, symt); +          mod += String.format("  call %s(%s)\n",                               this.tf.retrieveAlias(tp2),                               this.tf.retrieveAlias(cur)); - -        mod += n.f3.accept(this, symt); -        mod += n.f4.accept(this, symt); -        mod += n.f5.accept(this, symt);          return mod;      } @@ -645,7 +657,7 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> {       */      public String visit(IntegerLiteral n, SymbolTable symt) {          String mod = ""; -        mod += n.f0.accept(this, symt); +        mod += n.f0.tokenImage;          return mod;      } diff --git a/vaporize/tests_easy/ex31.java b/vaporize/tests_easy/ex31.java index 6527b8b..d5a6980 100644 --- a/vaporize/tests_easy/ex31.java +++ b/vaporize/tests_easy/ex31.java @@ -9,4 +9,8 @@ class A {      public int foo() {          return 22 ;      } + +    public int bar() { +        return 42 ; +    }  } | 
