summaryrefslogtreecommitdiff
path: root/vaporize
diff options
context:
space:
mode:
Diffstat (limited to 'vaporize')
-rw-r--r--vaporize/library/ControlFlowGraph.java42
-rw-r--r--vaporize/library/VaporizeSimp.java678
2 files changed, 42 insertions, 678 deletions
diff --git a/vaporize/library/ControlFlowGraph.java b/vaporize/library/ControlFlowGraph.java
new file mode 100644
index 0000000..0153b38
--- /dev/null
+++ b/vaporize/library/ControlFlowGraph.java
@@ -0,0 +1,42 @@
+package vaporize.library;
+
+import cs132.vapor.ast.*;
+import st.*;
+import misc.*;
+import java.util.*;
+
+public class ControlFlowGraph<P, R> extends VInstr.VisitorPR<P, R, RuntimeException> {
+
+ public R visit(P p, VMemRead r) throws RuntimeException {
+ return null;
+ }
+
+ public R visit(P p, VMemWrite w) throws RuntimeException {
+ return null;
+ }
+
+ public R visit(P p, VAssign a) throws RuntimeException {
+ return null;
+ }
+
+ public R visit(P p, VBranch b) throws RuntimeException {
+ return null;
+ }
+
+ public R visit(P p, VGoto g) throws RuntimeException {
+ return null;
+ }
+
+ public R visit(P p, VCall c) throws RuntimeException {
+ return null;
+ }
+
+ public R visit(P p, VBuiltIn c) throws RuntimeException {
+ return null;
+ }
+
+ public R visit(P p, VReturn r) throws RuntimeException {
+ return null;
+ }
+
+}
diff --git a/vaporize/library/VaporizeSimp.java b/vaporize/library/VaporizeSimp.java
deleted file mode 100644
index 6c69ea2..0000000
--- a/vaporize/library/VaporizeSimp.java
+++ /dev/null
@@ -1,678 +0,0 @@
-package vaporize.library;
-
-import syntaxtree.*;
-package visitor;
-import st.*;
-import misc.*;
-import java.util.*;
-
-public class VaporizeSimp<R,A> implements GJVisitor<R,A> {
-
- //
- // Auto class visitors--probably don't need to be overridden.
- //
- public R visit(NodeList n, A argu) {
- R _ret=null;
- int _count=0;
- for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
- e.nextElement().accept(this,argu);
- _count++;
- }
- return _ret;
- }
-
- public R visit(NodeListOptional n, A argu) {
- if ( n.present() ) {
- R _ret=null;
- int _count=0;
- for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
- e.nextElement().accept(this,argu);
- _count++;
- }
- return _ret;
- }
- else
- return null;
- }
-
- public R visit(NodeOptional n, A argu) {
- if ( n.present() )
- return n.node.accept(this,argu);
- else
- return null;
- }
-
- public R visit(NodeSequence n, A argu) {
- R _ret=null;
- int _count=0;
- for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
- e.nextElement().accept(this,argu);
- _count++;
- }
- return _ret;
- }
-
- public R visit(NodeToken n, A argu) { return null; }
-
- //
- // User-generated visitor methods below
- //
-
- /**
- * f0 -> MainClass()
- * f1 -> ( TypeDeclaration() )*
- * f2 -> <EOF>
- */
- 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;
- }
-
- /**
- * f0 -> "class"
- * f1 -> Identifier()
- * f2 -> "{"
- * f3 -> "public"
- * f4 -> "static"
- * f5 -> "void"
- * f6 -> "main"
- * f7 -> "("
- * f8 -> "String"
- * f9 -> "["
- * f10 -> "]"
- * f11 -> Identifier()
- * f12 -> ")"
- * f13 -> "{"
- * f14 -> ( VarDeclaration() )*
- * f15 -> ( Statement() )*
- * f16 -> "}"
- * f17 -> "}"
- */
- 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 R visit(TypeDeclaration n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> "class"
- * f1 -> Identifier()
- * f2 -> "{"
- * f3 -> ( VarDeclaration() )*
- * f4 -> ( MethodDeclaration() )*
- * f5 -> "}"
- */
- 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;
- }
-
- /**
- * f0 -> "class"
- * f1 -> Identifier()
- * f2 -> "extends"
- * f3 -> Identifier()
- * f4 -> "{"
- * f5 -> ( VarDeclaration() )*
- * f6 -> ( MethodDeclaration() )*
- * f7 -> "}"
- */
- 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;
- }
-
- /**
- * f0 -> Type()
- * f1 -> Identifier()
- * f2 -> ";"
- */
- 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;
- }
-
- /**
- * f0 -> "public"
- * f1 -> Type()
- * f2 -> Identifier()
- * f3 -> "("
- * f4 -> ( FormalParameterList() )?
- * f5 -> ")"
- * f6 -> "{"
- * f7 -> ( VarDeclaration() )*
- * f8 -> ( Statement() )*
- * f9 -> "return"
- * f10 -> Expression()
- * f11 -> ";"
- * f12 -> "}"
- */
- 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 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 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 R visit(FormalParameterRest n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- n.f1.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> ArrayType()
- * | BooleanType()
- * | IntegerType()
- * | Identifier()
- */
- public R visit(Type n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> "int"
- * f1 -> "["
- * f2 -> "]"
- */
- 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 R visit(BooleanType n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> "int"
- */
- public R visit(IntegerType n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> Block()
- * | AssignmentStatement()
- * | ArrayAssignmentStatement()
- * | IfStatement()
- * | WhileStatement()
- * | PrintStatement()
- */
- public R visit(Statement n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> "{"
- * f1 -> ( Statement() )*
- * f2 -> "}"
- */
- 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;
- }
-
- /**
- * f0 -> Identifier()
- * f1 -> "="
- * f2 -> Expression()
- * f3 -> ";"
- */
- 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;
- }
-
- /**
- * f0 -> Identifier()
- * f1 -> "["
- * f2 -> Expression()
- * f3 -> "]"
- * f4 -> "="
- * f5 -> Expression()
- * f6 -> ";"
- */
- 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;
- }
-
- /**
- * f0 -> "if"
- * f1 -> "("
- * f2 -> Expression()
- * f3 -> ")"
- * f4 -> Statement()
- * f5 -> "else"
- * f6 -> Statement()
- */
- 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;
- }
-
- /**
- * f0 -> "while"
- * f1 -> "("
- * f2 -> Expression()
- * f3 -> ")"
- * f4 -> Statement()
- */
- 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;
- }
-
- /**
- * f0 -> "System.out.println"
- * f1 -> "("
- * f2 -> Expression()
- * f3 -> ")"
- * f4 -> ";"
- */
- 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;
- }
-
- /**
- * f0 -> AndExpression()
- * | CompareExpression()
- * | PlusExpression()
- * | MinusExpression()
- * | TimesExpression()
- * | ArrayLookup()
- * | ArrayLength()
- * | MessageSend()
- * | PrimaryExpression()
- */
- public R visit(Expression n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> PrimaryExpression()
- * f1 -> "&&"
- * f2 -> PrimaryExpression()
- */
- 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;
- }
-
- /**
- * f0 -> PrimaryExpression()
- * f1 -> "<"
- * f2 -> PrimaryExpression()
- */
- 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;
- }
-
- /**
- * f0 -> PrimaryExpression()
- * f1 -> "+"
- * f2 -> PrimaryExpression()
- */
- 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;
- }
-
- /**
- * f0 -> PrimaryExpression()
- * f1 -> "-"
- * f2 -> PrimaryExpression()
- */
- 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;
- }
-
- /**
- * f0 -> PrimaryExpression()
- * f1 -> "*"
- * f2 -> PrimaryExpression()
- */
- 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;
- }
-
- /**
- * f0 -> PrimaryExpression()
- * f1 -> "["
- * f2 -> PrimaryExpression()
- * f3 -> "]"
- */
- 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;
- }
-
- /**
- * f0 -> PrimaryExpression()
- * f1 -> "."
- * f2 -> "length"
- */
- 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;
- }
-
- /**
- * f0 -> PrimaryExpression()
- * f1 -> "."
- * f2 -> Identifier()
- * f3 -> "("
- * f4 -> ( ExpressionList() )?
- * f5 -> ")"
- */
- 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 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 R visit(ExpressionRest n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- n.f1.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> IntegerLiteral()
- * | TrueLiteral()
- * | FalseLiteral()
- * | Identifier()
- * | ThisExpression()
- * | ArrayAllocationExpression()
- * | AllocationExpression()
- * | NotExpression()
- * | BracketExpression()
- */
- public R visit(PrimaryExpression n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> <INTEGER_LITERAL>
- */
- public R visit(IntegerLiteral n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> "true"
- */
- public R visit(TrueLiteral n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> "false"
- */
- public R visit(FalseLiteral n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> <IDENTIFIER>
- */
- public R visit(Identifier n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> "this"
- */
- public R visit(ThisExpression n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> "new"
- * f1 -> "int"
- * f2 -> "["
- * f3 -> Expression()
- * f4 -> "]"
- */
- 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;
- }
-
- /**
- * f0 -> "new"
- * f1 -> Identifier()
- * f2 -> "("
- * f3 -> ")"
- */
- 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 R visit(NotExpression n, A argu) {
- R _ret=null;
- n.f0.accept(this, argu);
- n.f1.accept(this, argu);
- return _ret;
- }
-
- /**
- * f0 -> "("
- * f1 -> Expression()
- * f2 -> ")"
- */
- 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;
- }
-
-}