diff options
Diffstat (limited to 'vaporize/library')
-rw-r--r-- | vaporize/library/TypeFactory.java | 25 | ||||
-rw-r--r-- | vaporize/library/VaporizeSimp.java | 668 |
2 files changed, 294 insertions, 399 deletions
diff --git a/vaporize/library/TypeFactory.java b/vaporize/library/TypeFactory.java deleted file mode 100644 index b73862f..0000000 --- a/vaporize/library/TypeFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -package vaporize.library; - -import java.util.HashMap; -import st.TypeInstance; - -public class TypeFactory { - - private int type_num; - private HashMap<TypeInstance,String> map; - - public void reset() { - this.type_num = 0; - this.map = new HashMap<>(); - } - - public String addNewAlias(TypeInstance t) { - String alias = String.format("t.%d", this.type_num++); - this.map.put(t, alias); - return alias; - } - - public String retrieveAlias(TypeInstance t) { - return this.map.get(t); - } -} diff --git a/vaporize/library/VaporizeSimp.java b/vaporize/library/VaporizeSimp.java index a7faf88..6c69ea2 100644 --- a/vaporize/library/VaporizeSimp.java +++ b/vaporize/library/VaporizeSimp.java @@ -1,60 +1,58 @@ package vaporize.library; import syntaxtree.*; -import visitor.*; +package visitor; import st.*; import misc.*; import java.util.*; -public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { - - TypeFactory tf = new TypeFactory(); +public class VaporizeSimp<R,A> implements GJVisitor<R,A> { // // Auto class visitors--probably don't need to be overridden. // - public String visit(NodeList n, SymbolTable symt) { - String mod = ""; + public R visit(NodeList n, A argu) { + R _ret=null; int _count=0; for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) { - mod += e.nextElement().accept(this,symt); + e.nextElement().accept(this,argu); _count++; } - return mod; + return _ret; } - public String visit(NodeListOptional n, SymbolTable symt) { - String mod = ""; + public R visit(NodeListOptional n, A argu) { if ( n.present() ) { + R _ret=null; int _count=0; for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) { - mod += e.nextElement().accept(this,symt); + e.nextElement().accept(this,argu); _count++; } - return mod; + return _ret; } else - return ""; + return null; } - public String visit(NodeOptional n, SymbolTable symt) { + public R visit(NodeOptional n, A argu) { if ( n.present() ) - return n.node.accept(this,symt); + return n.node.accept(this,argu); else - return ""; + return null; } - public String visit(NodeSequence n, SymbolTable symt) { - String mod = ""; + public R visit(NodeSequence n, A argu) { + R _ret=null; int _count=0; for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) { - mod += e.nextElement().accept(this,symt); + e.nextElement().accept(this,argu); _count++; } - return mod; + return _ret; } - public String visit(NodeToken n, SymbolTable symt) { return ""; } + public R visit(NodeToken n, A argu) { return null; } // // User-generated visitor methods below @@ -65,12 +63,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> ( TypeDeclaration() )* * f2 -> <EOF> */ - public String visit(Goal n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - return mod; + public R visit(Goal n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** @@ -93,50 +91,37 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f16 -> "}" * f17 -> "}" */ - public String visit(MainClass n, SymbolTable symt) { - String id = n.f1.f0.tokenImage; - - symt.setActive(TypeEnum.classname, id); - symt.setActive(TypeEnum.method, "main"); - this.tf.reset(); - String mod = ""; - mod += "func Main()\n"; - - mod += n.f0.accept(this, symt); - n.f1.accept(this, symt); // throw class name away - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - mod += n.f4.accept(this, symt); - 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.f11.accept(this, symt); // throw boiler 'args' variable away - mod += n.f12.accept(this, symt); - mod += n.f13.accept(this, symt); - mod += n.f14.accept(this, symt); // FIXME - mod += n.f15.accept(this, symt); - mod += n.f16.accept(this, symt); - mod += n.f17.accept(this, symt); - - mod += " goto :exit\nerror:\n" + - " Error(\"Mem exhausted\")\n goto :exit\n" + - "exit:\n ret\n\n"; - - symt.removeActive(TypeEnum.method); - return mod; + public R visit(MainClass n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + n.f5.accept(this, argu); + n.f6.accept(this, argu); + n.f7.accept(this, argu); + n.f8.accept(this, argu); + n.f9.accept(this, argu); + n.f10.accept(this, argu); + n.f11.accept(this, argu); + n.f12.accept(this, argu); + n.f13.accept(this, argu); + n.f14.accept(this, argu); + n.f15.accept(this, argu); + n.f16.accept(this, argu); + n.f17.accept(this, argu); + return _ret; } /** * f0 -> ClassDeclaration() * | ClassExtendsDeclaration() */ - public String visit(TypeDeclaration n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - return mod; + public R visit(TypeDeclaration n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** @@ -147,24 +132,15 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f4 -> ( MethodDeclaration() )* * f5 -> "}" */ - public String visit(ClassDeclaration n, SymbolTable symt) { - String id = n.f1.f0.tokenImage; - symt.setActive(TypeEnum.classname, id); - String mod = ""; - - mod += n.f0.accept(this, symt); - n.f1.accept(this, symt); - mod += String.format("const functable_%s\n", id); - for (MethodInstance mtd : symt.getClass(id).getMethods()) { - mod += String.format(" :%s_%s\n", id, mtd); - } - mod += "\n"; - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - mod += n.f4.accept(this, symt); - mod += n.f5.accept(this, symt); - - return mod; + public R visit(ClassDeclaration n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + n.f5.accept(this, argu); + return _ret; } /** @@ -177,20 +153,17 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f6 -> ( MethodDeclaration() )* * f7 -> "}" */ - public String visit(ClassExtendsDeclaration n, SymbolTable symt) { - String id = n.f1.f0.tokenImage; - symt.setActive(TypeEnum.classname, id); - String mod = ""; - - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - mod += n.f4.accept(this, symt); - mod += n.f5.accept(this, symt); - mod += n.f6.accept(this, symt); - mod += n.f7.accept(this, symt); - return mod; + public R visit(ClassExtendsDeclaration n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + n.f5.accept(this, argu); + n.f6.accept(this, argu); + n.f7.accept(this, argu); + return _ret; } /** @@ -198,17 +171,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> Identifier() * f2 -> ";" */ - public String visit(VarDeclaration n, SymbolTable symt) { - String mod = ""; - - 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 - mod += String.format(" if0 %s goto :error\n", - this.tf.retrieveAlias(symt.getType(id))); - mod += n.f2.accept(this, symt); - return mod; + public R visit(VarDeclaration n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** @@ -226,70 +194,55 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f11 -> ";" * f12 -> "}" */ - public String visit(MethodDeclaration n, SymbolTable symt) { - String id = n.f2.f0.tokenImage; - symt.setActive(TypeEnum.method, id); - this.tf.reset(); - String mod = ""; - - mod += n.f0.accept(this, symt); - n.f1.accept(this, symt); - n.f2.accept(this, symt); - mod += "func " + symt.getActive(TypeEnum.classname) + "_" + id + "(this"; - mod += n.f3.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); - n.f10.accept(this, symt); // FIXME - mod += n.f11.accept(this, symt); - mod += n.f12.accept(this, symt); - - mod += " ret\n\n"; - - - symt.removeActive(TypeEnum.method); - return mod; + public R visit(MethodDeclaration n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + n.f5.accept(this, argu); + n.f6.accept(this, argu); + n.f7.accept(this, argu); + n.f8.accept(this, argu); + n.f9.accept(this, argu); + n.f10.accept(this, argu); + n.f11.accept(this, argu); + n.f12.accept(this, argu); + return _ret; } /** * f0 -> FormalParameter() * f1 -> ( FormalParameterRest() )* */ - public String visit(FormalParameterList n, SymbolTable symt) { - String mod = ""; - String arg = n.f0.accept(this, symt); - if (arg != null) - mod += " " + arg; - mod += n.f1.accept(this, symt); - return mod; + public R visit(FormalParameterList n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + return _ret; } /** * f0 -> Type() * f1 -> Identifier() */ - public String visit(FormalParameter n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - return mod; + public R visit(FormalParameter n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + return _ret; } /** * f0 -> "," * f1 -> FormalParameter() */ - public String visit(FormalParameterRest n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - String arg = n.f1.accept(this, symt); - if (arg != null) - mod += " " + arg; - return mod; + public R visit(FormalParameterRest n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + return _ret; } /** @@ -298,10 +251,10 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * | IntegerType() * | Identifier() */ - public String visit(Type n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - return mod; + public R visit(Type n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** @@ -309,30 +262,30 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> "[" * f2 -> "]" */ - public String visit(ArrayType n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - return mod; + public R visit(ArrayType n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** * f0 -> "boolean" */ - public String visit(BooleanType n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - return mod; + public R visit(BooleanType n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** * f0 -> "int" */ - public String visit(IntegerType n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt);; - return mod; + public R visit(IntegerType n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** @@ -343,10 +296,10 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * | WhileStatement() * | PrintStatement() */ - public String visit(Statement n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - return mod; + public R visit(Statement n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** @@ -354,12 +307,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> ( Statement() )* * f2 -> "}" */ - public String visit(Block n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - return mod; + public R visit(Block n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** @@ -368,15 +321,13 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f2 -> Expression() * f3 -> ";" */ - public String visit(AssignmentStatement n, SymbolTable symt) { - String mod = ""; - - String id = n.f0.accept(this, symt); - mod += String.format(" [%s] = ", this.tf.retrieveAlias(symt.getType(id))); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - return mod; + public R visit(AssignmentStatement n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + return _ret; } /** @@ -388,16 +339,16 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f5 -> Expression() * f6 -> ";" */ - public String visit(ArrayAssignmentStatement n, SymbolTable symt) { - String mod = ""; - n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - mod += n.f4.accept(this, symt); - mod += n.f5.accept(this, symt); - mod += n.f6.accept(this, symt); - return mod; + public R visit(ArrayAssignmentStatement n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + n.f5.accept(this, argu); + n.f6.accept(this, argu); + return _ret; } /** @@ -409,16 +360,16 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f5 -> "else" * f6 -> Statement() */ - public String visit(IfStatement n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - mod += n.f4.accept(this, symt); - mod += n.f5.accept(this, symt); - mod += n.f6.accept(this, symt); - return mod; + public R visit(IfStatement n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + n.f5.accept(this, argu); + n.f6.accept(this, argu); + return _ret; } /** @@ -428,14 +379,14 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f3 -> ")" * f4 -> Statement() */ - public String visit(WhileStatement n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - mod += n.f4.accept(this, symt); - return mod; + public R visit(WhileStatement n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + return _ret; } /** @@ -445,14 +396,14 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f3 -> ")" * f4 -> ";" */ - public String visit(PrintStatement n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - mod += n.f4.accept(this, symt); - return mod; + public R visit(PrintStatement n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + return _ret; } /** @@ -466,10 +417,10 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * | MessageSend() * | PrimaryExpression() */ - public String visit(Expression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - return mod; + public R visit(Expression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** @@ -477,12 +428,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> "&&" * f2 -> PrimaryExpression() */ - public String visit(AndExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - return mod; + public R visit(AndExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** @@ -490,12 +441,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> "<" * f2 -> PrimaryExpression() */ - public String visit(CompareExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - return mod; + public R visit(CompareExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** @@ -503,19 +454,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> "+" * f2 -> PrimaryExpression() */ - public String visit(PlusExpression n, SymbolTable symt) { - String mod = ""; - 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(" %s = AddS(%s %s)\n", - this.tf.addNewAlias(tp1), - oper1, - oper2); - - return mod; + public R visit(PlusExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** @@ -523,12 +467,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> "-" * f2 -> PrimaryExpression() */ - public String visit(MinusExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - return mod; + public R visit(MinusExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** @@ -536,12 +480,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> "*" * f2 -> PrimaryExpression() */ - public String visit(TimesExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - return mod; + public R visit(TimesExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** @@ -550,13 +494,13 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f2 -> PrimaryExpression() * f3 -> "]" */ - public String visit(ArrayLookup n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - return mod; + public R visit(ArrayLookup n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + return _ret; } /** @@ -564,12 +508,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> "." * f2 -> "length" */ - public String visit(ArrayLength n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - return mod; + public R visit(ArrayLength n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } /** @@ -580,59 +524,37 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f4 -> ( ExpressionList() )? * f5 -> ")" */ - public String visit(MessageSend n, SymbolTable symt) { - String mod = ""; - String id = n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - String id2 = n.f2.accept(this, symt); - TypeInstance tp1 = new TypeInstance("tp1", TypeEnum.ERROR); // TypeFactory likes to know who it's renting to - TypeInstance tp2 = new TypeInstance("tp2", TypeEnum.ERROR); - - TypeInstance cur = symt.getType(id); - int mtdIndex = cur.getClassInstance() - .getMethods().indexOf(symt.getMethod(id2)) * 4; - - mod += String.format(" %s = [%s+%d]\n", - this.tf.addNewAlias(tp1), - this.tf.retrieveAlias(cur), - 0); - - mod += String.format(" %s = [%s+%d]\n", - this.tf.addNewAlias(tp2), - 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)); - - return mod; + public R visit(MessageSend n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + n.f5.accept(this, argu); + return _ret; } /** * f0 -> Expression() * f1 -> ( ExpressionRest() )* */ - public String visit(ExpressionList n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - return mod; + public R visit(ExpressionList n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + return _ret; } /** * f0 -> "," * f1 -> Expression() */ - public String visit(ExpressionRest n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - return mod; + public R visit(ExpressionRest n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + return _ret; } /** @@ -646,55 +568,55 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * | NotExpression() * | BracketExpression() */ - public String visit(PrimaryExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - return mod; + public R visit(PrimaryExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** * f0 -> <INTEGER_LITERAL> */ - public String visit(IntegerLiteral n, SymbolTable symt) { - String mod = ""; - mod += n.f0.tokenImage; - return mod; + public R visit(IntegerLiteral n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** * f0 -> "true" */ - public String visit(TrueLiteral n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - return mod; + public R visit(TrueLiteral n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** * f0 -> "false" */ - public String visit(FalseLiteral n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - return mod; + public R visit(FalseLiteral n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** * f0 -> <IDENTIFIER> */ - public String visit(Identifier n, SymbolTable symt) { - String mod = ""; - mod += n.f0.tokenImage; - return mod; + public R visit(Identifier n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** * f0 -> "this" */ - public String visit(ThisExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - return mod; + public R visit(ThisExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + return _ret; } /** @@ -704,14 +626,14 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f3 -> Expression() * f4 -> "]" */ - public String visit(ArrayAllocationExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - mod += n.f4.accept(this, symt); - return mod; + public R visit(ArrayAllocationExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + n.f4.accept(this, argu); + return _ret; } /** @@ -720,26 +642,24 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f2 -> "(" * f3 -> ")" */ - public String visit(AllocationExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - String cls = n.f1.accept(this, symt); - mod += String.format(":functable_%s\n", cls); - - mod += n.f2.accept(this, symt); - mod += n.f3.accept(this, symt); - return mod; + public R visit(AllocationExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, argu); + return _ret; } /** * f0 -> "!" * f1 -> Expression() */ - public String visit(NotExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - return mod; + public R visit(NotExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + return _ret; } /** @@ -747,12 +667,12 @@ public class VaporizeSimp extends GJDepthFirst<String,SymbolTable> { * f1 -> Expression() * f2 -> ")" */ - public String visit(BracketExpression n, SymbolTable symt) { - String mod = ""; - mod += n.f0.accept(this, symt); - mod += n.f1.accept(this, symt); - mod += n.f2.accept(this, symt); - return mod; + public R visit(BracketExpression n, A argu) { + R _ret=null; + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + return _ret; } } |