forked from JavaTX/JavaCompilerCore
modified: src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java
renamed: src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/ClassConstraint.java -> src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java renamed: src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java -> src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java renamed: src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/GGenerics.java -> src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/GGenerics.java renamed: src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/MethodConstraint.java -> src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/MethodConstraint.java renamed: src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/PositionFinder.java -> src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/PositionFinder.java renamed: src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/preGGenerics.java -> src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/preGGenerics.java modified: src/test/java/constraintSimplify/FamilyOfGenerics.java modified: src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java modified: src/test/java/insertGenerics/TestExample42.java modified: src/test/java/insertGenerics/TestTransitiveClosure.java
This commit is contained in:
parent
531b1ccd22
commit
9cf7cec37b
@ -9,7 +9,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics;
|
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.MethodAndConstraints;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.MethodAndConstraints;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package de.dhbwstuttgart.bytecode.gGenericsAli;
|
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
|
|
@ -1,11 +1,7 @@
|
|||||||
package de.dhbwstuttgart.bytecode.gGenericsAli;
|
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -189,8 +185,7 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
for (TPHConstraint tphC: tempList) {
|
for (TPHConstraint tphC: tempList) {
|
||||||
hasSame = constraint.getLeft() == tphC.getLeft() &&
|
hasSame = constraint.getLeft() == tphC.getLeft() &&
|
||||||
constraint.getRight() == tphC.getRight() &&
|
constraint.getRight() == tphC.getRight() &&
|
||||||
constraint.getRel() == tphC.getRel(); //constraint already in ArrayList if
|
constraint.getRel() == tphC.getRel(); //constraint already in ArrayList if true
|
||||||
// System.out.println(hasSame);
|
|
||||||
if (hasSame)
|
if (hasSame)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -198,22 +193,19 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<TPHConstraint> buildTransitiveClosure(List list) {
|
public static List<TPHConstraint> buildTransitiveClosure(List list) {
|
||||||
List<TPHConstraint> iterList = list;
|
List<TPHConstraint> iterList = new ArrayList<>(list);
|
||||||
List<TPHConstraint> runList = list;
|
List<TPHConstraint> runList = new ArrayList<>(list);
|
||||||
List<TPHConstraint> tcList = list;
|
List<TPHConstraint> tcList = new ArrayList<>(list);
|
||||||
boolean addedConToList = false;
|
boolean addedConToList = false;
|
||||||
for (TPHConstraint cons: iterList) {
|
for (TPHConstraint cons: iterList) {
|
||||||
for (TPHConstraint cons2: runList) {
|
for (TPHConstraint cons2: runList) {
|
||||||
if(cons.getRight() == cons2.getLeft()) {
|
if(cons.getRight() == cons2.getLeft()) {
|
||||||
TPHConstraint consToAdd = new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS);
|
TPHConstraint consToAdd = new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS);
|
||||||
// System.out.println(consToAdd);
|
|
||||||
// System.out.println(tcList);
|
|
||||||
// System.out.println(checkForDuplicates(consToAdd,tcList));
|
|
||||||
if (!checkForDuplicates(consToAdd,tcList)) {
|
if (!checkForDuplicates(consToAdd,tcList)) {
|
||||||
tcList.add(consToAdd); //Duplikate? dürfte nicht sein -> checken
|
tcList.add(consToAdd);
|
||||||
addedConToList = true;
|
addedConToList = true;
|
||||||
if (addedConToList) {
|
if (addedConToList) {
|
||||||
buildTransitiveClosure(tcList);
|
return buildTransitiveClosure(tcList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO: über aktualisierte Liste laufen wegen Updates -> Rekursion?
|
//TODO: über aktualisierte Liste laufen wegen Updates -> Rekursion?
|
@ -1,4 +1,4 @@
|
|||||||
package de.dhbwstuttgart.bytecode.gGenericsAli;
|
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
|
|
@ -1,6 +1,5 @@
|
|||||||
package de.dhbwstuttgart.bytecode.gGenericsAli;
|
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package de.dhbwstuttgart.bytecode.gGenericsAli;
|
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
|
|
@ -1,27 +1,18 @@
|
|||||||
package constraintSimplify;
|
package constraintSimplify;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics;
|
import de.dhbwstuttgart.bytecode.insertGenerics.PositionFinder;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.PositionFinder;
|
|
||||||
import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder;
|
import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder;
|
||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
|
||||||
import de.dhbwstuttgart.parser.NullToken;
|
import de.dhbwstuttgart.parser.NullToken;
|
||||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
import org.antlr.v4.runtime.Token;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.nio.file.NotLinkException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package insertGenerics;
|
package insertGenerics;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.ClassConstraint;
|
import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics;
|
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.MethodConstraint;
|
import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.PositionFinder;
|
import de.dhbwstuttgart.bytecode.insertGenerics.PositionFinder;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -47,7 +47,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gives constraint: A <. B, which is a method constraint
|
gives constraint: A <. B, which is a class constraint
|
||||||
*/
|
*/
|
||||||
|
|
||||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||||
|
@ -2,10 +2,10 @@ package insertGenerics;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.ClassConstraint;
|
import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics;
|
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.MethodConstraint;
|
import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.PositionFinder;
|
import de.dhbwstuttgart.bytecode.insertGenerics.PositionFinder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -2,15 +2,11 @@ package insertGenerics;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.ClassConstraint;
|
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.FamilyOfGeneratedGenerics;
|
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.MethodConstraint;
|
|
||||||
import de.dhbwstuttgart.bytecode.gGenericsAli.PositionFinder;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TestTransitiveClosure {
|
public class TestTransitiveClosure {
|
||||||
|
Loading…
Reference in New Issue
Block a user