Refactoring
This commit is contained in:
parent
a7e1a5e2c2
commit
4b21f03a5a
@ -10,8 +10,6 @@ public interface ASTVisitor extends StatementVisitor{
|
|||||||
|
|
||||||
void visit(SourceFile sourceFile);
|
void visit(SourceFile sourceFile);
|
||||||
|
|
||||||
void visit(ArgumentList argumentList);
|
|
||||||
|
|
||||||
void visit(GenericTypeVar genericTypeVar);
|
void visit(GenericTypeVar genericTypeVar);
|
||||||
|
|
||||||
void visit(FormalParameter formalParameter);
|
void visit(FormalParameter formalParameter);
|
||||||
|
@ -8,6 +8,8 @@ import de.dhbwstuttgart.syntaxtree.statement.literal.StringLiteral;
|
|||||||
|
|
||||||
public interface StatementVisitor {
|
public interface StatementVisitor {
|
||||||
|
|
||||||
|
void visit(ArgumentList argumentList);
|
||||||
|
|
||||||
void visit(LambdaExpression lambdaExpression);
|
void visit(LambdaExpression lambdaExpression);
|
||||||
|
|
||||||
void visit(Assign assign);
|
void visit(Assign assign);
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.statement;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der FormalParameter einer LambdaExpression hat gesonderte Eigenschaften.
|
|
||||||
* @author janulrich
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LambdaParameter extends FormalParameter {
|
|
||||||
|
|
||||||
public LambdaParameter(FormalParameter fp) {
|
|
||||||
super(null,null,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -42,6 +42,13 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
return constraintsSet;
|
return constraintsSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(ArgumentList arglist) {
|
||||||
|
for(int i = 0;i<arglist.getArguments().size();i++){
|
||||||
|
arglist.getArguments().get(i).accept(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(LambdaExpression lambdaExpression) {
|
public void visit(LambdaExpression lambdaExpression) {
|
||||||
TypePlaceholder tphRetType = TypePlaceholder.fresh(new NullToken());
|
TypePlaceholder tphRetType = TypePlaceholder.fresh(new NullToken());
|
||||||
@ -136,7 +143,6 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
@Override
|
@Override
|
||||||
public void visit(MethodCall methodCall) {
|
public void visit(MethodCall methodCall) {
|
||||||
methodCall.receiver.accept(this);
|
methodCall.receiver.accept(this);
|
||||||
constraintsSet.addAll(this.getArgumentListConstraints(methodCall, info));
|
|
||||||
//Overloading:
|
//Overloading:
|
||||||
Set<Constraint> methodConstraints = new HashSet<>();
|
Set<Constraint> methodConstraints = new HashSet<>();
|
||||||
for(MethodAssumption m : this.getMethods(methodCall.name, methodCall.arglist, info)){
|
for(MethodAssumption m : this.getMethods(methodCall.name, methodCall.arglist, info)){
|
||||||
@ -150,7 +156,6 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(NewClass methodCall) {
|
public void visit(NewClass methodCall) {
|
||||||
constraintsSet.addAll(this.getArgumentListConstraints(methodCall, info));
|
|
||||||
//Overloading:
|
//Overloading:
|
||||||
Set<Constraint> methodConstraints = new HashSet<>();
|
Set<Constraint> methodConstraints = new HashSet<>();
|
||||||
for(MethodAssumption m : this.getConstructors(info, (RefType) methodCall.getType(), methodCall.getArgumentList())){
|
for(MethodAssumption m : this.getConstructors(info, (RefType) methodCall.getType(), methodCall.getArgumentList())){
|
||||||
@ -290,14 +295,6 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConstraintSet getArgumentListConstraints(MethodCall forMethod, TypeInferenceBlockInformation info) {
|
|
||||||
TYPEStmt ret = new TYPEStmt(info);
|
|
||||||
for(int i = 0;i<forMethod.arglist.getArguments().size();i++){
|
|
||||||
forMethod.arglist.getArguments().get(i).accept(ret);
|
|
||||||
}
|
|
||||||
return ret.constraintsSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MethodAssumption> getConstructors(TypeInferenceBlockInformation info, RefType ofType, ArgumentList argList){
|
public List<MethodAssumption> getConstructors(TypeInferenceBlockInformation info, RefType ofType, ArgumentList argList){
|
||||||
List<MethodAssumption> ret = new ArrayList<>();
|
List<MethodAssumption> ret = new ArrayList<>();
|
||||||
for(ClassOrInterface cl : info.getAvailableClasses()){
|
for(ClassOrInterface cl : info.getAvailableClasses()){
|
||||||
|
Loading…
Reference in New Issue
Block a user