forked from JavaTX/JavaCompilerCore
Merged with simplifyRes and cleaned up code
This commit is contained in:
parent
3ecb202a90
commit
25c685c705
@ -3,13 +3,9 @@ package de.dhbwstuttgart.bytecode;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.FieldVisitor;
|
import org.objectweb.asm.FieldVisitor;
|
||||||
@ -18,22 +14,18 @@ import org.objectweb.asm.Opcodes;
|
|||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
|
||||||
import de.dhbwstuttgart.bytecode.descriptor.DescriptorToString;
|
import de.dhbwstuttgart.bytecode.descriptor.DescriptorToString;
|
||||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
||||||
import de.dhbwstuttgart.bytecode.signature.Signature;
|
import de.dhbwstuttgart.bytecode.signature.Signature;
|
||||||
import de.dhbwstuttgart.bytecode.signature.TypeToSignature;
|
import de.dhbwstuttgart.bytecode.signature.TypeToSignature;
|
||||||
import de.dhbwstuttgart.bytecode.signature.TypeToString;
|
import de.dhbwstuttgart.bytecode.signature.TypeToString;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.SimplifyResult;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericGenratorResultForSourceFile;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericsGeneratorResult;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericsGeneratorResultForClass;
|
|
||||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
|
||||||
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.NormalConstructor;
|
import de.dhbwstuttgart.bytecode.utilities.NormalConstructor;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.NormalMethod;
|
import de.dhbwstuttgart.bytecode.utilities.NormalMethod;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
|
||||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||||
@ -80,7 +72,6 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
|
|
||||||
public class BytecodeGen implements ASTVisitor {
|
public class BytecodeGen implements ASTVisitor {
|
||||||
@ -204,7 +195,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
List<GenericsGeneratorResult> consClass = generatedGenerics.getClassConstraints();
|
List<GenericsGeneratorResult> consClass = generatedGenerics.getClassConstraints();
|
||||||
//
|
//
|
||||||
Signature signature = new Signature(classOrInterface, genericsAndBounds, consClass);
|
Signature signature = new Signature(classOrInterface, genericsAndBounds, consClass);
|
||||||
sig = signature.toString();
|
sig = signature.createSignatureForClassOrInterface();
|
||||||
System.out.println("Signature: => " + sig);
|
System.out.println("Signature: => " + sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,12 +210,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Constructor c : classOrInterface.getConstructors()) {
|
for (Constructor c : classOrInterface.getConstructors()) {
|
||||||
// if(!isConsWithNoParamsVisited) {
|
|
||||||
c.accept(this);
|
c.accept(this);
|
||||||
// }
|
|
||||||
|
|
||||||
// if(!c.getParameterList().iterator().hasNext())
|
|
||||||
// isConsWithNoParamsVisited = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Method m : classOrInterface.getMethods()) {
|
for (Method m : classOrInterface.getMethods()) {
|
||||||
@ -237,12 +223,6 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(Constructor field) {
|
public void visit(Constructor field) {
|
||||||
System.out.println("ResultSet: ");
|
|
||||||
resultSet.results.forEach(a -> {
|
|
||||||
System.out.println(a.getLeft().toString() + " = " + a.getRight().toString());
|
|
||||||
});
|
|
||||||
System.out.println("---------------");
|
|
||||||
|
|
||||||
// stores generics and their bounds of method
|
// stores generics and their bounds of method
|
||||||
HashMap<String, String> genericsAndBoundsMethod = new HashMap<>();
|
HashMap<String, String> genericsAndBoundsMethod = new HashMap<>();
|
||||||
|
|
||||||
@ -270,15 +250,10 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
String sig = null;
|
String sig = null;
|
||||||
if (hasGen) {
|
if (hasGen) {
|
||||||
List<GenericsGeneratorResult> constraints = generatedGenerics.getClassConstraints();
|
List<GenericsGeneratorResult> constraints = generatedGenerics.getClassConstraints();
|
||||||
// Map<TPHConstraint, Set<String>> constraints = generatedGenerics.getMethodConstraintsByID(methParamTypes);
|
|
||||||
//// ArrayList<GenericInsertPair> pairs = simplifyPairs(method.name,tphExtractor.allPairs,tphExtractor.allCons);
|
|
||||||
Signature signature = new Signature(genericsAndBounds,
|
Signature signature = new Signature(genericsAndBounds,
|
||||||
methodParamsAndTypes, resultSet, constraints);
|
methodParamsAndTypes, resultSet, constraints);
|
||||||
|
|
||||||
sig = signature.createSignatureForConstructor(field);
|
sig = signature.createSignatureForConstructor(field);
|
||||||
// Map<TPHConstraint, Set<String>> constraints = generatedGenerics.getMethodConstraintsByID(methParamTypes);
|
|
||||||
// Signature signature = new Signature(field, genericsAndBounds, methodParamsAndTypes, resultSet, constraints);
|
|
||||||
// sig = signature.toString();
|
|
||||||
}
|
}
|
||||||
if (field.getParameterList().iterator().hasNext())
|
if (field.getParameterList().iterator().hasNext())
|
||||||
System.out.println(field.getParameterList().iterator().next().getType().acceptTV(new TypeToDescriptor()));
|
System.out.println(field.getParameterList().iterator().next().getType().acceptTV(new TypeToDescriptor()));
|
||||||
@ -363,8 +338,6 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
|
|
||||||
List<GenericsGeneratorResult> constraints = generatedGenerics.getMethodConstraintsByID(id);
|
List<GenericsGeneratorResult> constraints = generatedGenerics.getMethodConstraintsByID(id);
|
||||||
List<GenericsGeneratorResult> classConstraints = generatedGenerics.getClassConstraints();
|
List<GenericsGeneratorResult> classConstraints = generatedGenerics.getClassConstraints();
|
||||||
// Map<TPHConstraint, Set<String>> constraints = generatedGenerics.getMethodConstraintsByID(methParamTypes);
|
|
||||||
//// ArrayList<GenericInsertPair> pairs = simplifyPairs(method.name,tphExtractor.allPairs,tphExtractor.allCons);
|
|
||||||
Signature signature = new Signature(genericsAndBoundsMethod, genericsAndBounds,
|
Signature signature = new Signature(genericsAndBoundsMethod, genericsAndBounds,
|
||||||
methodParamsAndTypes, resultSet, constraints,classConstraints);
|
methodParamsAndTypes, resultSet, constraints,classConstraints);
|
||||||
sig = signature.createSignatureForMethod(method);
|
sig = signature.createSignatureForMethod(method);
|
||||||
@ -373,7 +346,6 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
NormalMethod meth = new NormalMethod(method, genericsAndBounds, genericsAndBoundsMethod, hasGen);
|
NormalMethod meth = new NormalMethod(method, genericsAndBounds, genericsAndBoundsMethod, hasGen);
|
||||||
methDesc = meth.accept(new DescriptorToString(resultSet));
|
methDesc = meth.accept(new DescriptorToString(resultSet));
|
||||||
|
|
||||||
// System.out.println(methDesc);
|
|
||||||
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC + acc, method.getName(), methDesc, sig, null);
|
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC + acc, method.getName(), methDesc, sig, null);
|
||||||
|
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
package de.dhbwstuttgart.bytecode.genericsGenerator;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.NameReplacementResult;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGenerator.NameReplacementResult;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the result of the constraints simplifier.
|
* This class represents the result of the constraints simplifier.
|
@ -7,8 +7,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.ConstraintsSimplierResult;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.*;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericsGeneratorResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fayez
|
* @author fayez
|
||||||
@ -19,8 +18,7 @@ public class ConstraintsSimplifier {
|
|||||||
|
|
||||||
List<TPHConstraint> allCons = tphExtractor.allCons;
|
List<TPHConstraint> allCons = tphExtractor.allCons;
|
||||||
List<TPHConstraint> equalCons = new ArrayList<>();
|
List<TPHConstraint> equalCons = new ArrayList<>();
|
||||||
List<SimpleCycle> simpleCycles = findSimpleCycles(allCons);
|
|
||||||
|
|
||||||
/* Step 1 */
|
/* Step 1 */
|
||||||
List<ConstraintsWithSameLeftSide> foundCons = GenericsGeneratorUtility.findConstraintsWithLeftSameLeftSide(allCons);
|
List<ConstraintsWithSameLeftSide> foundCons = GenericsGeneratorUtility.findConstraintsWithLeftSameLeftSide(allCons);
|
||||||
if(!foundCons.isEmpty()) {
|
if(!foundCons.isEmpty()) {
|
||||||
@ -34,10 +32,10 @@ public class ConstraintsSimplifier {
|
|||||||
// equalCons.addAll(GenericsGeneratorUtility.getEqualConstraints(allCons));
|
// equalCons.addAll(GenericsGeneratorUtility.getEqualConstraints(allCons));
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
List<LongCycle> longCycles = findLongCycles(allCons);
|
List<Cycle> cycles = findCycles(allCons);
|
||||||
|
|
||||||
if(!longCycles.isEmpty()) {
|
if(!cycles.isEmpty()) {
|
||||||
handleLongCycle(genericsGeneratorResults, allCons, longCycles,tphExtractor);
|
handleCycle(genericsGeneratorResults, allCons, cycles,tphExtractor);
|
||||||
}
|
}
|
||||||
/* The right hand side of equal constraint is the new name in name replacement result */
|
/* The right hand side of equal constraint is the new name in name replacement result */
|
||||||
List<NameReplacementResult> nameReplacementResults = GenericsGeneratorUtility.createNameReplacementResultsFromEqualConstraints(equalCons);
|
List<NameReplacementResult> nameReplacementResults = GenericsGeneratorUtility.createNameReplacementResultsFromEqualConstraints(equalCons);
|
||||||
@ -114,13 +112,13 @@ public class ConstraintsSimplifier {
|
|||||||
/**
|
/**
|
||||||
* @param genericsGeneratorResults
|
* @param genericsGeneratorResults
|
||||||
* @param allCons
|
* @param allCons
|
||||||
* @param longCycles
|
* @param cycles
|
||||||
* @param tphExtractor
|
* @param tphExtractor
|
||||||
*/
|
*/
|
||||||
public static void handleLongCycle(List<GenericsGeneratorResult> genericsGeneratorResults,
|
public static void handleCycle(List<GenericsGeneratorResult> genericsGeneratorResults,
|
||||||
List<TPHConstraint> allCons, List<LongCycle> longCycles, TPHExtractor tphExtractor) {
|
List<TPHConstraint> allCons, List<Cycle> cycles, TPHExtractor tphExtractor) {
|
||||||
GenericsGeneratorUtility.modifyRelationForConstraintsinLongCycle(longCycles);
|
GenericsGeneratorUtility.modifyRelationForConstraintsInCycle(cycles);
|
||||||
List<NameReplacementResult> nameReplacementResults = GenericsGeneratorUtility.substituteTPHSFormLongCycle(allCons, longCycles,tphExtractor);
|
List<NameReplacementResult> nameReplacementResults = GenericsGeneratorUtility.substituteTPHSFormCycle(allCons, cycles,tphExtractor);
|
||||||
GenericsGeneratorUtility.createResults(genericsGeneratorResults,nameReplacementResults);
|
GenericsGeneratorUtility.createResults(genericsGeneratorResults,nameReplacementResults);
|
||||||
GenericsGeneratorUtility.removeEqualConstraints(allCons);
|
GenericsGeneratorUtility.removeEqualConstraints(allCons);
|
||||||
}
|
}
|
||||||
@ -129,33 +127,11 @@ public class ConstraintsSimplifier {
|
|||||||
* @param allCons
|
* @param allCons
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<LongCycle> findLongCycles(List<TPHConstraint> allCons) {
|
public static List<Cycle> findCycles(List<TPHConstraint> allCons) {
|
||||||
/* find all long cycles */
|
/* find all cycles */
|
||||||
CyclesFinder cyclesFinder = new CyclesFinder(allCons);
|
CyclesFinder cyclesFinder = new CyclesFinder(allCons);
|
||||||
List<LongCycle> longCycles = cyclesFinder.findLongCycles();
|
List<Cycle> cycles = cyclesFinder.findCycles();
|
||||||
return longCycles;
|
return cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param allCons
|
|
||||||
* @param simpleCycles
|
|
||||||
* @param tphExtractor
|
|
||||||
*/
|
|
||||||
public static void handleSimpleCycles(List<TPHConstraint> allCons, List<SimpleCycle> simpleCycles, TPHExtractor tphExtractor) {
|
|
||||||
GenericsGeneratorUtility.modifyRelation(simpleCycles);
|
|
||||||
GenericsGeneratorUtility.removeAllReverseConstraints(allCons,simpleCycles);
|
|
||||||
GenericsGeneratorUtility.substituteTPH(allCons, simpleCycles);
|
|
||||||
GenericsGeneratorUtility.replaceOldNames(simpleCycles,tphExtractor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param allCons
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static List<SimpleCycle> findSimpleCycles(List<TPHConstraint> allCons) {
|
|
||||||
CyclesFinder cyclesFinder = new CyclesFinder(allCons);
|
|
||||||
/* find all simple cycles if they are exist */
|
|
||||||
List<SimpleCycle> simpleCycles = cyclesFinder.findSimpleCycles();
|
|
||||||
return simpleCycles;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
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.genericsGeneratorTypes.Cycle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fayez
|
* @author fayez
|
||||||
@ -22,46 +23,22 @@ public class CyclesFinder {
|
|||||||
this.allCons = allCons;
|
this.allCons = allCons;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SimpleCycle> findSimpleCycles() {
|
public List<Cycle> findCycles() {
|
||||||
List<SimpleCycle> simpleCycles = new ArrayList<>();
|
|
||||||
allCons.forEach(c -> {
|
|
||||||
String left = c.getLeft();
|
|
||||||
String right = c.getRight();
|
|
||||||
if (c.getRel() == Relation.EXTENDS && !containsInCycle(c, simpleCycles)) {
|
|
||||||
Optional<TPHConstraint> revCon = GenericsGeneratorUtility.getReverseConstraint(allCons, left, right);
|
|
||||||
if (revCon.isPresent()) {
|
|
||||||
TPHConstraint reverseConstraint = revCon.get();
|
|
||||||
SimpleCycle simpleCycle = new SimpleCycle(c, reverseConstraint);
|
|
||||||
simpleCycles.add(simpleCycle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return simpleCycles;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean containsInCycle(TPHConstraint c, List<SimpleCycle> simpleCycles) {
|
|
||||||
return simpleCycles.stream().filter(sc -> {
|
|
||||||
return sc.contains(c);
|
|
||||||
}).count() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<LongCycle> findLongCycles() {
|
|
||||||
List<TPHConstraint> vistedConstraints = new ArrayList<>(allCons.size());
|
List<TPHConstraint> vistedConstraints = new ArrayList<>(allCons.size());
|
||||||
List<LongCycle> longCycles = new ArrayList<>();
|
List<Cycle> cycles = new ArrayList<>();
|
||||||
for (TPHConstraint constraint : allCons) {
|
for (TPHConstraint constraint : allCons) {
|
||||||
if(constraint.getRel()==Relation.EQUAL)
|
if(constraint.getRel()==Relation.EQUAL)
|
||||||
continue;
|
continue;
|
||||||
if (!vistedConstraints.contains(constraint)) {
|
if (!vistedConstraints.contains(constraint)) {
|
||||||
vistedConstraints.add(constraint);
|
vistedConstraints.add(constraint);
|
||||||
checkConstraint(constraint, vistedConstraints, longCycles);
|
checkConstraint(constraint, vistedConstraints, cycles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return longCycles;
|
return cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkConstraint(TPHConstraint constraint, List<TPHConstraint> vistedConstraints,
|
private void checkConstraint(TPHConstraint constraint, List<TPHConstraint> vistedConstraints,
|
||||||
List<LongCycle> longCycles) {
|
List<Cycle> cycles) {
|
||||||
List<String> tphsInRelation = new LinkedList<>();
|
List<String> tphsInRelation = new LinkedList<>();
|
||||||
List<TPHConstraint> maybeCycle = new ArrayList<>();
|
List<TPHConstraint> maybeCycle = new ArrayList<>();
|
||||||
maybeCycle.add(constraint);
|
maybeCycle.add(constraint);
|
||||||
@ -69,13 +46,13 @@ public class CyclesFinder {
|
|||||||
tphsInRelation.add(constraint.getRight());
|
tphsInRelation.add(constraint.getRight());
|
||||||
Optional<TPHConstraint> nextConstraint = getConstraintInRelation(tphsInRelation, maybeCycle);
|
Optional<TPHConstraint> nextConstraint = getConstraintInRelation(tphsInRelation, maybeCycle);
|
||||||
while (nextConstraint.isPresent()) {
|
while (nextConstraint.isPresent()) {
|
||||||
if(containsInLongCycle(nextConstraint.get(), longCycles)) {
|
if(containsInLongCycle(nextConstraint.get(), cycles)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isCycle(tphsInRelation)) {
|
if (isCycle(tphsInRelation)) {
|
||||||
addAllToVisitedConstraints(vistedConstraints, maybeCycle);
|
addAllToVisitedConstraints(vistedConstraints, maybeCycle);
|
||||||
LongCycle cycle = new LongCycle(maybeCycle);
|
Cycle cycle = new Cycle(maybeCycle);
|
||||||
longCycles.add(cycle);
|
cycles.add(cycle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nextConstraint = getConstraintInRelation(tphsInRelation, maybeCycle);
|
nextConstraint = getConstraintInRelation(tphsInRelation, maybeCycle);
|
||||||
@ -84,8 +61,8 @@ public class CyclesFinder {
|
|||||||
// addAllToVisitedConstraints(vistedConstraints, maybeCycle);
|
// addAllToVisitedConstraints(vistedConstraints, maybeCycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsInLongCycle(TPHConstraint c, List<LongCycle> longCycles) {
|
private boolean containsInLongCycle(TPHConstraint c, List<Cycle> cycles) {
|
||||||
for(LongCycle cycle : longCycles) {
|
for(Cycle cycle : cycles) {
|
||||||
if(cycle.containConstraint(c))
|
if(cycle.containConstraint(c))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
package de.dhbwstuttgart.bytecode.genericsGenerator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGenerator.GenericsGenerator;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.MethodAndConstraints;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGenerator.GenericsGeneratorUtility;
|
|
||||||
import de.dhbwstuttgart.bytecode.signature.Signature;
|
|
||||||
import de.dhbwstuttgart.bytecode.signature.TypeToSignature;
|
|
||||||
import de.dhbwstuttgart.bytecode.signature.TypeToString;
|
|
||||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
|
||||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||||
@ -69,7 +57,6 @@ import de.dhbwstuttgart.syntaxtree.statement.WhileStmt;
|
|||||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
@ -148,14 +135,8 @@ public class GeneratedGenericsFinder implements ASTVisitor {
|
|||||||
if(!isVisited) {
|
if(!isVisited) {
|
||||||
ggResult = GenericsGenerator.generateConstraints(className, tphExtractor, tphsClass,simplifiedConstraints);
|
ggResult = GenericsGenerator.generateConstraints(className, tphExtractor, tphsClass,simplifiedConstraints);
|
||||||
isVisited = true;
|
isVisited = true;
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for(Constructor m : classOrInterface.getConstructors()) {
|
|
||||||
// addMethodConstraints(simplifiedConstraints, ggResult, m);
|
|
||||||
// }
|
|
||||||
|
|
||||||
for(Method m : classOrInterface.getMethods()) {
|
for(Method m : classOrInterface.getMethods()) {
|
||||||
addMethodConstraints(simplifiedConstraints, ggResult, m);
|
addMethodConstraints(simplifiedConstraints, ggResult, m);
|
||||||
|
|
@ -11,18 +11,13 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.*;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericGeneratorResultsForAllMethods;
|
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.ConstraintsSimplierResult;
|
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericsGeneratorResult;
|
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericsGeneratorResultForClass;
|
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.MethodAndConstraints;
|
|
||||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||||
import de.dhbwstuttgart.syntaxtree.Method;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fayez
|
* @author fayez
|
||||||
|
@ -12,6 +12,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.*;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
@ -19,7 +20,6 @@ import de.dhbwstuttgart.bytecode.constraint.EqualConstraint;
|
|||||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||||
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.simplifyRes.GenericsGeneratorResult;
|
|
||||||
import de.dhbwstuttgart.bytecode.utilities.ConstraintsFinder;
|
import de.dhbwstuttgart.bytecode.utilities.ConstraintsFinder;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.NameReplacer;
|
import de.dhbwstuttgart.bytecode.utilities.NameReplacer;
|
||||||
@ -74,21 +74,6 @@ public class GenericsGeneratorUtility {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void modifyRelation(List<SimpleCycle> simpleCycles) {
|
|
||||||
simpleCycles.forEach(sc->{
|
|
||||||
sc.getConstraint().setRel(Relation.EQUAL);
|
|
||||||
sc.getReverseConstraint().setRel(Relation.EQUAL);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeAllReverseConstraints(List<TPHConstraint> allCons, List<SimpleCycle> simpleCycles) {
|
|
||||||
simpleCycles.forEach(sc->allCons.remove(sc.getReverseConstraint()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void substituteTPH(List<TPHConstraint> allCons, List<SimpleCycle> simpleCycles) {
|
|
||||||
simpleCycles.forEach(sc->substituteTPH(allCons, sc.getConstraint().getLeft(), sc.getConstraint().getRight()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ConstraintsWithSameLeftSide> findConstraintsWithLeftSameLeftSide(List<TPHConstraint> allCons) {
|
public static List<ConstraintsWithSameLeftSide> findConstraintsWithLeftSameLeftSide(List<TPHConstraint> allCons) {
|
||||||
// finder looks for constraints that have the same left hand side
|
// finder looks for constraints that have the same left hand side
|
||||||
// and put them in a list
|
// and put them in a list
|
||||||
@ -279,13 +264,13 @@ public class GenericsGeneratorUtility {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void modifyRelationForConstraintsinLongCycle(List<LongCycle> longCycles) {
|
public static void modifyRelationForConstraintsInCycle(List<Cycle> cycles) {
|
||||||
longCycles.stream().map(lc->lc.getConstraints()).flatMap(e->e.stream()).forEach(c->c.setRel(Relation.EQUAL));
|
cycles.stream().map(lc->lc.getConstraints()).flatMap(e->e.stream()).forEach(c->c.setRel(Relation.EQUAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<NameReplacementResult> substituteTPHSFormLongCycle(List<TPHConstraint> allCons, List<LongCycle> longCycles, TPHExtractor tphExtractor) {
|
public static List<NameReplacementResult> substituteTPHSFormCycle(List<TPHConstraint> allCons, List<Cycle> cycles, TPHExtractor tphExtractor) {
|
||||||
List<NameReplacementResult> results = new ArrayList<>();
|
List<NameReplacementResult> results = new ArrayList<>();
|
||||||
longCycles.forEach(lc->{
|
cycles.forEach(lc->{
|
||||||
Set<String> names = getNamesFromCycle(lc);
|
Set<String> names = getNamesFromCycle(lc);
|
||||||
String newName = names.stream().findFirst().get();
|
String newName = names.stream().findFirst().get();
|
||||||
|
|
||||||
@ -328,7 +313,7 @@ public class GenericsGeneratorUtility {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getNamesFromCycle(LongCycle lc) {
|
public static Set<String> getNamesFromCycle(Cycle lc) {
|
||||||
Set<String> names = new HashSet<>();
|
Set<String> names = new HashSet<>();
|
||||||
lc.getConstraints().forEach(c->names.add(c.getLeft()));
|
lc.getConstraints().forEach(c->names.add(c.getLeft()));
|
||||||
return names;
|
return names;
|
||||||
@ -388,23 +373,6 @@ public class GenericsGeneratorUtility {
|
|||||||
return allCons.stream().filter(c->c.getRight().equals(tph)).findFirst();
|
return allCons.stream().filter(c->c.getRight().equals(tph)).findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void replaceOldNames(List<SimpleCycle> simpleCycles, TPHExtractor tphExtractor) {
|
|
||||||
simpleCycles.forEach(sc -> {
|
|
||||||
Stream<ArrayList<String>> tphsOfMethods = tphExtractor.ListOfMethodsAndTph.stream().map(m->m.getTphs());
|
|
||||||
Stream<ArrayList<String>> localTphsOfMethods = tphExtractor.ListOfMethodsAndTph.stream().map(m->m.getLocalTphs());
|
|
||||||
|
|
||||||
String newName = sc.getConstraint().getRight();
|
|
||||||
String oldName = sc.getConstraint().getLeft();
|
|
||||||
|
|
||||||
List<String> names = new ArrayList<>();
|
|
||||||
names.add(oldName);
|
|
||||||
names.add(newName);
|
|
||||||
|
|
||||||
replaceOldNames(newName, names, tphsOfMethods);
|
|
||||||
replaceOldNames(newName, names, localTphsOfMethods);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isTPHInGenericGeneratorResult(final List<GenericsGeneratorResult> constraints, final String tph) {
|
public static boolean isTPHInGenericGeneratorResult(final List<GenericsGeneratorResult> constraints, final String tph) {
|
||||||
return constraints.stream().filter(g->g.getConstraint().getLeft().equals(tph)).findFirst().isPresent();
|
return constraints.stream().filter(g->g.getConstraint().getLeft().equals(tph)).findFirst().isPresent();
|
||||||
}
|
}
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package de.dhbwstuttgart.bytecode.genericsGenerator;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fayez
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SimpleCycle {
|
|
||||||
private TPHConstraint constraint;
|
|
||||||
private TPHConstraint reverseConstraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param constraint
|
|
||||||
* @param reverseConstraint
|
|
||||||
*/
|
|
||||||
public SimpleCycle(TPHConstraint constraint, TPHConstraint reverseConstraint) {
|
|
||||||
this.constraint = constraint;
|
|
||||||
this.reverseConstraint = reverseConstraint;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the constraint
|
|
||||||
*/
|
|
||||||
public TPHConstraint getConstraint() {
|
|
||||||
return constraint;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param constraint the constraint to set
|
|
||||||
*/
|
|
||||||
public void setConstraint(TPHConstraint constraint) {
|
|
||||||
this.constraint = constraint;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the reverseConstraint
|
|
||||||
*/
|
|
||||||
public TPHConstraint getReverseConstraint() {
|
|
||||||
return reverseConstraint;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param reverseConstraint the reverseConstraint to set
|
|
||||||
*/
|
|
||||||
public void setReverseConstraint(TPHConstraint reverseConstraint) {
|
|
||||||
this.reverseConstraint = reverseConstraint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean contains(TPHConstraint c) {
|
|
||||||
if (constraint.getLeft().equals(c.getLeft()) && constraint.getRight().equals(c.getRight())
|
|
||||||
&& constraint.getRel().equals(c.getRel()))
|
|
||||||
return true;
|
|
||||||
if (reverseConstraint.getLeft().equals(c.getLeft()) && reverseConstraint.getRight().equals(c.getRight())
|
|
||||||
&& reverseConstraint.getRel().equals(c.getRel()))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return constraint.toString() + " -> " + reverseConstraint.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package de.dhbwstuttgart.bytecode.genericsGenerator;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.genericsGenerator;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -11,13 +11,13 @@ import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
|||||||
* @author fayez
|
* @author fayez
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LongCycle {
|
public class Cycle {
|
||||||
private final List<TPHConstraint> constraints;
|
private final List<TPHConstraint> constraints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constraints
|
* @param constraints
|
||||||
*/
|
*/
|
||||||
public LongCycle(List<TPHConstraint> constraints) {
|
public Cycle(List<TPHConstraint> constraints) {
|
||||||
this.constraints = constraints;
|
this.constraints = constraints;
|
||||||
}
|
}
|
||||||
|
|
@ -1,13 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.Collections2;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fayez
|
* @author fayez
|
||||||
*
|
*
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.genericsGenerator;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -6,12 +6,9 @@ import org.objectweb.asm.Type;
|
|||||||
import org.objectweb.asm.signature.SignatureVisitor;
|
import org.objectweb.asm.signature.SignatureVisitor;
|
||||||
import org.objectweb.asm.signature.SignatureWriter;
|
import org.objectweb.asm.signature.SignatureWriter;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
|
||||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericsGeneratorResult;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||||
@ -22,8 +19,6 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.WildcardType;
|
|
||||||
import de.dhbwstuttgart.typeinference.result.ResolvedType;
|
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
|
|
||||||
public class Signature {
|
public class Signature {
|
||||||
@ -75,21 +70,18 @@ public class Signature {
|
|||||||
this.classOrInterface = classOrInterface;
|
this.classOrInterface = classOrInterface;
|
||||||
this.genericsAndBounds = genericsAndBounds;
|
this.genericsAndBounds = genericsAndBounds;
|
||||||
this.consClass = consClass;
|
this.consClass = consClass;
|
||||||
createSignatureForClassOrInterface();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Signature(HashMap<String, String> genericsAndBoundsMethod,
|
public Signature(HashMap<String, String> genericsAndBoundsMethod,
|
||||||
HashMap<String, String> genericsAndBounds,
|
HashMap<String, String> genericsAndBounds,
|
||||||
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes, ResultSet resultSet,
|
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes, ResultSet resultSet,
|
||||||
List<GenericsGeneratorResult> constraints,List<GenericsGeneratorResult> consClass) {
|
List<GenericsGeneratorResult> constraints,List<GenericsGeneratorResult> consClass) {
|
||||||
//this.method = method;
|
|
||||||
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
|
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
|
||||||
this.genericsAndBounds = genericsAndBounds;
|
this.genericsAndBounds = genericsAndBounds;
|
||||||
this.methodParamsAndTypes = methodParamsAndTypes;
|
this.methodParamsAndTypes = methodParamsAndTypes;
|
||||||
this.resultSet = resultSet;
|
this.resultSet = resultSet;
|
||||||
this.constraints = constraints;
|
this.constraints = constraints;
|
||||||
this.consClass = consClass;
|
this.consClass = consClass;
|
||||||
//createSignatureForMethod(this.method);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createSignatureForConstructor(Constructor constructor) {
|
public String createSignatureForConstructor(Constructor constructor) {
|
||||||
@ -145,33 +137,19 @@ public class Signature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createSignatureForFunN(int numberOfParams, String to, String[] paramTypes) {
|
private void createSignatureForFunN(int numberOfParams, String to, String[] paramTypes) {
|
||||||
for (int i = 0; i < numberOfParams; i++) {
|
defineTypeVariablesForParametersOfFunN(numberOfParams);
|
||||||
int j = i + 1;
|
|
||||||
sw.visitFormalTypeParameter("T" + j);
|
|
||||||
// getBounds von Params
|
|
||||||
sw.visitClassBound().visitClassType(paramTypes[i]);
|
|
||||||
sw.visitClassBound().visitEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.visitFormalTypeParameter("R");
|
sw.visitFormalTypeParameter("R");
|
||||||
visitClassBound(to);
|
visitClassBound(to);
|
||||||
// TODO: prüfe ob Return-Type = void,
|
// TODO: prüfe ob Return-Type = void,
|
||||||
sw.visitSuperclass().visitClassType(Type.getInternalName(Object.class));
|
sw.visitSuperclass().visitClassType(Type.getInternalName(Object.class));
|
||||||
;
|
|
||||||
sw.visitEnd();
|
sw.visitEnd();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSignatureForFunN(int numberOfParams) {
|
private void createSignatureForFunN(int numberOfParams) {
|
||||||
|
|
||||||
// sw.visitClassBound().visitEnd();
|
defineTypeVariablesForParametersOfFunN(numberOfParams);
|
||||||
for (int i = 0; i < numberOfParams; i++) {
|
|
||||||
int j = i + 1;
|
|
||||||
sw.visitFormalTypeParameter("T" + j);
|
|
||||||
// getBounds von Params
|
|
||||||
sw.visitClassBound().visitClassType(Type.getInternalName(Object.class));
|
|
||||||
sw.visitClassBound().visitEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.visitFormalTypeParameter("R");
|
sw.visitFormalTypeParameter("R");
|
||||||
// getBounds vom Return-Type
|
// getBounds vom Return-Type
|
||||||
@ -179,171 +157,17 @@ public class Signature {
|
|||||||
sw.visitClassBound().visitEnd();
|
sw.visitClassBound().visitEnd();
|
||||||
// TODO: prüfe ob Return-Type = void,
|
// TODO: prüfe ob Return-Type = void,
|
||||||
sw.visitSuperclass().visitClassType(Type.getInternalName(Object.class));
|
sw.visitSuperclass().visitClassType(Type.getInternalName(Object.class));
|
||||||
;
|
|
||||||
sw.visitEnd();
|
sw.visitEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void defineTypeVariablesForParametersOfFunN(int numberOfParams) {
|
||||||
* Creates signature for a method or constructor with @see
|
for (int i = 0; i < numberOfParams; i++) {
|
||||||
* {@link SignatureWriter} Signature looks like: <typevaliables
|
int j = i + 1;
|
||||||
* (K:Ljava/lang/Object "Bounds")>(params L.. OR T.. Or basistape)ReturnType
|
sw.visitFormalTypeParameter("T" + j);
|
||||||
*
|
// getBounds von Params
|
||||||
* @param method method or constructor
|
sw.visitClassBound().visitClassType(Type.getInternalName(Object.class));
|
||||||
* @param isConstructor true if constructor
|
sw.visitClassBound().visitEnd();
|
||||||
*/
|
|
||||||
private void createSignatureForConsOrMethod(Method method, boolean isConstructor) {
|
|
||||||
Iterator<? extends GenericTypeVar> itr = method.getGenerics().iterator();
|
|
||||||
// visits all formal type parameter and visits their bounds <T:...;B:...;...>
|
|
||||||
while (itr.hasNext()) {
|
|
||||||
System.out.println("HAS GENERICS!!");
|
|
||||||
GenericTypeVar g = itr.next();
|
|
||||||
visitTypeVarsAndTheirBounds(g, genericsAndBoundsMethod);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wenn die RückgabeType eine TPH ist, wird als generic behandelt
|
|
||||||
// z.B: Type = TPH K => wird eine Formal Type Parameter K$ erzeugt und Bound =
|
|
||||||
// Object
|
|
||||||
if (!isConstructor) {
|
|
||||||
String ret = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToSignature());
|
|
||||||
ArrayList<TPHConstraint> allConsBeforeSimplify = new ArrayList<>();
|
|
||||||
|
|
||||||
Map<TPHConstraint, Set<String>> allConstraints = new HashMap<>();
|
|
||||||
|
|
||||||
if (ret.contains("<")) {
|
|
||||||
allConsBeforeSimplify = getAllConstraints(
|
|
||||||
(RefType) resultSet.resolveType(method.getReturnType()).resolvedType);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String paramName : methodParamsAndTypes.keySet()) {
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric t = methodParamsAndTypes.get(paramName);
|
|
||||||
String pT = t.acceptTV(new TypeToSignature());
|
|
||||||
|
|
||||||
if (pT.contains("<"))
|
|
||||||
allConsBeforeSimplify = getAllConstraints((RefType) t);
|
|
||||||
}
|
|
||||||
boolean doSimplify = false;
|
|
||||||
if (!allConsBeforeSimplify.isEmpty()) {
|
|
||||||
addConstraintsToMap(allConstraints, allConsBeforeSimplify);
|
|
||||||
doSimplify = true;
|
|
||||||
}
|
|
||||||
createTypeVars(allConstraints, doSimplify);
|
|
||||||
|
|
||||||
if (!ret.equals("V")) {
|
|
||||||
if (ret.contains(SPECIAL_CHAR) && !ret.contains(SPECIAL_CHAR_FOR_FUN) && !ret.contains("<")) {
|
|
||||||
if (genericsAndBounds.containsKey(ret)) {
|
|
||||||
genericsAndBoundsMethod.put(ret.substring(1), genericsAndBounds.get(ret.substring(1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
visitParams();
|
|
||||||
if (isConstructor || resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToSignature())
|
|
||||||
.equals("V")) {
|
|
||||||
sw.visitReturnType().visitBaseType('V');
|
|
||||||
} else {
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric returnType = method.getReturnType();
|
|
||||||
// return type deswegen ist false
|
|
||||||
// doVisitParamsOrReturn(returnType, false);
|
|
||||||
}
|
|
||||||
// sw.visitEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addConstraintsToMap(Map<TPHConstraint, Set<String>> allConstraints,
|
|
||||||
ArrayList<TPHConstraint> allConsBeforeSimplify) {
|
|
||||||
for (TPHConstraint tphCons : allConsBeforeSimplify) {
|
|
||||||
allConstraints.put(tphCons, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getEqualTPH(Map<TPHConstraint, Set<String>> methodConstraints2, String tph) {
|
|
||||||
for (TPHConstraint cons : methodConstraints2.keySet()) {
|
|
||||||
if (methodConstraints2.get(cons) != null) {
|
|
||||||
if (methodConstraints2.get(cons).contains(tph)) {
|
|
||||||
return cons.getLeft();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tph;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createTypeVars(Map<TPHConstraint, Set<String>> allConstraints, boolean doSimplify) {
|
|
||||||
allConstraints.putAll(methodConstraints);
|
|
||||||
|
|
||||||
Map<TPHConstraint, Set<String>> simplifiedConstraints;
|
|
||||||
if (doSimplify) {
|
|
||||||
simplifiedConstraints = Simplify.simplifyContraints(allConstraints);
|
|
||||||
} else {
|
|
||||||
simplifiedConstraints = allConstraints;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (TPHConstraint cons : simplifiedConstraints.keySet()) {
|
|
||||||
// need subst.
|
|
||||||
String sub = cons.getLeft() + SPECIAL_CHAR;
|
|
||||||
if (!genericsAndBoundsMethod.containsKey(sub) && !genericsAndBounds.containsKey(sub)) {
|
|
||||||
sw.visitFormalTypeParameter(sub);
|
|
||||||
String bound = cons.getRight();
|
|
||||||
if (bound.equals(Type.getInternalName(Object.class))) {
|
|
||||||
sw.visitClassBound().visitClassType(Type.getInternalName(Object.class));
|
|
||||||
sw.visitClassBound().visitEnd();
|
|
||||||
genericsAndBoundsMethod.put(sub, bound);
|
|
||||||
} else {
|
|
||||||
String boundName = bound + SPECIAL_CHAR;
|
|
||||||
sw.visitClassBound().visitTypeVariable(boundName);
|
|
||||||
genericsAndBoundsMethod.put(sub, boundName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayList<TPHConstraint> getAllConstraints(RefType ref) {
|
|
||||||
final ArrayList<TPHConstraint> res = new ArrayList<>();
|
|
||||||
for (RefTypeOrTPHOrWildcardOrGeneric p : ref.getParaList()) {
|
|
||||||
ResolvedType resType;
|
|
||||||
if (p instanceof WildcardType) {
|
|
||||||
resType = resultSet.resolveType(((WildcardType) p).getInnerType());
|
|
||||||
} else {
|
|
||||||
resType = resultSet.resolveType(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric resolved = resType.resolvedType;
|
|
||||||
if (resolved instanceof TypePlaceholder) {
|
|
||||||
// resType.getAdditionalGenerics().forEach(ag ->{
|
|
||||||
resultSet.genIns.forEach(ag -> {
|
|
||||||
TPHConstraint constr = new ExtendsConstraint(ag.getLeft().getName(), ag.getRight().getName());
|
|
||||||
if (!contains(res, constr)) {
|
|
||||||
res.add(constr);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (resolved instanceof WildcardType) {
|
|
||||||
WildcardType resWC = (WildcardType) resolved;
|
|
||||||
ResolvedType resType2 = resultSet.resolveType(resWC.getInnerType());
|
|
||||||
if (resType2.resolvedType instanceof TypePlaceholder) {
|
|
||||||
// resType2.getAdditionalGenerics().forEach(ag ->{
|
|
||||||
resultSet.genIns.forEach(ag -> {
|
|
||||||
TPHConstraint constr = new ExtendsConstraint(ag.getLeft().getName(), ag.getRight().getName());
|
|
||||||
if (!contains(res, constr)) {
|
|
||||||
res.add(constr);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
System.out.println("RES GIP === " + res.size());
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean contains(ArrayList<TPHConstraint> constraints, TPHConstraint constr) {
|
|
||||||
for (int i = 0; i < constraints.size(); ++i) {
|
|
||||||
TPHConstraint p = constraints.get(i);
|
|
||||||
if (constr.getLeft().equals(p.getLeft()) && constr.getRight().equals(p.getRight()))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -363,8 +187,7 @@ public class Signature {
|
|||||||
break;
|
break;
|
||||||
case "GRT":
|
case "GRT":
|
||||||
GenericRefType g = (GenericRefType) t;
|
GenericRefType g = (GenericRefType) t;
|
||||||
// sv.visitTypeVariable(g.acceptTV(new TypeToSignature()).substring(1));
|
sv.visitTypeVariable(g.acceptTV(new TypeToSignature(constraints)));
|
||||||
sv.visitTypeVariable(g.acceptTV(new TypeToSignature()));
|
|
||||||
break;
|
break;
|
||||||
case "TPH":
|
case "TPH":
|
||||||
RefTypeOrTPHOrWildcardOrGeneric r = resultSet.resolveType(t).resolvedType;
|
RefTypeOrTPHOrWildcardOrGeneric r = resultSet.resolveType(t).resolvedType;
|
||||||
@ -375,13 +198,12 @@ public class Signature {
|
|||||||
// das braucht man nicht es reicht: sv.visitTypeVariable(r.acceptTV(new
|
// das braucht man nicht es reicht: sv.visitTypeVariable(r.acceptTV(new
|
||||||
// TypeToSignature())
|
// TypeToSignature())
|
||||||
//
|
//
|
||||||
String sig2 = r.acceptTV(new TypeToSignature());
|
String sig2 = r.acceptTV(new TypeToSignature(constraints));
|
||||||
if (r instanceof GenericRefType) {
|
if (r instanceof GenericRefType) {
|
||||||
sv.visitTypeVariable(sig2);
|
sv.visitTypeVariable(sig2);
|
||||||
} else if (!(r instanceof TypePlaceholder)) {
|
} else if (!(r instanceof TypePlaceholder)) {
|
||||||
if (sig2.contains(SPECIAL_CHAR_FOR_FUN)) {
|
if (sig2.contains(SPECIAL_CHAR_FOR_FUN)) {
|
||||||
System.out.println(" Signature FUN$$: " + r);
|
sv.visitInterface().visitClassType(sig2.substring(1));
|
||||||
sv.visitInterface().visitClassType(sig2.substring(1, sig2.length()));
|
|
||||||
} else {
|
} else {
|
||||||
// Kann zwischen GenericRefType und RefType nicht unterscheiden
|
// Kann zwischen GenericRefType und RefType nicht unterscheiden
|
||||||
// Deswegen wird immer geprüft, ob der Name in Generic Maps liegt
|
// Deswegen wird immer geprüft, ob der Name in Generic Maps liegt
|
||||||
@ -405,7 +227,6 @@ public class Signature {
|
|||||||
} else {
|
} else {
|
||||||
toVisit = getEqualTPH(constraints, realName) + SPECIAL_CHAR;
|
toVisit = getEqualTPH(constraints, realName) + SPECIAL_CHAR;
|
||||||
}
|
}
|
||||||
System.out.println(r.getClass() + " Signature TPH: " + r.acceptTV(new TypeToSignature()));
|
|
||||||
}
|
}
|
||||||
sv.visitTypeVariable(toVisit);
|
sv.visitTypeVariable(toVisit);
|
||||||
}
|
}
|
||||||
@ -413,41 +234,18 @@ public class Signature {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "SWC":
|
case "SWC":
|
||||||
System.out.println("SWC---Signature");
|
|
||||||
SuperWildcardType swc = (SuperWildcardType) t;
|
SuperWildcardType swc = (SuperWildcardType) t;
|
||||||
String sigInner = swc.getInnerType().acceptTV(new TypeToSignature(constraints));
|
String sigInner = swc.getInnerType().acceptTV(new TypeToSignature(constraints));
|
||||||
if (swc.getInnerType() instanceof TypePlaceholder) {
|
int length = sigInner.length();
|
||||||
sv.visitTypeArgument(SUPER_CHAR).visitTypeVariable(sigInner.substring(1, sigInner.length()));
|
visitWildCard(sv, sigInner, length, swc.getInnerType(), SUPER_CHAR);
|
||||||
} else if (swc.getInnerType() instanceof RefType) {
|
|
||||||
if (sigInner.contains(SPECIAL_CHAR_FOR_FUN)) {
|
|
||||||
sv.visitTypeArgument(SUPER_CHAR).visitInterface().visitClassType(sigInner.substring(1, sigInner.length()));
|
|
||||||
} else {
|
|
||||||
sv.visitTypeArgument(SUPER_CHAR).visitClassType(sigInner.substring(1, sigInner.length()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sv.visitTypeArgument(SUPER_CHAR).visitTypeVariable(sigInner.substring(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "EWC":
|
case "EWC":
|
||||||
System.out.println("EWC---Signature");
|
|
||||||
ExtendsWildcardType ewc = (ExtendsWildcardType) t;
|
ExtendsWildcardType ewc = (ExtendsWildcardType) t;
|
||||||
String esigInner = ewc.getInnerType().acceptTV(new TypeToSignature(constraints));
|
String esigInner = ewc.getInnerType().acceptTV(new TypeToSignature(constraints));
|
||||||
System.out.println(esigInner);
|
int lengthEWCSig = esigInner.length();
|
||||||
if (ewc.getInnerType() instanceof TypePlaceholder) {
|
visitWildCard(sv, esigInner, lengthEWCSig, ewc.getInnerType(), EXTENDS_CHAR);
|
||||||
sv.visitTypeArgument(EXTENDS_CHAR).visitTypeVariable(esigInner.substring(1, esigInner.length()));
|
|
||||||
} else if (ewc.getInnerType() instanceof RefType) {
|
|
||||||
if (esigInner.contains(SPECIAL_CHAR_FOR_FUN)) {
|
|
||||||
sv.visitTypeArgument(EXTENDS_CHAR).visitInterface()
|
|
||||||
.visitClassType(esigInner.substring(1, esigInner.length()));
|
|
||||||
} else {
|
|
||||||
// sv.visitClassType(esigInner.substring(1,esigInner.length()));
|
|
||||||
sv.visitTypeArgument(EXTENDS_CHAR).visitClassType(esigInner.substring(1, esigInner.length()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sv.visitTypeArgument(EXTENDS_CHAR).visitTypeVariable(esigInner.substring(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -457,6 +255,24 @@ public class Signature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void visitWildCard(SignatureVisitor sv, String sigInner, int length, RefTypeOrTPHOrWildcardOrGeneric innerType, char superOrExtendsChar) {
|
||||||
|
if (innerType instanceof TypePlaceholder) {
|
||||||
|
sv.visitTypeArgument(superOrExtendsChar).visitTypeVariable(sigInner.substring(1, length));
|
||||||
|
} else if (innerType instanceof RefType) {
|
||||||
|
checkInnerSignatureOfWildCard(sv, sigInner, length, superOrExtendsChar);
|
||||||
|
} else {
|
||||||
|
sv.visitTypeArgument(superOrExtendsChar).visitTypeVariable(sigInner.substring(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkInnerSignatureOfWildCard(SignatureVisitor sv, String sigInner, int length, char superOrExtendsChar) {
|
||||||
|
if (sigInner.contains(SPECIAL_CHAR_FOR_FUN)) {
|
||||||
|
sv.visitTypeArgument(superOrExtendsChar).visitInterface().visitClassType(sigInner.substring(1, length));
|
||||||
|
} else {
|
||||||
|
sv.visitTypeArgument(superOrExtendsChar).visitClassType(sigInner.substring(1, length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Optional<GenericsGeneratorResult> getEqualTPHFromClassConstraints(List<GenericsGeneratorResult> consClass, String tph) {
|
private Optional<GenericsGeneratorResult> getEqualTPHFromClassConstraints(List<GenericsGeneratorResult> consClass, String tph) {
|
||||||
return consClass.stream()
|
return consClass.stream()
|
||||||
.filter(c -> c.getConstraint().getLeft().equals(tph) || c.getEqualsTPHs().contains(tph))
|
.filter(c -> c.getConstraint().getLeft().equals(tph) || c.getEqualsTPHs().contains(tph))
|
||||||
@ -469,38 +285,29 @@ public class Signature {
|
|||||||
.findFirst().get().getConstraint().getLeft();
|
.findFirst().get().getConstraint().getLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param isParameterType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private SignatureVisitor getSignatureVisitor(boolean isParameterType) {
|
|
||||||
SignatureVisitor sv;
|
|
||||||
if (isParameterType) {
|
|
||||||
sv = sw.visitParameterType();
|
|
||||||
} else {
|
|
||||||
sv = sw.visitReturnType();
|
|
||||||
}
|
|
||||||
return sv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates signature for class or interface with {@link SignatureWriter}
|
* Creates signature for class or interface with {@link SignatureWriter}
|
||||||
* Signature looks like: <typevaliables (K:Ljava/lang/Object
|
* Signature looks like: <typevaliables (K:Ljava/lang/Object
|
||||||
* "Bounds")>superclass
|
* "Bounds")>superclass
|
||||||
*/
|
*/
|
||||||
private void createSignatureForClassOrInterface() {
|
public String createSignatureForClassOrInterface() {
|
||||||
Iterator<GenericTypeVar> itr = classOrInterface.getGenerics().iterator();
|
defineTypeVariablesForClassOrInterface();
|
||||||
|
|
||||||
while (itr.hasNext()) {
|
|
||||||
GenericTypeVar g = itr.next();
|
|
||||||
visitTypeVarsAndTheirBounds(g, genericsAndBounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
defineGenericsFromConstraints(consClass,genericsAndBounds);
|
defineGenericsFromConstraints(consClass,genericsAndBounds);
|
||||||
|
|
||||||
String sClass = classOrInterface.getSuperClass().acceptTV(new TypeToSignature());
|
String sClass = classOrInterface.getSuperClass().acceptTV(new TypeToSignature());
|
||||||
sw.visitSuperclass().visitClassType(sClass.substring(1, sClass.length() - 1));
|
sw.visitSuperclass().visitClassType(sClass.substring(1, sClass.length() - 1));
|
||||||
sw.visitEnd();
|
sw.visitEnd();
|
||||||
|
return sw.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void defineTypeVariablesForClassOrInterface() {
|
||||||
|
Iterator<GenericTypeVar> itr = classOrInterface.getGenerics().iterator();
|
||||||
|
|
||||||
|
while (itr.hasNext()) {
|
||||||
|
GenericTypeVar g = itr.next();
|
||||||
|
visitTypeVarsAndTheirBounds(g, genericsAndBounds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -553,7 +360,6 @@ public class Signature {
|
|||||||
while (bItr.hasNext()) {
|
while (bItr.hasNext()) {
|
||||||
RefTypeOrTPHOrWildcardOrGeneric b = bItr.next();
|
RefTypeOrTPHOrWildcardOrGeneric b = bItr.next();
|
||||||
String boundDesc = b.acceptTV(new TypeToDescriptor());
|
String boundDesc = b.acceptTV(new TypeToDescriptor());
|
||||||
// System.out.println("GetBounds: " + boundDesc);
|
|
||||||
// Ensure that <...> extends java.lang.Object OR ...
|
// Ensure that <...> extends java.lang.Object OR ...
|
||||||
if (b instanceof GenericRefType) {
|
if (b instanceof GenericRefType) {
|
||||||
sw.visitClassBound().visitTypeVariable(boundDesc);
|
sw.visitClassBound().visitTypeVariable(boundDesc);
|
||||||
@ -562,11 +368,6 @@ public class Signature {
|
|||||||
}
|
}
|
||||||
genAndBounds.put(g.getName(), boundDesc);
|
genAndBounds.put(g.getName(), boundDesc);
|
||||||
}
|
}
|
||||||
// sw.visitClassBound().visitEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return sw.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericsGeneratorResult;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The class SimplifyResult represents the results of the simplify algorithm.
|
|
||||||
* This class contains all constraints and all type placeholders of a class. The type placeholders
|
|
||||||
* are represented by their names.
|
|
||||||
* The simplify results of each method of a class are also contained in this class.
|
|
||||||
*
|
|
||||||
* @author fayez
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SimplifyResult {
|
|
||||||
private List<TPHConstraint> classConstraints;
|
|
||||||
private List<String> tphsClass;
|
|
||||||
private final List<SimplifyResultMethod> simplifyResultForMethod = new ArrayList<>();
|
|
||||||
|
|
||||||
public SimplifyResult(List<TPHConstraint> classConstraints, List<String> tphsClass) {
|
|
||||||
this.classConstraints = classConstraints;
|
|
||||||
this.tphsClass = tphsClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimplifyResult() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TPHConstraint> getClassConstraints() {
|
|
||||||
return classConstraints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SimplifyResultMethod> getSimplifyResultForMethod() {
|
|
||||||
return simplifyResultForMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getTphsClass() {
|
|
||||||
return tphsClass==null?new ArrayList<>():tphsClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param classConstraints the classConstraints to set
|
|
||||||
*/
|
|
||||||
public void setClassConstraints(List<TPHConstraint> classConstraints) {
|
|
||||||
this.classConstraints = classConstraints;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tphsClass the tphsClass to set
|
|
||||||
*/
|
|
||||||
public void setTphsClass(List<String> tphsClass) {
|
|
||||||
this.tphsClass = tphsClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<TPHConstraint, Set<String>> getMethodConstraintsByID(String id){
|
|
||||||
return simplifyResultForMethod.stream().filter(sr->sr.getMethodID().equals(id)).findAny().get().getConastraintsAndEqualTPHs();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The simplify results of a class
|
|
||||||
*
|
|
||||||
* @author fayez
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SimplifyResultClass {
|
|
||||||
private final String className;
|
|
||||||
private SimplifyResult simplifyResults;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param className
|
|
||||||
*/
|
|
||||||
public SimplifyResultClass(String className) {
|
|
||||||
this.className = className;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param className
|
|
||||||
* @param simplifyResults
|
|
||||||
*/
|
|
||||||
public SimplifyResultClass(String className, SimplifyResult simplifyResults) {
|
|
||||||
this.className = className;
|
|
||||||
this.simplifyResults = simplifyResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClassName() {
|
|
||||||
return className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimplifyResult getSimplifyResults() {
|
|
||||||
return simplifyResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param simplifyResults the simplifyResults to set
|
|
||||||
*/
|
|
||||||
public void setSimplifyResults(SimplifyResult simplifyResults) {
|
|
||||||
this.simplifyResults = simplifyResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The simplify results of a methed
|
|
||||||
*
|
|
||||||
* @author fayez
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SimplifyResultMethod {
|
|
||||||
|
|
||||||
private final String methodID;
|
|
||||||
private final Map<TPHConstraint, Set<String>> conastraintsAndEqualTPHs;
|
|
||||||
|
|
||||||
|
|
||||||
public SimplifyResultMethod(String methodName, Map<TPHConstraint, Set<String>> conastraintsAndEqualTPHs) {
|
|
||||||
this.methodID = methodName;
|
|
||||||
this.conastraintsAndEqualTPHs = conastraintsAndEqualTPHs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the methodName
|
|
||||||
*/
|
|
||||||
public String getMethodID() {
|
|
||||||
return methodID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the conastraintsAndEqualTPHs
|
|
||||||
*/
|
|
||||||
public Map<TPHConstraint, Set<String>> getConastraintsAndEqualTPHs() {
|
|
||||||
return conastraintsAndEqualTPHs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.objectweb.asm.Type;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
|
||||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fayez
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TypeVariableFinder {
|
|
||||||
private ClassOrInterface classOrInterface;
|
|
||||||
private Map<String, String> genericsAndBounds;
|
|
||||||
private List<TPHConstraint> consClass;
|
|
||||||
|
|
||||||
public TypeVariableFinder(ClassOrInterface classOrInterface, Map<String, String> genericsAndBounds,
|
|
||||||
List<TPHConstraint> consClass) {
|
|
||||||
this.classOrInterface = classOrInterface;
|
|
||||||
this.genericsAndBounds = genericsAndBounds;
|
|
||||||
this.consClass = consClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void findTV() {
|
|
||||||
Iterator<GenericTypeVar> itr = classOrInterface.getGenerics().iterator();
|
|
||||||
|
|
||||||
while(itr.hasNext()) {
|
|
||||||
GenericTypeVar g = itr.next();
|
|
||||||
getBoundsOfTypeVar(g,genericsAndBounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!consClass.isEmpty()) {
|
|
||||||
ArrayList<String> types = new ArrayList<>();
|
|
||||||
ArrayList<String> superTypes = new ArrayList<>();
|
|
||||||
|
|
||||||
for(TPHConstraint cons : consClass) {
|
|
||||||
types.add(cons.getLeft());
|
|
||||||
superTypes.add(cons.getRight());
|
|
||||||
}
|
|
||||||
|
|
||||||
for(TPHConstraint cons : consClass) {
|
|
||||||
String t = cons.getLeft()+"$";
|
|
||||||
String bound = cons.getRight();
|
|
||||||
if(!bound.equals(Type.getInternalName(Object.class)))
|
|
||||||
bound += "$";
|
|
||||||
genericsAndBounds.put(t, bound);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get bounds of type variable
|
|
||||||
* @param g type variable
|
|
||||||
* @param genAndBounds
|
|
||||||
*/
|
|
||||||
private void getBoundsOfTypeVar(GenericTypeVar g, Map<String, String> genAndBounds) {
|
|
||||||
|
|
||||||
Iterator<? extends RefTypeOrTPHOrWildcardOrGeneric> bItr = g.getBounds().iterator();
|
|
||||||
while(bItr.hasNext()) {
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric b =bItr.next();
|
|
||||||
String boundDesc = b.acceptTV(new TypeToDescriptor());
|
|
||||||
// Ensure that <...> extends java.lang.Object OR ...
|
|
||||||
genAndBounds.put(g.getName(), boundDesc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
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.genericsGenerator.ConstraintsWithSameLeftSide;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.ConstraintsWithSameLeftSide;
|
||||||
|
|
||||||
public class ConstraintsFinder {
|
public class ConstraintsFinder {
|
||||||
private List<TPHConstraint> allConstaints;
|
private List<TPHConstraint> allConstaints;
|
||||||
|
@ -7,7 +7,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGenerator.NameReplacementResult;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.NameReplacementResult;
|
||||||
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
|
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
|
||||||
|
|
||||||
public class NameReplacer {
|
public class NameReplacer {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,23 +3,18 @@ package de.dhbwstuttgart.core;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
||||||
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.SimplifyResult;
|
import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GeneratedGenericsFinder;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericGenratorResultForSourceFile;
|
|
||||||
import de.dhbwstuttgart.environment.CompilationEnvironment;
|
import de.dhbwstuttgart.environment.CompilationEnvironment;
|
||||||
import de.dhbwstuttgart.parser.JavaTXParser;
|
import de.dhbwstuttgart.parser.JavaTXParser;
|
||||||
import de.dhbwstuttgart.parser.NullToken;
|
|
||||||
import de.dhbwstuttgart.parser.scope.GenericsRegistry;
|
import de.dhbwstuttgart.parser.scope.GenericsRegistry;
|
||||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.SyntaxTreeGenerator;
|
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.SyntaxTreeGenerator;
|
||||||
import de.dhbwstuttgart.parser.antlr.Java8Parser.CompilationUnitContext;
|
import de.dhbwstuttgart.parser.antlr.Java8Parser.CompilationUnitContext;
|
||||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||||
@ -31,7 +26,6 @@ import de.dhbwstuttgart.typeinference.unify.RuleSet;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
import de.dhbwstuttgart.typeinference.unify.distributeVariance;
|
import de.dhbwstuttgart.typeinference.unify.distributeVariance;
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||||
@ -46,15 +40,10 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.antlr.v4.parse.ANTLRParser.throwsSpec_return;
|
|
||||||
import org.apache.commons.io.output.NullOutputStream;
|
|
||||||
//import org.apache.commons.io.output.NullOutputStream;
|
//import org.apache.commons.io.output.NullOutputStream;
|
||||||
|
|
||||||
public class JavaTXCompiler {
|
public class JavaTXCompiler {
|
||||||
@ -66,13 +55,6 @@ public class JavaTXCompiler {
|
|||||||
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll?
|
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll?
|
||||||
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
||||||
|
|
||||||
/**
|
|
||||||
* Äußerste Liste der Source-Files.
|
|
||||||
* Danach Liste der Klassen in Source File.
|
|
||||||
* Danach Map Klassenname
|
|
||||||
*/
|
|
||||||
private List<List<HashMap<String, SimplifyResult>>> simplifyResultsSF = new ArrayList<>();
|
|
||||||
|
|
||||||
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||||
this(Arrays.asList(sourceFile));
|
this(Arrays.asList(sourceFile));
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
|
@ -1,37 +1,20 @@
|
|||||||
package de.dhbwstuttgart.typedeployment;
|
package de.dhbwstuttgart.typedeployment;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericGenratorResultForSourceFile;
|
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericsGeneratorResult;
|
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericsGeneratorResultForClass;
|
|
||||||
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
import de.dhbwstuttgart.parser.NullToken;
|
import de.dhbwstuttgart.parser.NullToken;
|
||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.NewArray;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||||
import de.dhbwstuttgart.typeinference.result.*;
|
import de.dhbwstuttgart.typeinference.result.*;
|
||||||
|
|
||||||
import org.antlr.v4.parse.ANTLRParser.action_return;
|
|
||||||
import org.antlr.v4.parse.ANTLRParser.block_return;
|
|
||||||
import org.antlr.v4.parse.ANTLRParser.labeledAlt_return;
|
|
||||||
import org.antlr.v4.parse.ANTLRParser.parserRule_return;
|
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.stringtemplate.v4.compiler.STParser.ifstat_return;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.print.DocFlavor.STRING;
|
|
||||||
import javax.security.auth.kerberos.KerberosKey;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO:
|
* TODO:
|
||||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.simplifyRes.GenericGenratorResultForSourceFile;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user