From afd3f32f238c2bb67b2bda3e3dfccb471841784b Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 28 Jun 2017 17:20:26 +0200 Subject: [PATCH] ASTVisitor implementieren --- .../StatementGenerator.java | 6 ++--- .../dhbwstuttgart/syntaxtree/ASTVisitor.java | 25 +++++++++++++++++++ src/de/dhbwstuttgart/syntaxtree/Field.java | 5 ++++ .../syntaxtree/FormalParameter.java | 5 ++++ .../syntaxtree/GenericDeclarationList.java | 5 ++++ .../syntaxtree/GenericTypeVar.java | 5 ++++ .../syntaxtree/ParameterList.java | 5 ++++ .../dhbwstuttgart/syntaxtree/SourceFile.java | 5 ++++ .../syntaxtree/SyntaxTreeNode.java | 1 + .../syntaxtree/operator/AddOp.java | 23 ----------------- .../syntaxtree/operator/AndOp.java | 18 ------------- .../syntaxtree/operator/DivideOp.java | 12 --------- .../syntaxtree/operator/EqualOp.java | 15 ----------- .../syntaxtree/operator/GreaterEquOp.java | 13 ---------- .../syntaxtree/operator/GreaterOp.java | 14 ----------- .../syntaxtree/operator/LessEquOp.java | 15 ----------- .../syntaxtree/operator/LessOp.java | 14 ----------- .../syntaxtree/operator/LogOp.java | 18 ------------- .../syntaxtree/operator/MinusOp.java | 11 -------- .../syntaxtree/operator/ModuloOp.java | 15 ----------- .../syntaxtree/operator/MulOp.java | 10 -------- .../syntaxtree/operator/NotEqualOp.java | 11 -------- .../syntaxtree/operator/Operator.java | 13 ---------- .../syntaxtree/operator/OrOp.java | 15 ----------- .../syntaxtree/operator/PlusOp.java | 12 --------- .../syntaxtree/operator/RelOp.java | 11 -------- .../syntaxtree/operator/TimesOp.java | 11 -------- .../syntaxtree/statement/ArgumentList.java | 5 ++++ .../syntaxtree/statement/Binary.java | 8 ++++-- .../syntaxtree/statement/Expression.java | 6 +++++ .../syntaxtree/statement/This.java | 1 - .../type/RefTypeOrTPHOrWildcardOrGeneric.java | 6 +++++ .../syntaxtree/visual/ASTPrinter.java | 5 ++++ test/javFiles/Faculty.jav | 6 ++++- test/typeinference/JavaTXCompilerTest.java | 3 ++- 35 files changed, 93 insertions(+), 260 deletions(-) create mode 100644 src/de/dhbwstuttgart/syntaxtree/ASTVisitor.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/AddOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/AndOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/DivideOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/EqualOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/GreaterEquOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/GreaterOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/LessEquOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/LessOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/LogOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/MinusOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/ModuloOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/MulOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/NotEqualOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/Operator.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/OrOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/PlusOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/RelOp.java delete mode 100755 src/de/dhbwstuttgart/syntaxtree/operator/TimesOp.java create mode 100644 src/de/dhbwstuttgart/syntaxtree/visual/ASTPrinter.java diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index f69ec781e..b3273f9db 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -4,8 +4,6 @@ import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.antlr.Java8Parser; import de.dhbwstuttgart.syntaxtree.*; -import de.dhbwstuttgart.syntaxtree.operator.AndOp; -import de.dhbwstuttgart.syntaxtree.operator.OrOp; import de.dhbwstuttgart.syntaxtree.statement.*; import de.dhbwstuttgart.syntaxtree.statement.literal.*; import de.dhbwstuttgart.syntaxtree.type.RefType; @@ -505,7 +503,7 @@ public class StatementGenerator { return convert(expression.conditionalAndExpression()); }else{ return new Binary(convert(expression.conditionalOrExpression()), - convert(expression.conditionalAndExpression()), new OrOp(null)); + convert(expression.conditionalAndExpression()), Binary.Operator.OR); } } @@ -514,7 +512,7 @@ public class StatementGenerator { return convert(expression.inclusiveOrExpression()); }else{ return new Binary(convert(expression.conditionalAndExpression()), - convert(expression.inclusiveOrExpression()), new AndOp(null)); + convert(expression.inclusiveOrExpression()), Binary.Operator.AND); } } diff --git a/src/de/dhbwstuttgart/syntaxtree/ASTVisitor.java b/src/de/dhbwstuttgart/syntaxtree/ASTVisitor.java new file mode 100644 index 000000000..8372dca86 --- /dev/null +++ b/src/de/dhbwstuttgart/syntaxtree/ASTVisitor.java @@ -0,0 +1,25 @@ +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.type.RefTypeOrTPHOrWildcardOrGeneric; + +public interface ASTVisitor extends StatementVisitor{ + + void visit(SourceFile sourceFile); + + void visit(ArgumentList argumentList); + + void visit(RefTypeOrTPHOrWildcardOrGeneric refTypeOrTPHOrWildcardOrGeneric); + + void visit(GenericTypeVar genericTypeVar); + + void visit(FormalParameter formalParameter); + + void visit(GenericDeclarationList genericTypeVars); + + void visit(Field field); + + void visit(ParameterList formalParameters); +} diff --git a/src/de/dhbwstuttgart/syntaxtree/Field.java b/src/de/dhbwstuttgart/syntaxtree/Field.java index 4961443cc..82c3053f9 100644 --- a/src/de/dhbwstuttgart/syntaxtree/Field.java +++ b/src/de/dhbwstuttgart/syntaxtree/Field.java @@ -24,5 +24,10 @@ public class Field extends SyntaxTreeNode{ public RefTypeOrTPHOrWildcardOrGeneric getType() { return type; } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/FormalParameter.java b/src/de/dhbwstuttgart/syntaxtree/FormalParameter.java index 7fb16d833..8e7e79830 100755 --- a/src/de/dhbwstuttgart/syntaxtree/FormalParameter.java +++ b/src/de/dhbwstuttgart/syntaxtree/FormalParameter.java @@ -21,4 +21,9 @@ public class FormalParameter extends SyntaxTreeNode public String getName() { return name; } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/GenericDeclarationList.java b/src/de/dhbwstuttgart/syntaxtree/GenericDeclarationList.java index ceea42b1a..e316aa6b0 100644 --- a/src/de/dhbwstuttgart/syntaxtree/GenericDeclarationList.java +++ b/src/de/dhbwstuttgart/syntaxtree/GenericDeclarationList.java @@ -26,4 +26,9 @@ public class GenericDeclarationList extends SyntaxTreeNode implements Iterable iterator() { return gtvs.iterator(); } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java index 5d151046e..8ac65e353 100755 --- a/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java @@ -51,4 +51,9 @@ public class GenericTypeVar extends SyntaxTreeNode public GenericTypeName getName() { return name; } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/ParameterList.java b/src/de/dhbwstuttgart/syntaxtree/ParameterList.java index b7d6860f2..1d8ff055b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/ParameterList.java +++ b/src/de/dhbwstuttgart/syntaxtree/ParameterList.java @@ -34,4 +34,9 @@ public class ParameterList extends SyntaxTreeNode implements Iterable iterator() { return null; } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java index 2dda4b29b..c18385add 100755 --- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -62,4 +62,9 @@ public class SourceFile extends SyntaxTreeNode{ public File getFile() { return file; } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java index 58155562c..77e26be8a 100644 --- a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java +++ b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java @@ -19,4 +19,5 @@ public abstract class SyntaxTreeNode implements IItemWithOffset{ return offset; } + public abstract void accept(ASTVisitor visitor); } diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/AddOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/AddOp.java deleted file mode 100755 index 00eb55bab..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/AddOp.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; - -import org.antlr.v4.runtime.Token; -import org.apache.bcel.Constants; -import org.apache.bcel.generic.ArithmeticInstruction; -import org.apache.bcel.generic.DUP; -import org.apache.bcel.generic.IADD; -import org.apache.bcel.generic.InstructionList; -import org.apache.bcel.generic.InvokeInstruction; -import org.apache.bcel.generic.ObjectType; - - - -public abstract class AddOp extends Operator -{ - public AddOp(Token offset) { - super(offset); - } - -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/AndOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/AndOp.java deleted file mode 100755 index 945bd0b6c..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/AndOp.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; -import de.dhbwstuttgart.syntaxtree.statement.Binary; -import org.antlr.v4.runtime.Token; -import org.apache.bcel.generic.InstructionList; - -public class AndOp extends LogOp -{ - - public AndOp(Token offset) - { - super(offset); - } - - - -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/DivideOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/DivideOp.java deleted file mode 100755 index 6b6bdccf0..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/DivideOp.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; - - - -public class DivideOp extends MulOp -{ - public DivideOp(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/EqualOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/EqualOp.java deleted file mode 100755 index 6b733dd7e..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/EqualOp.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; -import org.apache.bcel.generic.BranchInstruction; -import org.apache.bcel.generic.IF_ICMPNE; - - -public class EqualOp extends RelOp -{ - - - public EqualOp(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/GreaterEquOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/GreaterEquOp.java deleted file mode 100755 index a90a8bcfb..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/GreaterEquOp.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; - - - -public class GreaterEquOp extends RelOp -{ - - public GreaterEquOp(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/GreaterOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/GreaterOp.java deleted file mode 100755 index 08dfd37c7..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/GreaterOp.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; -import org.antlr.v4.runtime.Token; - - - - -public class GreaterOp extends RelOp -{ - - - public GreaterOp(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/LessEquOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/LessEquOp.java deleted file mode 100755 index cbff126e5..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/LessEquOp.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; - - - - -public class LessEquOp extends RelOp -{ - - - public LessEquOp(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/LessOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/LessOp.java deleted file mode 100755 index 8be12e11c..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/LessOp.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; -import org.antlr.v4.runtime.Token; - - - - -public class LessOp extends RelOp -{ - public LessOp(Token offset) - { - super(offset); - } - -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/LogOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/LogOp.java deleted file mode 100755 index 69df6267b..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/LogOp.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; -import org.antlr.v4.runtime.Token; - -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; - - - -public abstract class LogOp extends Operator -{ - - public LogOp(Token offset) - { - super(offset); - } - -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/MinusOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/MinusOp.java deleted file mode 100755 index 32b69c66f..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/MinusOp.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - - -import org.antlr.v4.runtime.Token; - -public class MinusOp extends AddOp -{ - public MinusOp(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/ModuloOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/ModuloOp.java deleted file mode 100755 index c33d0e1df..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/ModuloOp.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; - - - - -public class ModuloOp extends MulOp -{ - public ModuloOp(Token offset) - { - super(offset); - } - -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/MulOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/MulOp.java deleted file mode 100755 index 484393c2b..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/MulOp.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; - -public abstract class MulOp extends Operator -{ - public MulOp(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/NotEqualOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/NotEqualOp.java deleted file mode 100755 index 60a809aec..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/NotEqualOp.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; - -public class NotEqualOp extends RelOp -{ - - public NotEqualOp(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/Operator.java b/src/de/dhbwstuttgart/syntaxtree/operator/Operator.java deleted file mode 100755 index 23e8299f8..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/Operator.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - - -import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; -import org.antlr.v4.runtime.Token; - -public abstract class Operator extends SyntaxTreeNode -{ - - public Operator(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/OrOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/OrOp.java deleted file mode 100755 index 856be57dd..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/OrOp.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; - - -public class OrOp extends LogOp -{ - - public OrOp(Token offset) - { - super(offset); - } - - -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/PlusOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/PlusOp.java deleted file mode 100755 index 7d83836f5..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/PlusOp.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - - -import org.antlr.v4.runtime.Token; - -public class PlusOp extends AddOp -{ - public PlusOp(Token offset) - { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/RelOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/RelOp.java deleted file mode 100755 index 2ff001a4b..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/RelOp.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; - -public abstract class RelOp extends Operator -{ - - public RelOp(Token offset) { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/TimesOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/TimesOp.java deleted file mode 100755 index 421b03f61..000000000 --- a/src/de/dhbwstuttgart/syntaxtree/operator/TimesOp.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.dhbwstuttgart.syntaxtree.operator; - -import org.antlr.v4.runtime.Token; - -public class TimesOp extends MulOp -{ - public TimesOp(Token offset) - { - super(offset); - } -} diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java b/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java index 87bf459c1..75c92370d 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; +import de.dhbwstuttgart.syntaxtree.ASTVisitor; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import org.antlr.v4.runtime.Token; @@ -19,4 +20,8 @@ public class ArgumentList extends SyntaxTreeNode return expr; } + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java b/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java index 321509f9c..8a0a0b352 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java @@ -6,12 +6,16 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; -import de.dhbwstuttgart.syntaxtree.operator.Operator; - // neu von Felix public class Binary extends Expression { + public enum Operator{ + ADD, + SUB, + MUL, + AND, OR, DIV + } public Binary(Expression expr1, Expression expr2, Operator op){ super(null, null); } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Expression.java b/src/de/dhbwstuttgart/syntaxtree/statement/Expression.java index 07db361ea..902a832de 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.ASTVisitor; import de.dhbwstuttgart.syntaxtree.StatementVisitor; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; @@ -23,4 +24,9 @@ public abstract class Expression extends SyntaxTreeNode } public abstract void accept(StatementVisitor visitor); + + @Override + public void accept(ASTVisitor visitor) { + this.accept((StatementVisitor)visitor); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/This.java b/src/de/dhbwstuttgart/syntaxtree/statement/This.java index f30847777..81899052d 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/This.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/This.java @@ -1,7 +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; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java b/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java index 79813f562..640e80c72 100644 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.ASTVisitor; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import org.antlr.v4.runtime.Token; @@ -7,4 +8,9 @@ public class RefTypeOrTPHOrWildcardOrGeneric extends SyntaxTreeNode{ public RefTypeOrTPHOrWildcardOrGeneric(Token offset) { super(offset); } + + @Override + public void accept(ASTVisitor visitor) { + visitor.visit(this); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/visual/ASTPrinter.java b/src/de/dhbwstuttgart/syntaxtree/visual/ASTPrinter.java new file mode 100644 index 000000000..bf8c1f873 --- /dev/null +++ b/src/de/dhbwstuttgart/syntaxtree/visual/ASTPrinter.java @@ -0,0 +1,5 @@ +package de.dhbwstuttgart.syntaxtree.visual; + +public class ASTPrinter { + +} diff --git a/test/javFiles/Faculty.jav b/test/javFiles/Faculty.jav index 0889314a8..f69a48c74 100644 --- a/test/javFiles/Faculty.jav +++ b/test/javFiles/Faculty.jav @@ -1,8 +1,12 @@ class Faculty { + Integer mul(Integer x, Integer y) { + return x; + } + m () { auto fact = (Integer x) -> { - return fact.apply(x); + return mul(x, fact.apply(x)); }; return fact; } diff --git a/test/typeinference/JavaTXCompilerTest.java b/test/typeinference/JavaTXCompilerTest.java index f62dd5b50..96dc1d407 100644 --- a/test/typeinference/JavaTXCompilerTest.java +++ b/test/typeinference/JavaTXCompilerTest.java @@ -26,7 +26,8 @@ public class JavaTXCompilerTest { @Test public void test() throws IOException, ClassNotFoundException { - filesToTest.add(new File(rootDirectory+"mathStruc.jav")); + filesToTest.add(new File(rootDirectory+"Faculty.jav")); + //filesToTest.add(new File(rootDirectory+"mathStruc.jav")); //filesToTest.add(new File(rootDirectory+"Lambda.jav")); //filesToTest.add(new File(rootDirectory+"Lambda2.jav")); //filesToTest.add(new File(rootDirectory+"Lambda3.jav"));