Merge branch 'targetBytecode' of https://gitea.hb.dhbw-stuttgart.de/JavaTX/JavaCompilerCore into targetBytecode
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 5m26s
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 5m26s
This commit is contained in:
commit
662756ac18
@ -1,3 +1,5 @@
|
|||||||
|
import java.util.List;
|
||||||
|
import java.util.AbstractList;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
//import java.lang.Float;
|
//import java.lang.Float;
|
||||||
@ -30,8 +32,8 @@ public class Matrix extends Vector<Vector<Integer>> {
|
|||||||
var erg = 0;
|
var erg = 0;
|
||||||
var k = 0;
|
var k = 0;
|
||||||
while(k < v1.size()) {
|
while(k < v1.size()) {
|
||||||
erg = erg + v1.elementAt(k)
|
erg = erg + v1.get(k)
|
||||||
* m.elementAt(k).elementAt(j);
|
* m.get(k).get(j);
|
||||||
k++; }
|
k++; }
|
||||||
// v2.addElement(new Integer(erg));
|
// v2.addElement(new Integer(erg));
|
||||||
v2.addElement(erg);
|
v2.addElement(erg);
|
||||||
|
@ -66,7 +66,7 @@ public class JavaTXCompiler {
|
|||||||
Boolean resultmodel = true;
|
Boolean resultmodel = true;
|
||||||
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
||||||
|
|
||||||
Boolean log = false; //gibt an ob ein Log-File nach System.getProperty("user.dir")+""/logFiles/"" geschrieben werden soll?
|
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+""/logFiles/"" geschrieben werden soll?
|
||||||
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
||||||
public final DirectoryClassLoader classLoader;
|
public final DirectoryClassLoader classLoader;
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ public class JavaTXCompiler {
|
|||||||
cl.getMethods().add(new Method(m.modifier, m.name, m.getReturnType().acceptTV(new TypeExchanger(gtvs)), newParaList, m.block,
|
cl.getMethods().add(new Method(m.modifier, m.name, m.getReturnType().acceptTV(new TypeExchanger(gtvs)), newParaList, m.block,
|
||||||
// new GenericDeclarationList(newGenericsList,
|
// new GenericDeclarationList(newGenericsList,
|
||||||
// ((GenericDeclarationList)m.getGenerics()).getOffset()),
|
// ((GenericDeclarationList)m.getGenerics()).getOffset()),
|
||||||
(GenericDeclarationList) m.getGenerics(), m.getOffset(), true));
|
(GenericDeclarationList) m.getGenerics(), m.getOffset(), true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ public class StatementGenerator {
|
|||||||
|
|
||||||
if (!Objects.isNull(creator.classCreatorRest())) {
|
if (!Objects.isNull(creator.classCreatorRest())) {
|
||||||
ArgumentList args = convertArguments(creator.classCreatorRest().arguments().expressionList());
|
ArgumentList args = convertArguments(creator.classCreatorRest().arguments().expressionList());
|
||||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes = args.getArguments().stream().map(x -> TypePlaceholder.fresh(creator.getStart())).collect(Collectors.toCollection(ArrayList::new));
|
ArrayList<TypePlaceholder> argTypes = args.getArguments().stream().map(x -> TypePlaceholder.fresh(creator.getStart())).collect(Collectors.toCollection(ArrayList::new));
|
||||||
argTypes.add(TypePlaceholder.fresh(creator.getStart())); // return type
|
argTypes.add(TypePlaceholder.fresh(creator.getStart())); // return type
|
||||||
Statement ret = new NewClass(newclass, args, null, argTypes, creator.getStart());
|
Statement ret = new NewClass(newclass, args, null, argTypes, creator.getStart());
|
||||||
ret.setStatement();
|
ret.setStatement();
|
||||||
@ -311,7 +311,7 @@ public class StatementGenerator {
|
|||||||
IdentifierContext identifier = innercreator.identifier();
|
IdentifierContext identifier = innercreator.identifier();
|
||||||
RefType newclass = (RefType) TypeGenerator.convertTypeName(identifier.getText(), genericArgs, identifier.getStart(), reg, generics);
|
RefType newclass = (RefType) TypeGenerator.convertTypeName(identifier.getText(), genericArgs, identifier.getStart(), reg, generics);
|
||||||
ArgumentList args = convertArguments(innercreator.classCreatorRest().arguments().expressionList());
|
ArgumentList args = convertArguments(innercreator.classCreatorRest().arguments().expressionList());
|
||||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes = args.getArguments().stream().map(x -> TypePlaceholder.fresh(innercreator.getStart())).collect(Collectors.toCollection(ArrayList::new));
|
ArrayList<TypePlaceholder> argTypes = args.getArguments().stream().map(x -> TypePlaceholder.fresh(innercreator.getStart())).collect(Collectors.toCollection(ArrayList::new));
|
||||||
Statement ret = new NewClass(newclass, args, null, argTypes, innercreator.getStart());
|
Statement ret = new NewClass(newclass, args, null, argTypes, innercreator.getStart());
|
||||||
ret.setStatement();
|
ret.setStatement();
|
||||||
return ret;
|
return ret;
|
||||||
@ -712,7 +712,7 @@ public class StatementGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArgumentList argumentList = convertArguments(expr.expressionList());
|
ArgumentList argumentList = convertArguments(expr.expressionList());
|
||||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature = argumentList.getArguments().stream().map(x -> (RefTypeOrTPHOrWildcardOrGeneric) TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
ArrayList<TypePlaceholder> signature = argumentList.getArguments().stream().map(x -> TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
||||||
signature.add(TypePlaceholder.fresh(offset)); // return type
|
signature.add(TypePlaceholder.fresh(offset)); // return type
|
||||||
|
|
||||||
MethodCall ret;
|
MethodCall ret;
|
||||||
@ -737,7 +737,7 @@ public class StatementGenerator {
|
|||||||
name = expr.SUPER().getText();
|
name = expr.SUPER().getText();
|
||||||
}
|
}
|
||||||
ArgumentList argumentList = convertArguments(expr.expressionList());
|
ArgumentList argumentList = convertArguments(expr.expressionList());
|
||||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature = argumentList.getArguments().stream().map(x -> (RefTypeOrTPHOrWildcardOrGeneric) TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
ArrayList<TypePlaceholder> signature = argumentList.getArguments().stream().map(x -> TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
||||||
signature.add(TypePlaceholder.fresh(offset)); // return type
|
signature.add(TypePlaceholder.fresh(offset)); // return type
|
||||||
MethodCall ret = new MethodCall(TypePlaceholder.fresh(offset), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
MethodCall ret = new MethodCall(TypePlaceholder.fresh(offset), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
||||||
ret.setStatement();
|
ret.setStatement();
|
||||||
|
@ -452,8 +452,8 @@ public class SyntaxTreeGenerator {
|
|||||||
protected static Block prepareBlock(Block constructorBlock, RefType superClass) {
|
protected static Block prepareBlock(Block constructorBlock, RefType superClass) {
|
||||||
List<Statement> statements = constructorBlock.getStatements();
|
List<Statement> statements = constructorBlock.getStatements();
|
||||||
if (statements.isEmpty() || !(statements.get(0) instanceof SuperCall || statements.get(0) instanceof ThisCall)) {
|
if (statements.isEmpty() || !(statements.get(0) instanceof SuperCall || statements.get(0) instanceof ThisCall)) {
|
||||||
var signature = new ArrayList<RefTypeOrTPHOrWildcardOrGeneric>();
|
var signature = new ArrayList<TypePlaceholder>();
|
||||||
signature.add(new Void(new NullToken()));
|
signature.add(TypePlaceholder.fresh(new NullToken()));
|
||||||
statements.add(0, new SuperCall(superClass, signature, constructorBlock.getOffset()));
|
statements.add(0, new SuperCall(superClass, signature, constructorBlock.getOffset()));
|
||||||
}
|
}
|
||||||
/* statements.addAll(fieldInitializations); geloescht PL 2018-11-24 */
|
/* statements.addAll(fieldInitializations); geloescht PL 2018-11-24 */
|
||||||
|
@ -33,6 +33,7 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
|
|||||||
private GenericDeclarationList generics;
|
private GenericDeclarationList generics;
|
||||||
private final RefTypeOrTPHOrWildcardOrGeneric returnType;
|
private final RefTypeOrTPHOrWildcardOrGeneric returnType;
|
||||||
public final Boolean isInherited;
|
public final Boolean isInherited;
|
||||||
|
public final Boolean isImplemented;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* its Constraints
|
* its Constraints
|
||||||
@ -50,10 +51,11 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
|
|||||||
this.block = block;
|
this.block = block;
|
||||||
this.generics = gtvDeclarations;
|
this.generics = gtvDeclarations;
|
||||||
this.isInherited = false;
|
this.isInherited = false;
|
||||||
|
this.isImplemented = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Method(int modifier, String name, RefTypeOrTPHOrWildcardOrGeneric returnType, ParameterList parameterList, Block block,
|
public Method(int modifier, String name, RefTypeOrTPHOrWildcardOrGeneric returnType, ParameterList parameterList, Block block,
|
||||||
GenericDeclarationList gtvDeclarations, Token offset, Boolean isInherited) {
|
GenericDeclarationList gtvDeclarations, Token offset, Boolean isInherited, Boolean isOverridden) {
|
||||||
super(offset);
|
super(offset);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.modifier = modifier;
|
this.modifier = modifier;
|
||||||
@ -62,6 +64,7 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
|
|||||||
this.block = block;
|
this.block = block;
|
||||||
this.generics = gtvDeclarations;
|
this.generics = gtvDeclarations;
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
|
this.isImplemented = isOverridden;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParameterList getParameterList() {
|
public ParameterList getParameterList() {
|
||||||
@ -107,4 +110,10 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(name, parameterlist, returnType);
|
return Objects.hash(name, parameterlist, returnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,11 +105,46 @@ public class ASTFactory {
|
|||||||
allInheritedMethods.removeAll(allDeclaredMethods);
|
allInheritedMethods.removeAll(allDeclaredMethods);
|
||||||
for (java.lang.reflect.Method method : allDeclaredMethods) {
|
for (java.lang.reflect.Method method : allDeclaredMethods) {
|
||||||
var signature = methodSignatures.get(new Pair<>(method.getName(), org.objectweb.asm.Type.getMethodDescriptor(method)));
|
var signature = methodSignatures.get(new Pair<>(method.getName(), org.objectweb.asm.Type.getMethodDescriptor(method)));
|
||||||
methoden.add(createMethod(method, signature, jreClass, false));
|
if (jreClass.getSuperclass()==null) {
|
||||||
}
|
methoden.add(createMethod(method, signature, jreClass, false, false));
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
methoden.add(createMethod(method, signature, jreClass, false, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
methoden.add(createMethod(method, signature, jreClass, false, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}}
|
||||||
for (java.lang.reflect.Method method : allInheritedMethods) {
|
for (java.lang.reflect.Method method : allInheritedMethods) {
|
||||||
var signature = methodSignatures.get(new Pair<>(method.getName(), org.objectweb.asm.Type.getMethodDescriptor(method)));
|
var signature = methodSignatures.get(new Pair<>(method.getName(), org.objectweb.asm.Type.getMethodDescriptor(method)));
|
||||||
methoden.add(createMethod(method, signature, jreClass, true));
|
methoden.add(createMethod(method, signature, jreClass, true, false));
|
||||||
}
|
}
|
||||||
List<Field> felder = new ArrayList<>();
|
List<Field> felder = new ArrayList<>();
|
||||||
for (java.lang.reflect.Field field : jreClass.getDeclaredFields()) {
|
for (java.lang.reflect.Field field : jreClass.getDeclaredFields()) {
|
||||||
@ -192,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 */));
|
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) {
|
public static Method createMethod(java.lang.reflect.Method jreMethod, String signature, java.lang.Class inClass, Boolean isInherited, Boolean isImplemented) {
|
||||||
String name = jreMethod.getName();
|
String name = jreMethod.getName();
|
||||||
RefTypeOrTPHOrWildcardOrGeneric returnType;
|
RefTypeOrTPHOrWildcardOrGeneric returnType;
|
||||||
Type jreRetType;
|
Type jreRetType;
|
||||||
@ -218,7 +253,7 @@ public class ASTFactory {
|
|||||||
GenericDeclarationList gtvDeclarations = createGenerics(jreMethod.getTypeParameters(), inClass, jreMethod.getName(), signature);
|
GenericDeclarationList gtvDeclarations = createGenerics(jreMethod.getTypeParameters(), inClass, jreMethod.getName(), signature);
|
||||||
Token offset = new NullToken();
|
Token offset = new NullToken();
|
||||||
|
|
||||||
return new Method(jreMethod.getModifiers(), name, returnType, parameterList, block, gtvDeclarations, offset, isInherited);
|
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) {
|
public static GenericDeclarationList createGenerics(TypeVariable[] typeParameters, Class context, String methodName, String signature) {
|
||||||
|
@ -27,10 +27,10 @@ public class MethodCall extends Statement
|
|||||||
public RefTypeOrTPHOrWildcardOrGeneric receiverType;
|
public RefTypeOrTPHOrWildcardOrGeneric receiverType;
|
||||||
|
|
||||||
//sind Tphs, repraesentieren im Resultset die Signatur der aufgerufenen Methoden, letztes Element ist der Returntyp
|
//sind Tphs, repraesentieren im Resultset die Signatur der aufgerufenen Methoden, letztes Element ist der Returntyp
|
||||||
public final ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature;
|
public final ArrayList<TypePlaceholder> signature;
|
||||||
|
|
||||||
public MethodCall(RefTypeOrTPHOrWildcardOrGeneric retType, Receiver receiver, String methodName, ArgumentList argumentList,
|
public MethodCall(RefTypeOrTPHOrWildcardOrGeneric retType, Receiver receiver, String methodName, ArgumentList argumentList,
|
||||||
RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature, Token offset){
|
RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<TypePlaceholder> signature, Token offset){
|
||||||
super(retType,offset);
|
super(retType,offset);
|
||||||
this.arglist = argumentList;
|
this.arglist = argumentList;
|
||||||
this.name = methodName;
|
this.name = methodName;
|
||||||
@ -40,7 +40,7 @@ public class MethodCall extends Statement
|
|||||||
if (signature == null) throw new NullPointerException();
|
if (signature == null) throw new NullPointerException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RefTypeOrTPHOrWildcardOrGeneric> signatureArguments() {
|
public List<TypePlaceholder> signatureArguments() {
|
||||||
return signature.subList(0, signature.size() - 1);
|
return signature.subList(0, signature.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import de.dhbwstuttgart.syntaxtree.Method;
|
|||||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||||
@ -30,9 +31,9 @@ public class NewClass extends MethodCall
|
|||||||
* @param start
|
* @param start
|
||||||
*/
|
*/
|
||||||
public NewClass(RefType newClass, ArgumentList args, RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
public NewClass(RefType newClass, ArgumentList args, RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
||||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes, Token start) {
|
ArrayList<TypePlaceholder> signature, Token start) {
|
||||||
super(newClass, new ExpressionReceiver(new EmptyStmt(start)), newClass.getName().toString(),
|
super(newClass, new ExpressionReceiver(new EmptyStmt(start)), newClass.getName().toString(),
|
||||||
args, receiverType, argTypes, start);
|
args, receiverType, signature, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,7 @@ import de.dhbwstuttgart.parser.NullToken;
|
|||||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
|
|
||||||
@ -16,12 +17,12 @@ import java.util.List;
|
|||||||
public class SuperCall extends MethodCall
|
public class SuperCall extends MethodCall
|
||||||
{
|
{
|
||||||
public SuperCall(RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
public SuperCall(RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
||||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes, Token offset){
|
ArrayList<TypePlaceholder> argTypes, Token offset){
|
||||||
this(new ArgumentList(new ArrayList<Expression>(), offset), receiverType, argTypes, offset);
|
this(new ArgumentList(new ArrayList<Expression>(), offset), receiverType, argTypes, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuperCall(ArgumentList argumentList, RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
public SuperCall(ArgumentList argumentList, RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
||||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes, Token offset){
|
ArrayList<TypePlaceholder> argTypes, Token offset){
|
||||||
super(new Void(offset), new ExpressionReceiver(new Super(receiverType, offset)), "<init>", argumentList, receiverType, argTypes, offset);
|
super(new Void(offset), new ExpressionReceiver(new Super(receiverType, offset)), "<init>", argumentList, receiverType, argTypes, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
|
|||||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class ThisCall extends MethodCall
|
public class ThisCall extends MethodCall
|
||||||
{
|
{
|
||||||
public ThisCall(ArgumentList argumentList, RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes, Token offset) {
|
public ThisCall(ArgumentList argumentList, RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<TypePlaceholder> argTypes, Token offset) {
|
||||||
super(new Void(offset), new ExpressionReceiver(new This(offset)), "<init>", argumentList, receiverType, argTypes, offset);
|
super(new Void(offset), new ExpressionReceiver(new This(offset)), "<init>", argumentList, receiverType, argTypes, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,14 +20,16 @@ public class MethodAssumption extends Assumption{
|
|||||||
private RefTypeOrTPHOrWildcardOrGeneric retType;
|
private RefTypeOrTPHOrWildcardOrGeneric retType;
|
||||||
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params;
|
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params;
|
||||||
private final Boolean isInherited;
|
private final Boolean isInherited;
|
||||||
|
private final Boolean isOverridden;
|
||||||
|
|
||||||
public MethodAssumption(ClassOrInterface receiver, RefTypeOrTPHOrWildcardOrGeneric retType,
|
public MethodAssumption(ClassOrInterface receiver, RefTypeOrTPHOrWildcardOrGeneric retType,
|
||||||
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params, TypeScope scope, Boolean isInherited){
|
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params, TypeScope scope, Boolean isInherited, Boolean isOverridden){
|
||||||
super(scope);
|
super(scope);
|
||||||
this.receiver = receiver;
|
this.receiver = receiver;
|
||||||
this.retType = retType;
|
this.retType = retType;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
|
this.isOverridden = isOverridden;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -74,4 +76,8 @@ public class MethodAssumption extends Assumption{
|
|||||||
public Boolean isInherited() {
|
public Boolean isInherited() {
|
||||||
return isInherited;
|
return isInherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean isOverridden() {
|
||||||
|
return isOverridden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class Constraint<A> extends HashSet<A> {
|
public class Constraint<A> extends HashSet<A> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Boolean isInherited = false;//wird nur für die Method-Constraints benoetigt
|
private Boolean isInherited = false;//wird beides nur für die Method-Constraints benoetigt
|
||||||
|
private Boolean isImplemented = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wird verwendet um bei der Codegenerierung die richtige Methoden - Signatur
|
* wird verwendet um bei der Codegenerierung die richtige Methoden - Signatur
|
||||||
@ -22,12 +23,14 @@ public class Constraint<A> extends HashSet<A> {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint(Boolean isInherited) {
|
public Constraint(Boolean isInherited, Boolean isImplemented) {
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
|
this.isImplemented = isImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint(Boolean isInherited, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
|
public Constraint(Boolean isInherited, Boolean isImplemented, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
|
this.isImplemented = isImplemented;
|
||||||
this.extendConstraint = extendConstraint;
|
this.extendConstraint = extendConstraint;
|
||||||
this.methodSignatureConstraint = methodSignatureConstraint;
|
this.methodSignatureConstraint = methodSignatureConstraint;
|
||||||
}
|
}
|
||||||
@ -40,6 +43,10 @@ public class Constraint<A> extends HashSet<A> {
|
|||||||
return isInherited;
|
return isInherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean isImplemented() {
|
||||||
|
return isImplemented;
|
||||||
|
}
|
||||||
|
|
||||||
public Constraint<A> getExtendConstraint() {
|
public Constraint<A> getExtendConstraint() {
|
||||||
return extendConstraint;
|
return extendConstraint;
|
||||||
}
|
}
|
||||||
@ -57,7 +64,8 @@ public class Constraint<A> extends HashSet<A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + "\nisInherited = " + isInherited
|
return super.toString() + "\nisInherited = " + isInherited + " isOveridden = " + isImplemented
|
||||||
|
+ methodSignatureConstraint
|
||||||
//" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" )
|
//" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" )
|
||||||
+ "\n" ;
|
+ "\n" ;
|
||||||
}
|
}
|
||||||
|
@ -71,12 +71,13 @@ public class ConstraintSet<A> {
|
|||||||
|
|
||||||
for(Set<Constraint<A>> oderConstraint : oderConstraints){
|
for(Set<Constraint<A>> oderConstraint : oderConstraints){
|
||||||
newOder.add(
|
newOder.add(
|
||||||
oderConstraint.parallelStream().map((Constraint<A> as) -> {
|
oderConstraint.stream().map((Constraint<A> as) -> {
|
||||||
|
|
||||||
Constraint<B> newConst = as.stream()
|
Constraint<B> newConst = as.stream()
|
||||||
.map(o)
|
.map(o)
|
||||||
.collect(Collectors.toCollection((
|
.collect(Collectors.toCollection((
|
||||||
() -> new Constraint<B> (as.isInherited(),
|
() -> new Constraint<B> (as.isInherited(),
|
||||||
|
as.isImplemented(),
|
||||||
(as.getExtendConstraint() != null)
|
(as.getExtendConstraint() != null)
|
||||||
? as.getExtendConstraint().stream().map(o).collect(Collectors.toCollection(Constraint::new))
|
? as.getExtendConstraint().stream().map(o).collect(Collectors.toCollection(Constraint::new))
|
||||||
: null,
|
: null,
|
||||||
|
@ -591,7 +591,7 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
for (var ctor : clazz.getConstructors()) {
|
for (var ctor : clazz.getConstructors()) {
|
||||||
var params = convertParams(ctor.getParameterList(), info);
|
var params = convertParams(ctor.getParameterList(), info);
|
||||||
if (params.size() != superCall.arglist.getArguments().size()) continue;
|
if (params.size() != superCall.arglist.getArguments().size()) continue;
|
||||||
var assumption = new MethodAssumption(null, new Void(new NullToken()), params, createTypeScope(clazz, ctor), ctor.isInherited);
|
var assumption = new MethodAssumption(null, new Void(new NullToken()), params, createTypeScope(clazz, ctor), ctor.isInherited, false);
|
||||||
|
|
||||||
GenericsResolver resolver = getResolverInstance();
|
GenericsResolver resolver = getResolverInstance();
|
||||||
Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(superCall, assumption, info, resolver);
|
Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(superCall, assumption, info, resolver);
|
||||||
@ -607,7 +607,7 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
for (var ctor : info.getCurrentClass().getConstructors()) {
|
for (var ctor : info.getCurrentClass().getConstructors()) {
|
||||||
var params = convertParams(ctor.getParameterList(), info);
|
var params = convertParams(ctor.getParameterList(), info);
|
||||||
if (params.size() != thisCall.arglist.getArguments().size()) continue;
|
if (params.size() != thisCall.arglist.getArguments().size()) continue;
|
||||||
var assumption = new MethodAssumption(null, new Void(new NullToken()), params, createTypeScope(info.getCurrentClass(), ctor), ctor.isInherited);
|
var assumption = new MethodAssumption(null, new Void(new NullToken()), params, createTypeScope(info.getCurrentClass(), ctor), ctor.isInherited, false);
|
||||||
|
|
||||||
GenericsResolver resolver = getResolverInstance();
|
GenericsResolver resolver = getResolverInstance();
|
||||||
Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(thisCall, assumption, info, resolver);
|
Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(thisCall, assumption, info, resolver);
|
||||||
@ -640,8 +640,8 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
|
|
||||||
protected Set<Constraint<Pair>> generateConstraint(MethodCall forMethod, MethodAssumption assumption, TypeInferenceBlockInformation info, GenericsResolver resolver) {
|
protected Set<Constraint<Pair>> generateConstraint(MethodCall forMethod, MethodAssumption assumption, TypeInferenceBlockInformation info, GenericsResolver resolver) {
|
||||||
Constraint<Pair> methodConstraint, extendsMethodConstraint;
|
Constraint<Pair> methodConstraint, extendsMethodConstraint;
|
||||||
methodConstraint = new Constraint<>(assumption.isInherited());
|
methodConstraint = new Constraint<>(assumption.isInherited(), assumption.isOverridden());
|
||||||
extendsMethodConstraint = new Constraint<>(assumption.isInherited());// PL 2023-01-24: Ersetzt die Dopplung in visit(MethodCall)
|
extendsMethodConstraint = new Constraint<>(assumption.isInherited(), assumption.isOverridden());// PL 2023-01-24: Ersetzt die Dopplung in visit(MethodCall)
|
||||||
|
|
||||||
ClassOrInterface receiverCl = assumption.getReceiver();
|
ClassOrInterface receiverCl = assumption.getReceiver();
|
||||||
/*
|
/*
|
||||||
@ -746,14 +746,14 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
|
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}, false));
|
}, false, false));
|
||||||
}
|
}
|
||||||
for (ClassOrInterface cl : info.getAvailableClasses()) {
|
for (ClassOrInterface cl : info.getAvailableClasses()) {
|
||||||
for (Method m : cl.getMethods()) {
|
for (Method m : cl.getMethods()) {
|
||||||
if (m.getName().equals(name) && m.getParameterList().getFormalparalist().size() == numArgs) {
|
if (m.getName().equals(name) && m.getParameterList().getFormalparalist().size() == numArgs) {
|
||||||
RefTypeOrTPHOrWildcardOrGeneric retType = m.getReturnType();// info.checkGTV(m.getReturnType());
|
RefTypeOrTPHOrWildcardOrGeneric retType = m.getReturnType();// info.checkGTV(m.getReturnType());
|
||||||
|
|
||||||
ret.add(new MethodAssumption(cl, retType, convertParams(m.getParameterList(), info), createTypeScope(cl, m), m.isInherited));
|
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()) {
|
for (Method m : cl.getConstructors()) {
|
||||||
if (m.getParameterList().getFormalparalist().size() == argList.getArguments().size()) {
|
if (m.getParameterList().getFormalparalist().size() == argList.getArguments().size()) {
|
||||||
var params = convertParams(m.getParameterList(), info);
|
var params = convertParams(m.getParameterList(), info);
|
||||||
ret.add(new MethodAssumption(cl, cl.generateTypeOfThisClass(), params, createTypeScope(cl, m), m.isInherited));
|
ret.add(new MethodAssumption(cl, cl.generateTypeOfThisClass(), params, createTypeScope(cl, m), m.isInherited, m.isImplemented));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -702,9 +702,10 @@ public class RuleSet implements IRuleSet{
|
|||||||
x -> uni.apply(pair,x)).collect(Collectors.toCollection((b.getExtendConstraint() != null)
|
x -> uni.apply(pair,x)).collect(Collectors.toCollection((b.getExtendConstraint() != null)
|
||||||
? () -> new Constraint<UnifyPair>(
|
? () -> new Constraint<UnifyPair>(
|
||||||
b.isInherited(),
|
b.isInherited(),
|
||||||
|
b.isImplemented(),
|
||||||
b.getExtendConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(Constraint::new)),
|
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)))
|
b.getmethodSignatureConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(HashSet::new)))
|
||||||
: () -> new Constraint<UnifyPair>(b.isInherited())
|
: () -> new Constraint<UnifyPair>(b.isInherited(), b.isImplemented())
|
||||||
));
|
));
|
||||||
oderConstraints.replaceAll(oc -> oc.stream().map(applyUni).collect(Collectors.toCollection(HashSet::new)));
|
oderConstraints.replaceAll(oc -> oc.stream().map(applyUni).collect(Collectors.toCollection(HashSet::new)));
|
||||||
/*
|
/*
|
||||||
|
@ -253,13 +253,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
one = true;
|
one = true;
|
||||||
Set<UnifyPair> neweq = new HashSet<>(eq);
|
Set<UnifyPair> neweq = new HashSet<>(eq);
|
||||||
/* 1-elementige Oder-Constraints werden in und-Constraints umgewandelt */
|
/* 1-elementige Oder-Constraints werden in und-Constraints umgewandelt */
|
||||||
|
Set<UnifyPair> methodSignatureConstraint = new HashSet<>();
|
||||||
oderConstraintsField.stream()
|
oderConstraintsField.stream()
|
||||||
.filter(x -> x.size()==1)
|
.filter(x -> x.size()==1)
|
||||||
.map(y -> y.stream().findFirst().get()).forEach(x -> neweq.addAll(x));
|
.map(y -> y.stream().findFirst().get()).forEach(x -> { neweq.addAll(x); methodSignatureConstraint.addAll(x.getmethodSignatureConstraint());} );
|
||||||
ArrayList<Set<Constraint<UnifyPair>>> remainingOderconstraints = oderConstraintsField.stream()
|
ArrayList<Set<Constraint<UnifyPair>>> remainingOderconstraints = oderConstraintsField.stream()
|
||||||
.filter(x -> x.size()>1)
|
.filter(x -> x.size()>1)
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, new HashSet<>());
|
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, methodSignatureConstraint);
|
||||||
noOfThread--;
|
noOfThread--;
|
||||||
try {
|
try {
|
||||||
logFile.close();
|
logFile.close();
|
||||||
@ -598,11 +599,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
eqPrimePrimeSet.forEach(x -> x.addAll(methodSignatureConstraint));
|
eqPrimePrimeSet.forEach(x -> x.addAll(methodSignatureConstraint));
|
||||||
|
|
||||||
//Substitutionen in methodcontraintsets werdne ausgeführt
|
//Substitutionen in methodcontraintsets werdne ausgeführt
|
||||||
|
/* PL auskommentiert 2024-05-02
|
||||||
eqPrimePrimeSet = eqPrimePrimeSet.stream().map(
|
eqPrimePrimeSet = eqPrimePrimeSet.stream().map(
|
||||||
x -> { Optional<Set<UnifyPair>> help = rules.subst(x);
|
x -> { Optional<Set<UnifyPair>> help = rules.subst(x);
|
||||||
return help.isPresent() ?
|
return help.isPresent() ?
|
||||||
help.get():
|
help.get():
|
||||||
x; }).collect(Collectors.toSet());
|
x; }).collect(Collectors.toSet());
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
* Ende
|
* Ende
|
||||||
*/
|
*/
|
||||||
@ -813,6 +816,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
writeLog("nextSetasList: " + nextSetasList.toString());
|
writeLog("nextSetasList: " + nextSetasList.toString());
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
a = oup.max(nextSetasList.iterator());
|
a = oup.max(nextSetasList.iterator());
|
||||||
|
writeLog("Max: a in " + variance + " "+ a);
|
||||||
nextSetasList.remove(a);
|
nextSetasList.remove(a);
|
||||||
if (oderConstraint) {
|
if (oderConstraint) {
|
||||||
nextSetasListOderConstraints.add(((Constraint<UnifyPair>)a).getExtendConstraint());
|
nextSetasListOderConstraints.add(((Constraint<UnifyPair>)a).getExtendConstraint());
|
||||||
@ -1350,12 +1354,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
while(aParDefIt.hasNext()) {
|
while(aParDefIt.hasNext()) {
|
||||||
Set<UnifyPair> a_new = aParDefIt.next();
|
Set<UnifyPair> a_new = aParDefIt.next();
|
||||||
List<Set<UnifyPair>> smallerSetasList = oup.smallerThan(a_new, nextSetasList);
|
List<Set<UnifyPair>> smallerSetasList = oup.smallerThan(a_new, nextSetasList);
|
||||||
|
writeLog("smallerSetasList: " + smallerSetasList);
|
||||||
List<Set<UnifyPair>> notInherited = smallerSetasList.stream()
|
List<Set<UnifyPair>> notInherited = smallerSetasList.stream()
|
||||||
.filter(x -> !((Constraint<UnifyPair>)x).isInherited())
|
.filter(x -> !((Constraint<UnifyPair>)x).isInherited() && !((Constraint<UnifyPair>)x).isImplemented())
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
writeLog("notInherited: " + notInherited+"\n");
|
||||||
List<Set<UnifyPair>> notErased = new ArrayList<>();
|
List<Set<UnifyPair>> notErased = new ArrayList<>();
|
||||||
notInherited.stream().forEach(x -> { notErased.addAll(oup.smallerEqThan(x, smallerSetasList)); });
|
notInherited.stream().forEach(x -> { notErased.addAll(oup.smallerEqThan(x, smallerSetasList)); });
|
||||||
List<Set<UnifyPair>> erased = new ArrayList<>(smallerSetasList);
|
List<Set<UnifyPair>> erased = new ArrayList<>(smallerSetasList);
|
||||||
|
writeLog("notErased: " + notErased+"\n");
|
||||||
erased.removeAll(notErased);
|
erased.removeAll(notErased);
|
||||||
nextSetasList.removeAll(erased);
|
nextSetasList.removeAll(erased);
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify;
|
||||||
import de.dhbwstuttgart.util.Pair;
|
import de.dhbwstuttgart.util.Pair;
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
|
import org.apache.commons.io.output.NullWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The finite closure for the type unification
|
* The finite closure for the type unification
|
||||||
@ -140,6 +141,10 @@ implements IFiniteClosure {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FiniteClosure(Set<UnifyPair> constraints, Writer writer) {
|
||||||
|
this(constraints, writer, null);
|
||||||
|
}
|
||||||
|
|
||||||
void testSmaller() {
|
void testSmaller() {
|
||||||
UnifyType tq1, tq2, tq3;
|
UnifyType tq1, tq2, tq3;
|
||||||
tq1 = new ExtendsType(PlaceholderType.freshPlaceholder());
|
tq1 = new ExtendsType(PlaceholderType.freshPlaceholder());
|
||||||
@ -694,7 +699,7 @@ implements IFiniteClosure {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public int compare (UnifyType left, UnifyType right, PairOperator pairop) {
|
public int compare (UnifyType left, UnifyType right, PairOperator pairop) {
|
||||||
//try {logFile.write("left: "+ left + " right: " + right + " pairop: " + pairop);} catch (IOException ie) {}
|
try {logFile.write("left: "+ left + " right: " + right + " pairop: " + pairop +"\n");} catch (IOException ie) {}
|
||||||
if (left.getName().equals("Matrix") || right.getName().equals("Matrix"))
|
if (left.getName().equals("Matrix") || right.getName().equals("Matrix"))
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
/*
|
/*
|
||||||
@ -751,15 +756,15 @@ implements IFiniteClosure {
|
|||||||
HashSet<UnifyPair> hs = new HashSet<>();
|
HashSet<UnifyPair> hs = new HashSet<>();
|
||||||
hs.add(up);
|
hs.add(up);
|
||||||
Set<UnifyPair> smallerRes = unifyTask.applyTypeUnificationRules(hs, this);
|
Set<UnifyPair> smallerRes = unifyTask.applyTypeUnificationRules(hs, this);
|
||||||
/*
|
|
||||||
//if (left.getName().equals("Matrix") || right.getName().equals("Matrix"))
|
//if (left.getName().equals("Vector") || right.getName().equals("AbstractList"))
|
||||||
{try {
|
{try {
|
||||||
logFile.write("\nsmallerRes: " + smallerRes);//"smallerHash: " + greaterHash.toString());
|
logFile.write("\nsmallerRes: " + smallerRes);//"smallerHash: " + greaterHash.toString());
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("no LogFile");}}
|
System.err.println("no LogFile");}}
|
||||||
*/
|
|
||||||
//Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok.
|
//Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok.
|
||||||
Predicate<UnifyPair> delFun = x -> !((x.getLhsType() instanceof PlaceholderType ||
|
Predicate<UnifyPair> delFun = x -> !((x.getLhsType() instanceof PlaceholderType ||
|
||||||
x.getRhsType() instanceof PlaceholderType)
|
x.getRhsType() instanceof PlaceholderType)
|
||||||
@ -767,6 +772,12 @@ implements IFiniteClosure {
|
|||||||
((WildcardType)x.getLhsType()).getWildcardedType().equals(x.getRhsType()))
|
((WildcardType)x.getLhsType()).getWildcardedType().equals(x.getRhsType()))
|
||||||
);
|
);
|
||||||
long smallerLen = smallerRes.stream().filter(delFun).count();
|
long smallerLen = smallerRes.stream().filter(delFun).count();
|
||||||
|
try {
|
||||||
|
logFile.write("\nsmallerLen: " + smallerLen +"\n");
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.err.println("no LogFile");}
|
||||||
if (smallerLen == 0) return -1;
|
if (smallerLen == 0) return -1;
|
||||||
else {
|
else {
|
||||||
up = new UnifyPair(right, left, pairop);
|
up = new UnifyPair(right, left, pairop);
|
||||||
@ -774,15 +785,15 @@ implements IFiniteClosure {
|
|||||||
hs = new HashSet<>();
|
hs = new HashSet<>();
|
||||||
hs.add(up);
|
hs.add(up);
|
||||||
Set<UnifyPair> greaterRes = unifyTask.applyTypeUnificationRules(hs, this);
|
Set<UnifyPair> greaterRes = unifyTask.applyTypeUnificationRules(hs, this);
|
||||||
/*
|
|
||||||
//if (left.getName().equals("Matrix") || right.getName().equals("Matrix"))
|
//if (left.getName().equals("Vector") || right.getName().equals("AbstractList"))
|
||||||
{try {
|
{try {
|
||||||
logFile.write("\ngreaterRes: " + greaterRes);//"smallerHash: " + greaterHash.toString());
|
logFile.write("\ngreaterRes: " + greaterRes);//"smallerHash: " + greaterHash.toString());
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("no LogFile");}}
|
System.err.println("no LogFile");}}
|
||||||
*/
|
|
||||||
//Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok.
|
//Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok.
|
||||||
long greaterLen = greaterRes.stream().filter(delFun).count();
|
long greaterLen = greaterRes.stream().filter(delFun).count();
|
||||||
if (greaterLen == 0) return 1;
|
if (greaterLen == 0) return 1;
|
||||||
|
@ -34,6 +34,12 @@ public class ReferenceType extends UnifyType {
|
|||||||
this.genericTypeVar = genericTypeVar;
|
this.genericTypeVar = genericTypeVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReferenceType(String name, UnifyType... params) {
|
||||||
|
super(name, new TypeParams(params));
|
||||||
|
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
||||||
|
genericTypeVar = false;
|
||||||
|
}
|
||||||
|
|
||||||
public ReferenceType(String name, TypeParams params) {
|
public ReferenceType(String name, TypeParams params) {
|
||||||
super(name, params);
|
super(name, params);
|
||||||
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
||||||
|
@ -4,6 +4,7 @@ import org.junit.Ignore;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
|
import java.util.AbstractList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
@ -180,7 +181,7 @@ public class TestComplete {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore()
|
//@Ignore()
|
||||||
public void matrixOpTest() throws Exception {
|
public void matrixOpTest() throws Exception {
|
||||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "MatrixOP.jav");
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "MatrixOP.jav");
|
||||||
var matrixOP = classFiles.get("MatrixOP");
|
var matrixOP = classFiles.get("MatrixOP");
|
||||||
@ -263,7 +264,7 @@ public class TestComplete {
|
|||||||
|
|
||||||
var instanceOfClass_m2 = matrix.getDeclaredConstructor(Vector.class).newInstance(vv1);
|
var instanceOfClass_m2 = matrix.getDeclaredConstructor(Vector.class).newInstance(vv1);
|
||||||
|
|
||||||
var mul = matrix.getDeclaredMethod("mul", Vector.class);
|
var mul = matrix.getDeclaredMethod("mul", List.class);
|
||||||
var result = mul.invoke(instanceOfClass_m1, instanceOfClass_m2);
|
var result = mul.invoke(instanceOfClass_m1, instanceOfClass_m2);
|
||||||
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
|
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user