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 f69ec781..b3273f9d 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 00000000..8372dca8 --- /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 4961443c..82c3053f 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 7fb16d83..8e7e7983 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 ceea42b1..e316aa6b 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 5d151046..8ac65e35 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 b7d6860f..1d8ff055 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 2dda4b29..c18385ad 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 58155562..77e26be8 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 00eb55ba..00000000 --- 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 945bd0b6..00000000 --- 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 6b6bdccf..00000000 --- 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 6b733dd7..00000000 --- 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 a90a8bcf..00000000 --- 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 08dfd37c..00000000 --- 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 cbff126e..00000000 --- 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 8be12e11..00000000 --- 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 69df6267..00000000 --- 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 32b69c66..00000000 --- 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 c33d0e1d..00000000 --- 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 484393c2..00000000 --- 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 60a809ae..00000000 --- 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 23e8299f..00000000 --- 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 856be57d..00000000 --- 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 7d83836f..00000000 --- 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 2ff001a4..00000000 --- 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 421b03f6..00000000 --- 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 87bf459c..75c92370 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 321509f9..8a0a0b35 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 07db361e..902a832d 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 f3084777..81899052 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 79813f56..640e80c7 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 00000000..bf8c1f87 --- /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 0889314a..f69a48c7 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 f62dd5b5..96dc1d40 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"));