Implementierungen von Interfaces eingefuegt und Overriding ersetzt durch implementierung
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 6m2s
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 6m2s
modified: ../src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java Overriding ersetzt durch implementierung (Umbennennung) modified: ../resources/bytecode/javFiles/Matrix.jav modified: ../src/main/java/de/dhbwstuttgart/syntaxtree/Method.java modified: ../src/main/java/de/dhbwstuttgart/typeinference/constraints/Constraint.java modified: ../src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java modified: ../src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java modified: ../src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java modified: ../src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
This commit is contained in:
parent
021b7ec9fe
commit
2221b559ca
@ -1,4 +1,5 @@
|
||||
import java.util.List;
|
||||
import java.util.AbstractList;
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
//import java.lang.Float;
|
||||
|
@ -33,7 +33,7 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
|
||||
private GenericDeclarationList generics;
|
||||
private final RefTypeOrTPHOrWildcardOrGeneric returnType;
|
||||
public final Boolean isInherited;
|
||||
public final Boolean isOverridden;
|
||||
public final Boolean isImplemented;
|
||||
|
||||
/*
|
||||
* its Constraints
|
||||
@ -51,7 +51,7 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
|
||||
this.block = block;
|
||||
this.generics = gtvDeclarations;
|
||||
this.isInherited = false;
|
||||
this.isOverridden = false;
|
||||
this.isImplemented = false;
|
||||
}
|
||||
|
||||
public Method(int modifier, String name, RefTypeOrTPHOrWildcardOrGeneric returnType, ParameterList parameterList, Block block,
|
||||
@ -64,7 +64,7 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
|
||||
this.block = block;
|
||||
this.generics = gtvDeclarations;
|
||||
this.isInherited = isInherited;
|
||||
this.isOverridden = isOverridden;
|
||||
this.isImplemented = isOverridden;
|
||||
}
|
||||
|
||||
public ParameterList getParameterList() {
|
||||
|
@ -108,15 +108,40 @@ public class ASTFactory {
|
||||
if (jreClass.getSuperclass()==null) {
|
||||
methoden.add(createMethod(method, signature, jreClass, false, false));
|
||||
}
|
||||
else try {
|
||||
else {
|
||||
Boolean isImplemented = false;
|
||||
isImplemented = Arrays.stream(jreClass.getInterfaces()).
|
||||
reduce(false,
|
||||
(x,y) -> {
|
||||
try {
|
||||
y.getDeclaredMethod(method.getName(), method.getParameterTypes());
|
||||
return true;
|
||||
}
|
||||
catch (java.lang.NoSuchMethodException e) {
|
||||
return false;
|
||||
}},
|
||||
(x,y) -> (x || y)
|
||||
);
|
||||
|
||||
if (isImplemented) {
|
||||
methoden.add(createMethod(method, signature, jreClass, false, true));
|
||||
}
|
||||
else {
|
||||
if (Modifier.isAbstract(jreClass.getSuperclass().getModifiers())) {
|
||||
try {
|
||||
jreClass.getSuperclass().getDeclaredMethod(method.getName(), method.getParameterTypes());
|
||||
methoden.add(createMethod(method, signature, jreClass, false, true));
|
||||
}
|
||||
catch (java.lang.NoSuchMethodException e)
|
||||
{
|
||||
catch (java.lang.NoSuchMethodException e) {
|
||||
methoden.add(createMethod(method, signature, jreClass, false, false));
|
||||
}
|
||||
}
|
||||
else {
|
||||
methoden.add(createMethod(method, signature, jreClass, false, false));
|
||||
}
|
||||
|
||||
}
|
||||
}}
|
||||
for (java.lang.reflect.Method method : allInheritedMethods) {
|
||||
var signature = methodSignatures.get(new Pair<>(method.getName(), org.objectweb.asm.Type.getMethodDescriptor(method)));
|
||||
methoden.add(createMethod(method, signature, jreClass, true, false));
|
||||
@ -202,7 +227,7 @@ public class ASTFactory {
|
||||
return Optional.of(new de.dhbwstuttgart.syntaxtree.Constructor(modifier, name, returnType, parameterList, block, gtvDeclarations, offset /* , new ArrayList<>() geloescht PL 2018-11-24 */));
|
||||
}
|
||||
|
||||
public static Method createMethod(java.lang.reflect.Method jreMethod, String signature, java.lang.Class inClass, Boolean isInherited, Boolean isOverridden) {
|
||||
public static Method createMethod(java.lang.reflect.Method jreMethod, String signature, java.lang.Class inClass, Boolean isInherited, Boolean isImplemented) {
|
||||
String name = jreMethod.getName();
|
||||
RefTypeOrTPHOrWildcardOrGeneric returnType;
|
||||
Type jreRetType;
|
||||
@ -228,7 +253,7 @@ public class ASTFactory {
|
||||
GenericDeclarationList gtvDeclarations = createGenerics(jreMethod.getTypeParameters(), inClass, jreMethod.getName(), signature);
|
||||
Token offset = new NullToken();
|
||||
|
||||
return new Method(jreMethod.getModifiers(), name, returnType, parameterList, block, gtvDeclarations, offset, isInherited, isOverridden);
|
||||
return new Method(jreMethod.getModifiers(), name, returnType, parameterList, block, gtvDeclarations, offset, isInherited, isImplemented);
|
||||
}
|
||||
|
||||
public static GenericDeclarationList createGenerics(TypeVariable[] typeParameters, Class context, String methodName, String signature) {
|
||||
|
@ -9,7 +9,7 @@ import java.util.Set;
|
||||
public class Constraint<A> extends HashSet<A> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Boolean isInherited = false;//wird beides nur für die Method-Constraints benoetigt
|
||||
private Boolean isOverridden = false;
|
||||
private Boolean isImplemented = false;
|
||||
|
||||
/*
|
||||
* wird verwendet um bei der Codegenerierung die richtige Methoden - Signatur
|
||||
@ -23,14 +23,14 @@ public class Constraint<A> extends HashSet<A> {
|
||||
super();
|
||||
}
|
||||
|
||||
public Constraint(Boolean isInherited, Boolean isOverridden) {
|
||||
public Constraint(Boolean isInherited, Boolean isImplemented) {
|
||||
this.isInherited = isInherited;
|
||||
this.isOverridden = isOverridden;
|
||||
this.isImplemented = isImplemented;
|
||||
}
|
||||
|
||||
public Constraint(Boolean isInherited, Boolean isOverridden, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
|
||||
public Constraint(Boolean isInherited, Boolean isImplemented, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
|
||||
this.isInherited = isInherited;
|
||||
this.isOverridden = isOverridden;
|
||||
this.isImplemented = isImplemented;
|
||||
this.extendConstraint = extendConstraint;
|
||||
this.methodSignatureConstraint = methodSignatureConstraint;
|
||||
}
|
||||
@ -43,8 +43,8 @@ public class Constraint<A> extends HashSet<A> {
|
||||
return isInherited;
|
||||
}
|
||||
|
||||
public Boolean isOverridden() {
|
||||
return isOverridden;
|
||||
public Boolean isImplemented() {
|
||||
return isImplemented;
|
||||
}
|
||||
|
||||
public Constraint<A> getExtendConstraint() {
|
||||
@ -64,7 +64,7 @@ public class Constraint<A> extends HashSet<A> {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return super.toString() + "\nisInherited = " + isInherited + " isOveridden = " + isOverridden
|
||||
return super.toString() + "\nisInherited = " + isInherited + " isOveridden = " + isImplemented
|
||||
+ methodSignatureConstraint
|
||||
//" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" )
|
||||
+ "\n" ;
|
||||
|
@ -77,7 +77,7 @@ public class ConstraintSet<A> {
|
||||
.map(o)
|
||||
.collect(Collectors.toCollection((
|
||||
() -> new Constraint<B> (as.isInherited(),
|
||||
as.isOverridden(),
|
||||
as.isImplemented(),
|
||||
(as.getExtendConstraint() != null)
|
||||
? as.getExtendConstraint().stream().map(o).collect(Collectors.toCollection(Constraint::new))
|
||||
: null,
|
||||
|
@ -753,7 +753,7 @@ public class TYPEStmt implements StatementVisitor {
|
||||
if (m.getName().equals(name) && m.getParameterList().getFormalparalist().size() == numArgs) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric retType = m.getReturnType();// info.checkGTV(m.getReturnType());
|
||||
|
||||
ret.add(new MethodAssumption(cl, retType, convertParams(m.getParameterList(), info), createTypeScope(cl, m), m.isInherited, m.isOverridden));
|
||||
ret.add(new MethodAssumption(cl, retType, convertParams(m.getParameterList(), info), createTypeScope(cl, m), m.isInherited, m.isImplemented));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -785,7 +785,7 @@ public class TYPEStmt implements StatementVisitor {
|
||||
for (Method m : cl.getConstructors()) {
|
||||
if (m.getParameterList().getFormalparalist().size() == argList.getArguments().size()) {
|
||||
var params = convertParams(m.getParameterList(), info);
|
||||
ret.add(new MethodAssumption(cl, cl.generateTypeOfThisClass(), params, createTypeScope(cl, m), m.isInherited, m.isOverridden));
|
||||
ret.add(new MethodAssumption(cl, cl.generateTypeOfThisClass(), params, createTypeScope(cl, m), m.isInherited, m.isImplemented));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -702,10 +702,10 @@ public class RuleSet implements IRuleSet{
|
||||
x -> uni.apply(pair,x)).collect(Collectors.toCollection((b.getExtendConstraint() != null)
|
||||
? () -> new Constraint<UnifyPair>(
|
||||
b.isInherited(),
|
||||
b.isOverridden(),
|
||||
b.isImplemented(),
|
||||
b.getExtendConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(Constraint::new)),
|
||||
b.getmethodSignatureConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(HashSet::new)))
|
||||
: () -> new Constraint<UnifyPair>(b.isInherited(), b.isOverridden())
|
||||
: () -> new Constraint<UnifyPair>(b.isInherited(), b.isImplemented())
|
||||
));
|
||||
oderConstraints.replaceAll(oc -> oc.stream().map(applyUni).collect(Collectors.toCollection(HashSet::new)));
|
||||
/*
|
||||
|
@ -1356,7 +1356,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
List<Set<UnifyPair>> smallerSetasList = oup.smallerThan(a_new, nextSetasList);
|
||||
writeLog("smallerSetasList: " + smallerSetasList);
|
||||
List<Set<UnifyPair>> notInherited = smallerSetasList.stream()
|
||||
.filter(x -> !((Constraint<UnifyPair>)x).isInherited() && !((Constraint<UnifyPair>)x).isOverridden())
|
||||
.filter(x -> !((Constraint<UnifyPair>)x).isInherited() && !((Constraint<UnifyPair>)x).isImplemented())
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
writeLog("notInherited: " + notInherited+"\n");
|
||||
List<Set<UnifyPair>> notErased = new ArrayList<>();
|
||||
|
Loading…
Reference in New Issue
Block a user