diff --git a/src/de/dhbwstuttgart/syntaxtree/StatementVisitor.java b/src/de/dhbwstuttgart/syntaxtree/StatementVisitor.java new file mode 100644 index 000000000..3f8072b5b --- /dev/null +++ b/src/de/dhbwstuttgart/syntaxtree/StatementVisitor.java @@ -0,0 +1,63 @@ +package de.dhbwstuttgart.syntaxtree; + +import de.dhbwstuttgart.syntaxtree.statement.*; +import de.dhbwstuttgart.syntaxtree.statement.literal.Literal; +import de.dhbwstuttgart.syntaxtree.statement.literal.Null; +import de.dhbwstuttgart.syntaxtree.statement.literal.StringLiteral; + +public interface StatementVisitor { + + void visit(LambdaExpression lambdaExpression); + + void visit(Assign assign); + + void visit(Binary binary); + + void visit(Block block); + + void visit(CastExpr castExpr); + + void visit(EmptyStmt emptyStmt); + + void visit(FieldVar fieldVar); + + void visit(ForStmt forStmt); + + void visit(IfStmt ifStmt); + + void visit(InstanceOf instanceOf); + + void visit(InstVar instVar); + + void visit(LocalVar localVar); + + void visit(LocalVarDecl localVarDecl); + + void visit(MethodCall methodCall); + + void visit(NewClass methodCall); + + void visit(NewArray newArray); + + void visit(Receiver receiver); + + void visit(Return aReturn); + + void visit(ReturnVoid aReturn); + + void visit(StaticClassName staticClassName); + + void visit(Super aSuper); + + void visit(This aThis); + + void visit(UnaryPlus unaryPlus); + + void visit(WhileStmt whileStmt); + + void visit(LocalVarBunchDeclaration localVarBunchDeclaration); + + void visit(Null aNull); + + void visit(Literal literal); +} diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java index ae536e812..0e2f49f2e 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.ConstraintsFactory; @@ -27,4 +28,9 @@ public class Assign extends Statement rightSide.getType(), lefSide.getType(), PairOperator.SMALLERDOT, info)); return ret; } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java b/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java index 6bc137c20..766ce0c7b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; @@ -19,4 +20,9 @@ public class Binary extends Expression public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java index 04e4a1066..504b94b39 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.*; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; @@ -31,6 +32,11 @@ public class Block extends Statement } return ret; } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java index f65c6880c..158cdf886 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; @@ -21,4 +22,9 @@ public class CastExpr extends Expression public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java index 1ae2df748..4dced5403 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.Void; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; @@ -19,4 +20,9 @@ public class EmptyStmt extends Statement public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { return new ConstraintSet(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Expression.java b/src/de/dhbwstuttgart/syntaxtree/statement/Expression.java index cb15d4098..23fb0e5db 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Expression.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Expression.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; @@ -22,4 +23,6 @@ public abstract class Expression extends SyntaxTreeNode } public abstract ConstraintSet getConstraints(TypeInferenceBlockInformation info); + + public abstract void accept(StatementVisitor visitor); } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/FieldVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/FieldVar.java index 13274065d..b782f9a09 100644 --- a/src/de/dhbwstuttgart/syntaxtree/statement/FieldVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/FieldVar.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.TypeinferenceException; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.FieldAssumption; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; @@ -42,4 +43,9 @@ public class FieldVar extends Expression { ret.addOderConstraint(oderConstraints); return ret; } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java index 2f20bd23a..703958dd2 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java @@ -2,6 +2,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; @@ -26,4 +27,9 @@ public class ForStmt extends Statement public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } \ No newline at end of file diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java index ec4145b91..858ae2989 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; @@ -21,4 +22,9 @@ public class IfStmt extends Statement public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { return null; } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java index 5ed2ee8e8..21270e7dd 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; @@ -20,4 +21,9 @@ public class InstVar extends Expression public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java b/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java index a22d33135..2b816e816 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; @@ -21,4 +22,9 @@ public class InstanceOf extends BinaryExpr public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java index cf263ed0b..cb663efe3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java @@ -1,9 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement; -import de.dhbwstuttgart.syntaxtree.FormalParameter; -import de.dhbwstuttgart.syntaxtree.GenericTypeVar; -import de.dhbwstuttgart.syntaxtree.ParameterList; -import de.dhbwstuttgart.syntaxtree.TypeScope; +import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; @@ -15,18 +12,11 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException; import java.util.ArrayList; -/** - * @author A10023 - Andreas Stadelmeier - * Momentan erweitert LambdaExpression noch Expr und erbt dadurch auch von ExprStatement ist also auch ein Statement - * - * LambdaExpression Aufbau: - * ( ParameterList ) -> { methodBody }; - */ public class LambdaExpression extends Expression implements TypeScope { private Block methodBody; private ParameterList params; - public LambdaExpression(RefTypeOrTPHOrWildcardOrGeneric type, ParameterList params, Block methodBody,Token offset) { + public LambdaExpression(RefTypeOrTPHOrWildcardOrGeneric type, ParameterList params, Block methodBody, Token offset) { super(type,offset); this.methodBody = methodBody; this.params = params; @@ -40,6 +30,11 @@ public class LambdaExpression extends Expression implements TypeScope { //return ret; } + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } + @Override public Iterable getGenerics() { //Lambda-Ausdrücke haben keine Generics diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVar.java index d1d3fba6f..23d343476 100644 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVar.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; @@ -28,4 +29,9 @@ public class LocalVar extends Statement{ //throw new NotImplementedException(); return new ConstraintSet(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarBunchDeclaration.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarBunchDeclaration.java index dc78c0e80..54adbb5a1 100644 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarBunchDeclaration.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarBunchDeclaration.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.Void; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; @@ -18,4 +19,10 @@ public class LocalVarBunchDeclaration extends Statement { public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } + diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java index 87e996b1d..f29e9976d 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java @@ -2,6 +2,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; @@ -23,4 +24,9 @@ public class LocalVarDecl extends Statement public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java index 30a8dfc8b..97fb6662f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java @@ -1,10 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import de.dhbwstuttgart.exceptions.TypeinferenceException; -import de.dhbwstuttgart.syntaxtree.ClassOrInterface; -import de.dhbwstuttgart.syntaxtree.FormalParameter; -import de.dhbwstuttgart.syntaxtree.Method; -import de.dhbwstuttgart.syntaxtree.ParameterList; +import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; @@ -50,6 +47,11 @@ public class MethodCall extends Statement return ret; } + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } + protected Constraint generateConstraint(MethodAssumption forMethod, TypeInferenceBlockInformation info){ Constraint methodConstraint = new Constraint(); methodConstraint.add(ConstraintsFactory.createPair(receiver.getType(), forMethod.getReceiverType(), PairOperator.SMALLERDOT, info)); @@ -68,7 +70,7 @@ public class MethodCall extends Statement } - public List getMethods(String name, ArgumentList arglist, TypeInferenceBlockInformation info) { + public static List getMethods(String name, ArgumentList arglist, TypeInferenceBlockInformation info) { List ret = new ArrayList<>(); for(ClassOrInterface cl : info.getAvailableClasses()){ for(Method m : cl.getMethods()){ @@ -83,7 +85,7 @@ public class MethodCall extends Statement return ret; } - protected List convertParams(ParameterList parameterList, TypeInferenceBlockInformation info){ + protected static List convertParams(ParameterList parameterList, TypeInferenceBlockInformation info){ List params = new ArrayList<>(); for(FormalParameter fp : parameterList.getFormalparalist()){ params.add(info.checkGTV(fp.getType())); diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java index 7595175f5..78454bcea 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.List; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; @@ -21,4 +22,9 @@ public class NewArray extends Expression public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java index ba13e83ee..f5ed5e5c5 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java @@ -8,6 +8,7 @@ import de.dhbwstuttgart.exceptions.TypeinferenceException; import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.Method; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; @@ -55,11 +56,6 @@ public class NewClass extends MethodCall return methodConstraint; } - @Override - public List getMethods(String name, ArgumentList arglist, TypeInferenceBlockInformation info) { - return getConstructors(info, (RefType) this.getType(), arglist); - } - @Override public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { ConstraintSet ret = new ConstraintSet(); @@ -75,4 +71,9 @@ public class NewClass extends MethodCall ret.addOderConstraint(methodConstraints); return ret; } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java b/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java index d45dd60af..ac6c043d6 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; @@ -22,4 +23,9 @@ public class Receiver extends Expression public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { return expr.getConstraints(info); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java index 6cfb719a6..59cbf0ab4 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.ConstraintsFactory; @@ -23,4 +24,9 @@ public class Return extends Statement this.getType(),info.getCurrentTypeScope().getReturnType(), info)); return ret; } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/ReturnVoid.java b/src/de/dhbwstuttgart/syntaxtree/statement/ReturnVoid.java index 1b5eae2d6..ca64b2c5a 100644 --- a/src/de/dhbwstuttgart/syntaxtree/statement/ReturnVoid.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/ReturnVoid.java @@ -1,9 +1,15 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import org.antlr.v4.runtime.Token; public class ReturnVoid extends Return{ public ReturnVoid(Token offset) { super(new EmptyStmt(offset), offset); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/StaticClassName.java b/src/de/dhbwstuttgart/syntaxtree/statement/StaticClassName.java index 2f6d35f41..883e89b20 100644 --- a/src/de/dhbwstuttgart/syntaxtree/statement/StaticClassName.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/StaticClassName.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.typecheck.JavaClassName; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; @@ -16,4 +17,9 @@ public class StaticClassName extends Expression { public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { return new ConstraintSet(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Super.java b/src/de/dhbwstuttgart/syntaxtree/statement/Super.java index 47f5d8cc0..5f9e40cb9 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Super.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Super.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; @@ -17,4 +18,9 @@ public class Super extends Expression public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/This.java b/src/de/dhbwstuttgart/syntaxtree/statement/This.java index 25d732e5f..c4ad1cf38 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/This.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/This.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.operator.Operator; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; @@ -28,4 +29,9 @@ public class This extends Expression ret.addUndConstraint(ConstraintsFactory.createPair( this.getType(), info.getCurrentClass().getType(), PairOperator.EQUALSDOT, info)); return ret; } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/UnaryPlus.java b/src/de/dhbwstuttgart/syntaxtree/statement/UnaryPlus.java index 7c0caf100..db4b9aecc 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/UnaryPlus.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/UnaryPlus.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; @@ -16,4 +17,9 @@ public class UnaryPlus extends Expression public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java index 7641efb31..9edc43f08 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; @@ -30,4 +31,9 @@ public class WhileStmt extends Statement public ConstraintSet getConstraints(TypeInferenceBlockInformation info) { throw new NotImplementedException(); } + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/literal/BoolLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/literal/BoolLiteral.java index c42b4c91e..29bdb47dc 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/literal/BoolLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/literal/BoolLiteral.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement.literal; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import org.antlr.v4.runtime.Token; @@ -15,7 +16,11 @@ public class BoolLiteral extends Literal this.value = value; } - + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/literal/CharLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/literal/CharLiteral.java index 6f1c79596..7e3796904 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/literal/CharLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/literal/CharLiteral.java @@ -1,4 +1,5 @@ package de.dhbwstuttgart.syntaxtree.statement.literal; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import org.antlr.v4.runtime.Token; @@ -13,4 +14,8 @@ public class CharLiteral extends Literal this.value = value; } + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/literal/Null.java b/src/de/dhbwstuttgart/syntaxtree/statement/literal/Null.java index 38a734067..254408e84 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/literal/Null.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/literal/Null.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement.literal; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import org.antlr.v4.runtime.Token; @@ -11,5 +12,10 @@ public class Null extends Literal { super(type,offset); } - + + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } + } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/literal/NumberLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/literal/NumberLiteral.java index aef0012dc..2c90f413b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/literal/NumberLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/literal/NumberLiteral.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.statement.literal; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import org.antlr.v4.runtime.Token; @@ -14,4 +15,8 @@ public class NumberLiteral extends Literal this.value = value; } + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/literal/StringLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/literal/StringLiteral.java index 892190511..d6ab98084 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/literal/StringLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/literal/StringLiteral.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement.literal; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.type.RefType; import org.antlr.v4.runtime.Token; @@ -15,4 +16,8 @@ public class StringLiteral extends Literal this.value = value; } + @Override + public void accept(StatementVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java new file mode 100644 index 000000000..f75d6222e --- /dev/null +++ b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java @@ -0,0 +1,144 @@ +package de.dhbwstuttgart.typeinference.typeAlgo; + +import de.dhbwstuttgart.syntaxtree.StatementVisitor; +import de.dhbwstuttgart.syntaxtree.statement.*; +import de.dhbwstuttgart.syntaxtree.statement.literal.Literal; +import de.dhbwstuttgart.syntaxtree.statement.literal.Null; + +public class TYPE implements StatementVisitor{ + + @Override + public void visit(LambdaExpression lambdaExpression) { + + } + + @Override + public void visit(Assign assign) { + + } + + @Override + public void visit(Binary binary) { + + } + + @Override + public void visit(Block block) { + + } + + @Override + public void visit(CastExpr castExpr) { + + } + + @Override + public void visit(EmptyStmt emptyStmt) { + + } + + @Override + public void visit(FieldVar fieldVar) { + + } + + @Override + public void visit(ForStmt forStmt) { + + } + + @Override + public void visit(IfStmt ifStmt) { + + } + + @Override + public void visit(InstanceOf instanceOf) { + + } + + @Override + public void visit(InstVar instVar) { + + } + + @Override + public void visit(LocalVar localVar) { + + } + + @Override + public void visit(LocalVarDecl localVarDecl) { + + } + + @Override + public void visit(MethodCall methodCall) { + + } + + @Override + public void visit(NewClass methodCall) { + + } + + @Override + public void visit(NewArray newArray) { + + } + + @Override + public void visit(Receiver receiver) { + + } + + @Override + public void visit(Return aReturn) { + + } + + @Override + public void visit(ReturnVoid aReturn) { + + } + + @Override + public void visit(StaticClassName staticClassName) { + + } + + @Override + public void visit(Super aSuper) { + + } + + @Override + public void visit(This aThis) { + + } + + @Override + public void visit(UnaryPlus unaryPlus) { + + } + + @Override + public void visit(WhileStmt whileStmt) { + + } + + @Override + public void visit(LocalVarBunchDeclaration localVarBunchDeclaration) { + + } + + @Override + public void visit(Null aNull) { + + } + + @Override + public void visit(Literal literal) { + + } +} diff --git a/test/typeinference/JavaTXCompilerTest.java b/test/typeinference/JavaTXCompilerTest.java index 31f0a6225..4df1c29db 100644 --- a/test/typeinference/JavaTXCompilerTest.java +++ b/test/typeinference/JavaTXCompilerTest.java @@ -17,10 +17,10 @@ public class JavaTXCompilerTest { @Test public void test() throws IOException, ClassNotFoundException { JavaTXCompiler compiler = new JavaTXCompiler(); - compiler.parse(new File(rootDirectory+"Methods.jav")); + //compiler.parse(new File(rootDirectory+"Methods.jav")); //compiler.parse(new File(rootDirectory+"Generics.jav")); //compiler.parse(new File(rootDirectory+"MethodsEasy.jav")); - //compiler.parse(new File(rootDirectory+"Lambda.jav")); + compiler.parse(new File(rootDirectory+"Lambda.jav")); compiler.typeInference(); } } \ No newline at end of file