Merge branch 'simplifyRes' into bigRefactoring
This commit is contained in:
commit
5fa1cf11ef
BIN
PluginBau.docx
Normal file
BIN
PluginBau.docx
Normal file
Binary file not shown.
19
pom.xml
19
pom.xml
@ -7,7 +7,7 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<artifactId>JavaTXcompiler</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<version>0.2</version>
|
||||
<version>0.1</version>
|
||||
<name>JavaTXcompiler</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<dependencies>
|
||||
@ -20,7 +20,7 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4</artifactId>
|
||||
<version>4.7</version>
|
||||
<version>4.8-1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
@ -63,6 +63,19 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<verbose>true</verbose>
|
||||
<fork>true</fork>
|
||||
<executable>/home/michael/programs/jdk/jdk8u232-b09/bin/javac</executable>
|
||||
<compilerVersion>1.8</compilerVersion>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin -->
|
||||
<plugin>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-maven-plugin</artifactId>
|
||||
@ -161,6 +174,8 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<tycho.version>0.23.0</tycho.version>
|
||||
|
@ -43,9 +43,8 @@ public class GenericGenratorResultForSourceFile {
|
||||
return genericGeneratorResultForAllClasses.stream()
|
||||
.filter(sr -> sr.getClassName().equals(name))
|
||||
.findAny()
|
||||
.orElseThrow(() -> new NoSuchElementException(
|
||||
"Simplify results for the class " + pkgName + "." + name + " are not found"));
|
||||
.orElse(new GenericsGeneratorResultForClass(name));
|
||||
}
|
||||
throw new NoSuchElementException("Simplify results for the class " + pkgName + "." + name + " are not found");
|
||||
return new GenericsGeneratorResultForClass(name);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* @author fayez
|
||||
@ -56,12 +59,16 @@ public class GenericsGeneratorResultForClass {
|
||||
.anyMatch(i -> i.equals(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<GenericsGeneratorResult> getMethodConstraintsByID(String id) {
|
||||
return methodsAndTheirConstraints.getMethodsAndConstraints().stream().filter(mc -> mc.getMethodID().equals(id))
|
||||
.findFirst().get().getConstraints();
|
||||
Optional<MethodAndConstraints> methodConstraints = methodsAndTheirConstraints.getMethodsAndConstraints()
|
||||
.stream()
|
||||
.filter(mc -> mc.getMethodID().equals(id))
|
||||
.findFirst();
|
||||
|
||||
if (methodConstraints.isPresent()) {
|
||||
return methodConstraints.get().getConstraints();
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* The simplify results of a source file (package)
|
||||
*
|
||||
* @author fayez
|
||||
*
|
||||
*/
|
||||
public class GenericGenratorResultForSourceFile {
|
||||
private String pkgName;
|
||||
private final List<GenericsGeneratorResultForClass> genericGeneratorResultForAllClasses = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* @param pkgName
|
||||
*/
|
||||
public GenericGenratorResultForSourceFile(String pkgName) {
|
||||
this.pkgName = pkgName;
|
||||
}
|
||||
|
||||
public List<GenericsGeneratorResultForClass> getGenericGeneratorResultForAllClasses() {
|
||||
return genericGeneratorResultForAllClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the simplify results of a class to simplifyResForSF
|
||||
*
|
||||
* @param sResClass simplify results of a class to added
|
||||
*/
|
||||
public void addGenericGeneratorResultClass(GenericsGeneratorResultForClass sResClass) {
|
||||
genericGeneratorResultForAllClasses.add(sResClass);
|
||||
}
|
||||
|
||||
public GenericsGeneratorResultForClass getSimplifyResultsByName(String pkgName, String name) {
|
||||
for (int i = 0; i < genericGeneratorResultForAllClasses.size(); i++) {
|
||||
GenericsGeneratorResultForClass genericsGeneratorResult = genericGeneratorResultForAllClasses.get(i);
|
||||
if (genericsGeneratorResult.getClassName().equals(name)) {
|
||||
return genericsGeneratorResult;
|
||||
}
|
||||
}
|
||||
|
||||
return new GenericsGeneratorResultForClass(name);
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.dhbwstuttgart.bytecode.simplifyRes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGeneratorResultsForAllMethods;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.MethodAndConstraints;
|
||||
|
||||
/**
|
||||
* @author fayez
|
||||
*
|
||||
*/
|
||||
public class GenericsGeneratorResultForClass {
|
||||
private final String className;
|
||||
private final List<GenericsGeneratorResult> classConstraints;
|
||||
private final GenericGeneratorResultsForAllMethods methodsAndTheirConstraints;
|
||||
|
||||
public GenericsGeneratorResultForClass(String className) {
|
||||
this(className, Collections.emptyList(), new GenericGeneratorResultsForAllMethods());
|
||||
}
|
||||
/**
|
||||
* @param className
|
||||
* @param classConstraints
|
||||
* @param methodsAndTheirConstraints
|
||||
*/
|
||||
public GenericsGeneratorResultForClass(String className, List<GenericsGeneratorResult> classConstraints,
|
||||
GenericGeneratorResultsForAllMethods methodsAndTheirConstraints) {
|
||||
this.className = className;
|
||||
this.classConstraints = classConstraints;
|
||||
this.methodsAndTheirConstraints = methodsAndTheirConstraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the className
|
||||
*/
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the classConstraints
|
||||
*/
|
||||
public List<GenericsGeneratorResult> getClassConstraints() {
|
||||
return classConstraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the methodsAndTheirConstraints
|
||||
*/
|
||||
public GenericGeneratorResultsForAllMethods getMethodsAndTheirConstraints() {
|
||||
return methodsAndTheirConstraints;
|
||||
}
|
||||
|
||||
public boolean contains(String id) {
|
||||
return methodsAndTheirConstraints.getMethodsAndConstraints().stream().map(mc -> mc.getMethodID())
|
||||
.anyMatch(i -> i.equals(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<GenericsGeneratorResult> getMethodConstraintsByID(String id) {
|
||||
java.util.Optional<MethodAndConstraints> methodAndConstraints = methodsAndTheirConstraints.getMethodsAndConstraints().stream().filter(mc -> mc.getMethodID().equals(id))
|
||||
.findFirst();
|
||||
|
||||
return methodAndConstraints.isPresent() ? methodAndConstraints.get().getConstraints() : Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
@ -48,7 +48,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class JavaTXCompiler {
|
||||
|
||||
public static JavaTXCompiler INSTANCE;
|
||||
//public static JavaTXCompiler INSTANCE;
|
||||
final CompilationEnvironment environment;
|
||||
Boolean resultmodel = true;
|
||||
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
||||
@ -57,13 +57,13 @@ public class JavaTXCompiler {
|
||||
|
||||
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||
this(Arrays.asList(sourceFile));
|
||||
INSTANCE = this;
|
||||
//INSTANCE = this;
|
||||
}
|
||||
|
||||
public JavaTXCompiler(File sourceFile, Boolean log) throws IOException, ClassNotFoundException {
|
||||
this(sourceFile);
|
||||
this.log = log;
|
||||
INSTANCE = this;
|
||||
//INSTANCE = this;
|
||||
}
|
||||
|
||||
public JavaTXCompiler(List<File> sources) throws IOException, ClassNotFoundException {
|
||||
@ -71,7 +71,7 @@ public class JavaTXCompiler {
|
||||
for (File s : sources) {
|
||||
sourceFiles.put(s, parse(s));
|
||||
}
|
||||
INSTANCE = this;
|
||||
//INSTANCE = this;
|
||||
}
|
||||
|
||||
public ConstraintSet<Pair> getConstraints() throws ClassNotFoundException {
|
||||
@ -714,10 +714,14 @@ public class JavaTXCompiler {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void generateBytecodForFile(String path, HashMap<String, byte[]> classFiles, SourceFile sf,
|
||||
List<ResultSet> typeinferenceResult) throws IOException {
|
||||
public synchronized void generateBytecodForFile(String path, /* HashMap<String, byte[]> classFiles,*/ SourceFile sf,
|
||||
List<ResultSet> typeinferenceResult, List<GenericGenratorResultForSourceFile> genericResultsRet) throws IOException {
|
||||
//genericResultsRet is empty; fuer die Rückgabe
|
||||
try {
|
||||
HashMap<String, byte[]> classFiles = new HashMap<>();
|
||||
|
||||
List<GenericGenratorResultForSourceFile> genericResults = getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
||||
genericResultsRet.addAll(genericResults);//fuer Rueckgabe
|
||||
BytecodeGen bytecodeGen = new BytecodeGen(classFiles,typeinferenceResult, genericResults, sf,path);
|
||||
bytecodeGen.visit(sf);
|
||||
this.writeClassFile(bytecodeGen.getClassFiles(), path);
|
||||
|
@ -359,7 +359,7 @@ public class SyntaxTreeGenerator{
|
||||
&& fieldDeclarationContext.unannTypeOrAuto().unannType() != null){
|
||||
fieldType = TypeGenerator.convert(fieldDeclarationContext.unannTypeOrAuto().unannType(), reg, generics);
|
||||
}else{
|
||||
fieldType = TypePlaceholder.fresh(fieldDeclarationContext.getStart());
|
||||
fieldType = TypePlaceholder.fresh(fieldDeclarationContext.variableDeclaratorList().getStart()); //PL 2019-12-06: variableDeclaratorList() eingefuegt, um als Token nicht die Modifier zu bekommen
|
||||
}
|
||||
for(Java8Parser.VariableDeclaratorContext varCtx : fieldDeclarationContext.variableDeclaratorList().variableDeclarator()){
|
||||
String fieldName = convert(varCtx.variableDeclaratorId());
|
||||
|
@ -6,7 +6,7 @@ import org.antlr.v4.runtime.Token;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
|
||||
/**
|
||||
* Eine Feldinitialisation steht für eine Felddeklaration mit gleichzeitiger Wertzuweisung
|
||||
* Eine Feldinitialisation steht für eine Felddeklaration mit gleichzeitiger Wertzuweisung
|
||||
* Beispiel: 'public Feld FeldVar = FeldWert;'
|
||||
* @author janulrich
|
||||
*
|
||||
@ -17,7 +17,7 @@ public class FieldDeclaration extends Field{
|
||||
|
||||
/**
|
||||
* Dieser Konstruktor der FieldDeclaration erstellt den Syntaxknoten vollständig.
|
||||
* Kein nachträgliches hinzfügen von Informationen oder aufrufen von parserPostProcessing ist notwendig.
|
||||
* Kein nachträgliches hinzfügen von Informationen oder aufrufen von parserPostProcessing ist notwendig.
|
||||
*/
|
||||
public FieldDeclaration(String name, RefTypeOrTPHOrWildcardOrGeneric typ, int modifier, Expression value, Token offset){
|
||||
super(name, typ, modifier, offset);//Dieser Deklarator wird nicht vom Parser aufgerufen. Dadurch gibt es auch keinen Offset
|
||||
|
@ -63,7 +63,7 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
|
||||
|
||||
@Override
|
||||
public Token getOffset() {
|
||||
return null;
|
||||
return super.getOffset();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -36,7 +36,7 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric
|
||||
/**
|
||||
* @author Andreas Stadelmeier, a10023
|
||||
* Ruft die TypePlaceholder.fresh()-Methode auf.
|
||||
* Fügt zusätzlich einen Replacementlistener hinzu.
|
||||
* Fügt zusätzlich einen Replacementlistener hinzu.
|
||||
* @return
|
||||
*/
|
||||
public static TypePlaceholder fresh(Token position){
|
||||
|
@ -0,0 +1,7 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
public enum KindOfTypeInsertPoint {
|
||||
NORMAL_INSERT,
|
||||
GENERIC_CLASS_INSERT,
|
||||
GENERERIC_METHOD_INSERT
|
||||
}
|
@ -1,9 +1,15 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.antlr.v4.parse.BlockSetTransformer.setAlt_return;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.statement.This;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultPair;
|
||||
|
||||
public class TypeInsert {
|
||||
@ -22,10 +28,15 @@ public class TypeInsert {
|
||||
|
||||
public String insert(String intoSource){
|
||||
List<TypeInsertPoint> offsets = new ArrayList<>();
|
||||
String ret = point.insert(intoSource, offsets);
|
||||
offsets.add(point);
|
||||
for(TypeInsertPoint insertPoint : inserts){
|
||||
ret = insertPoint.insert(ret, offsets);
|
||||
String ret = intoSource;
|
||||
|
||||
List<TypeInsertPoint> insertsSorted = new ArrayList<>();
|
||||
insertsSorted.add(point);
|
||||
insertsSorted.addAll(inserts);
|
||||
Collections.sort(insertsSorted, new TypeInsertPoint.TypeInsertPointPositionComparator().reversed());
|
||||
|
||||
for(TypeInsertPoint insertPoint : insertsSorted) {
|
||||
ret = insertPoint.insert(ret, new ArrayList<>());
|
||||
offsets.add(insertPoint);
|
||||
}
|
||||
return ret;
|
||||
@ -53,6 +64,18 @@ public class TypeInsert {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Set<TypeInsertPoint> getAdditionalPoints() {
|
||||
TypeInsertPoint.TypeInsertPointPositionComparator comparator = new TypeInsertPoint.TypeInsertPointPositionComparator();
|
||||
TreeSet<TypeInsertPoint> result = new TreeSet<>(comparator.reversed());
|
||||
result.addAll(inserts);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Set<TypeInsertPoint> getAdditionalPointsUnsorted() {
|
||||
return inserts;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return point.toString();
|
||||
}
|
||||
|
@ -1,20 +1,35 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||
import de.dhbwstuttgart.typeinference.result.*;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import java.util.*;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.PairTPHEqualTPH;
|
||||
import de.dhbwstuttgart.typeinference.result.PairTPHequalRefTypeOrWildcardType;
|
||||
import de.dhbwstuttgart.typeinference.result.PairTPHsmallerTPH;
|
||||
import de.dhbwstuttgart.typeinference.result.ResolvedType;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSetVisitor;
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
@ -31,49 +46,60 @@ import java.util.*;
|
||||
*/
|
||||
public class TypeInsertFactory {
|
||||
|
||||
private static List<ResultSet> newResults;
|
||||
|
||||
public static Set<TypeInsert> createTypeInsertPoints(SourceFile forSourcefile, ResultSet withResults){
|
||||
return new TypeInsertPlacer().getTypeInserts(forSourcefile, withResults);
|
||||
public static Set<TypeInsert> createTypeInsertPoints(SourceFile forSourcefile, ResultSet withResults, List<ResultSet> newResults, List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles){
|
||||
TypeInsertFactory.newResults = newResults;
|
||||
return new TypeInsertPlacer().getTypeInserts(forSourcefile, withResults, simplifyResultsForAllSourceFiles);
|
||||
}
|
||||
|
||||
public static TypeInsert createInsertPoints(RefTypeOrTPHOrWildcardOrGeneric type, Token offset, ClassOrInterface cl, Method m,
|
||||
ResultSet resultSet) {
|
||||
ResultSet resultSet, List<GenericsGeneratorResult> constraints, List<GenericsGeneratorResult> classConstraints) {
|
||||
|
||||
try {
|
||||
/* PL 2020-04-11 auskommentiert
|
||||
* try {
|
||||
*/
|
||||
ResolvedType resolvedType = resultSet.resolveType(type);
|
||||
TypeInsertPoint insertPoint = new TypeInsertPoint(offset,
|
||||
new TypeToInsertString(resolvedType.resolvedType).insert);
|
||||
List<GenericGenratorResultForSourceFile> simplifyResults = JavaTXCompiler.INSTANCE.getGeneratedGenericResultsForAllSourceFiles();
|
||||
new TypeToInsertString(resolvedType.resolvedType, constraints, classConstraints).insert, KindOfTypeInsertPoint.NORMAL_INSERT);
|
||||
/* PL 2020-04-11 auskommentiert
|
||||
List<GenericGenratorResultForSourceFile> simplifyResults = JavaTXCompiler.INSTANCE.getGeneratedGenericResultsForAllSourceFiles(newResults);
|
||||
for (GenericGenratorResultForSourceFile simplifyResultsEntries : simplifyResults) {
|
||||
GenericsGeneratorResultForClass genericResultsForClass = simplifyResultsEntries.getSimplifyResultsByName("", cl.getClassName().toString());
|
||||
return new TypeInsert(insertPoint, createGenericInsert(genericResultsForClass, cl, m, resultSet), resolvedType.getResultPair());
|
||||
return new TypeInsert(insertPoint, createGenericInsert(genericResultsForClass, cl, m, resultSet, offset), resolvedType.getResultPair());
|
||||
}
|
||||
|
||||
return new TypeInsert(insertPoint, new HashSet<>(), resolvedType.getResultPair());
|
||||
*/
|
||||
//GenericsGeneratorResultForClass genericResultsForClass = genericResult.getSimplifyResultsByName("", cl.getClassName().toString());
|
||||
return new TypeInsert(insertPoint, createGenericInsert(constraints, classConstraints, cl, m, resultSet, offset), resolvedType.getResultPair());
|
||||
|
||||
/* PL 2020-04-11 auskommentiert
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static synchronized Set<TypeInsertPoint> createGenericInsert(GenericsGeneratorResultForClass genericResult, ClassOrInterface cl, Method m, ResultSet resultSet){
|
||||
Set<TypeInsertPoint> result = createGenericClassInserts(genericResult, cl);
|
||||
|
||||
for (Method method : cl.getMethods()) {
|
||||
Resolver resolver = new Resolver(resultSet);
|
||||
List<GenericsGeneratorResult> methodConstraints = genericResult.getMethodConstraintsByID(MethodUtility.createID(resolver, method));
|
||||
createMethodConstraints(method, methodConstraints);
|
||||
}
|
||||
private static synchronized Set<TypeInsertPoint> createGenericInsert(List<GenericsGeneratorResult> methodConstraints, List<GenericsGeneratorResult> classConstraints,ClassOrInterface cl, Method m, ResultSet resultSet, Token mOffset){
|
||||
Set<TypeInsertPoint> result = createGenericClassInserts(classConstraints, cl);
|
||||
|
||||
Resolver resolver = new Resolver(resultSet);
|
||||
|
||||
if (m != null) {
|
||||
//List<GenericsGeneratorResult> methodConstraints = genericResult.getMethodConstraintsByID(MethodUtility.createID(resolver, m));
|
||||
result.addAll(createMethodConstraints(methodConstraints, m.getOffset() != null ? m.getOffset() : mOffset));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Set<TypeInsertPoint> createMethodConstraints(Method method, List<GenericsGeneratorResult> constraints) {
|
||||
private static Set<TypeInsertPoint> createMethodConstraints(List<GenericsGeneratorResult> constraints, Token mOffset) {
|
||||
Set<TypeInsertPoint> result = new HashSet<>();
|
||||
Token offset = new GenericDeclarationList(method.getGenerics(), new NullToken()).getOffset();
|
||||
Token offset = mOffset;
|
||||
|
||||
if (constraints.size() == 0) {
|
||||
result.add(new TypeInsertPoint(offset, ""));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -83,25 +109,25 @@ public class TypeInsertFactory {
|
||||
if (genericInsertConstraint.getConstraint().getRight().equals(Type.getInternalName(Object.class))) {
|
||||
insert += genericInsertConstraint.getConstraint().getLeft();
|
||||
} else {
|
||||
insert += genericInsertConstraint.getConstraint().getLeft() + " extends " + genericInsertConstraint.getConstraint().getRight() + ", ";
|
||||
insert += genericInsertConstraint.getConstraint().getLeft() + " extends " + genericInsertConstraint.getConstraint().getRight();
|
||||
}
|
||||
insert += ", ";
|
||||
}
|
||||
|
||||
insert = insert.substring(0, insert.length() -2);
|
||||
insert += ">";
|
||||
|
||||
result.add(new TypeInsertPoint(offset, insert));
|
||||
result.add(new TypeInsertPoint(offset, insert, KindOfTypeInsertPoint.GENERERIC_METHOD_INSERT));
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Set<TypeInsertPoint> createGenericClassInserts(GenericsGeneratorResultForClass genericResult, ClassOrInterface cl) {
|
||||
private static Set<TypeInsertPoint> createGenericClassInserts(List<GenericsGeneratorResult> classConstraints, ClassOrInterface cl) {
|
||||
Set<TypeInsertPoint> result = new HashSet<>();
|
||||
Token offset = cl.getGenerics().getOffset();
|
||||
|
||||
List<GenericsGeneratorResult> classConstraints = genericResult.getClassConstraints();
|
||||
//List<GenericsGeneratorResult> classConstraints = genericResult.getClassConstraints();
|
||||
|
||||
if (classConstraints.size() == 0) {
|
||||
result.add(new TypeInsertPoint(offset, ""));
|
||||
if (classConstraints == null || classConstraints.size() == 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -111,14 +137,15 @@ public class TypeInsertFactory {
|
||||
if (genericInsertConstraint.getConstraint().getRight().equals(Type.getInternalName(Object.class))) {
|
||||
insert += genericInsertConstraint.getConstraint().getLeft();
|
||||
} else {
|
||||
insert += genericInsertConstraint.getConstraint().getLeft() + " extends " + genericInsertConstraint.getConstraint().getRight() + ", ";
|
||||
insert += genericInsertConstraint.getConstraint().getLeft() + " extends " + genericInsertConstraint.getConstraint().getRight();
|
||||
}
|
||||
insert += ", ";
|
||||
}
|
||||
|
||||
insert = insert.substring(0, insert.length() -2);
|
||||
insert += ">";
|
||||
|
||||
result.add(new TypeInsertPoint(offset, insert));
|
||||
result.add(new TypeInsertPoint(offset, insert, KindOfTypeInsertPoint.GENERIC_CLASS_INSERT));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -126,9 +153,14 @@ public class TypeInsertFactory {
|
||||
|
||||
class TypeToInsertString implements ResultSetVisitor{
|
||||
String insert = "";
|
||||
private List<GenericsGeneratorResult> constraints;
|
||||
private List<GenericsGeneratorResult> classConstraints;
|
||||
|
||||
|
||||
TypeToInsertString(RefTypeOrTPHOrWildcardOrGeneric type){
|
||||
type.accept(this);
|
||||
TypeToInsertString(RefTypeOrTPHOrWildcardOrGeneric type, List<GenericsGeneratorResult> constraints, List<GenericsGeneratorResult> classConstraints){
|
||||
this.constraints = constraints;
|
||||
this.classConstraints = classConstraints;
|
||||
type.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -154,7 +186,7 @@ class TypeToInsertString implements ResultSetVisitor{
|
||||
Iterator<RefTypeOrTPHOrWildcardOrGeneric> iterator = resolved.getParaList().iterator();
|
||||
while(iterator.hasNext()){
|
||||
RefTypeOrTPHOrWildcardOrGeneric typeParam = iterator.next();
|
||||
insert += new TypeToInsertString(typeParam).insert;
|
||||
insert += new TypeToInsertString(typeParam, constraints, classConstraints).insert;
|
||||
if(iterator.hasNext())insert += ", ";
|
||||
}
|
||||
insert += ">";
|
||||
@ -168,16 +200,37 @@ class TypeToInsertString implements ResultSetVisitor{
|
||||
|
||||
@Override
|
||||
public void visit(SuperWildcardType superWildcardType) {
|
||||
insert += "? super " + new TypeToInsertString(superWildcardType.getInnerType()).insert;
|
||||
insert += "? super " + new TypeToInsertString(superWildcardType.getInnerType(), constraints, classConstraints).insert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
insert += typePlaceholder.getName();
|
||||
String realName = typePlaceholder.getName();
|
||||
//String realName = sig2.substring(1, sig2.length() - 1);
|
||||
//String toVisit = realName+SPECIAL_CHAR;
|
||||
//if(!genericsAndBounds.containsKey(toVisit)) {//PL 202-04-1 vielleicht braucht man das, vgl. Signature.java
|
||||
Optional<GenericsGeneratorResult> equalTPH = getEqualTPHFromClassConstraints(classConstraints, realName);
|
||||
if(equalTPH.isPresent()){
|
||||
insert += equalTPH.get().getConstraint().getLeft();// + SPECIAL_CHAR;
|
||||
} else {
|
||||
insert += getEqualTPH(constraints, realName);// + SPECIAL_CHAR;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExtendsWildcardType extendsWildcardType) {
|
||||
insert += "? extends " + new TypeToInsertString(extendsWildcardType.getInnerType()).insert;
|
||||
insert += "? extends " + new TypeToInsertString(extendsWildcardType.getInnerType(), constraints, classConstraints).insert;
|
||||
}
|
||||
|
||||
private Optional<GenericsGeneratorResult> getEqualTPHFromClassConstraints(List<GenericsGeneratorResult> listOfConstraints, String tph) {
|
||||
return listOfConstraints.stream()
|
||||
.filter(c -> c.getConstraint().getLeft().equals(tph) || c.getEqualsTPHs().contains(tph))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
private String getEqualTPH(List<GenericsGeneratorResult> constraints2, String tph) {
|
||||
return constraints2.stream()
|
||||
.filter(c -> c.getConstraint().getLeft().equals(tph) || c.getEqualsTPHs().contains(tph))
|
||||
.findFirst().get().getConstraint().getLeft();
|
||||
}
|
||||
}
|
@ -1,59 +1,85 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.JavaInternalExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TypeInsertPlacer extends AbstractASTWalker{
|
||||
Set<TypeInsert> inserts = new HashSet<>();
|
||||
private ResultSet withResults;
|
||||
String pkgName;
|
||||
private List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles;
|
||||
|
||||
public Set<TypeInsert> getTypeInserts(SourceFile forSourceFile, ResultSet withResults){
|
||||
public Set<TypeInsert> getTypeInserts(SourceFile forSourceFile, ResultSet withResults, List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles){
|
||||
this.withResults = withResults;
|
||||
this.simplifyResultsForAllSourceFiles = simplifyResultsForAllSourceFiles;
|
||||
pkgName = forSourceFile.getPkgName();
|
||||
forSourceFile.accept(this);
|
||||
return inserts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ClassOrInterface classOrInterface) {
|
||||
TypeInsertPlacerClass cl = new TypeInsertPlacerClass(classOrInterface, withResults);
|
||||
GenericsGeneratorResultForClass generatedGenerics = simplifyResultsForAllSourceFiles
|
||||
.stream()
|
||||
.map(sr->sr.getSimplifyResultsByName(pkgName, classOrInterface.getClassName().toString()))
|
||||
.findFirst()
|
||||
.get();
|
||||
TypeInsertPlacerClass cl = new TypeInsertPlacerClass(classOrInterface, withResults, generatedGenerics);
|
||||
this.inserts.addAll(cl.inserts);
|
||||
}
|
||||
}
|
||||
|
||||
class TypeInsertPlacerClass extends AbstractASTWalker{
|
||||
protected final ResultSet results;
|
||||
private GenericsGeneratorResultForClass generatedGenerics;
|
||||
protected final ClassOrInterface cl;
|
||||
public final Set<TypeInsert> inserts = new HashSet<>();
|
||||
private Method method;
|
||||
|
||||
private Resolver resolver;
|
||||
|
||||
List<GenericsGeneratorResult> constraints;
|
||||
List<GenericsGeneratorResult> classConstraints;
|
||||
|
||||
TypeInsertPlacerClass(ClassOrInterface forClass, ResultSet withResults){
|
||||
TypeInsertPlacerClass(ClassOrInterface forClass, ResultSet withResults, GenericsGeneratorResultForClass generatedGenerics){
|
||||
this.cl = forClass;
|
||||
this.method = null;
|
||||
this.results = withResults;
|
||||
this.generatedGenerics = generatedGenerics;
|
||||
resolver = new Resolver(withResults); //PL 2020-04-12 Ob das stimmt weiss ich nicht
|
||||
forClass.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Method method) {
|
||||
this.method = method;
|
||||
String id = MethodUtility.createID(resolver, method);
|
||||
constraints = generatedGenerics.getMethodConstraintsByID(id);
|
||||
classConstraints = generatedGenerics.getClassConstraints();
|
||||
if(method.getReturnType() instanceof TypePlaceholder)
|
||||
inserts.add(TypeInsertFactory.createInsertPoints(
|
||||
method.getReturnType(), method.getReturnType().getOffset(), cl, method, results));
|
||||
method.getReturnType(), method.getReturnType().getOffset(), cl, method, results, constraints, classConstraints));
|
||||
super.visit(method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Field field) {
|
||||
if(field.getType() instanceof TypePlaceholder){
|
||||
classConstraints = generatedGenerics.getClassConstraints();
|
||||
inserts.add(TypeInsertFactory.createInsertPoints(
|
||||
field.getType(), field.getType().getOffset(), cl, method, results));
|
||||
field.getType(), field.getType().getOffset(), cl, method, results, new ArrayList<>(), classConstraints));
|
||||
}
|
||||
super.visit(field);
|
||||
}
|
||||
@ -62,7 +88,7 @@ class TypeInsertPlacerClass extends AbstractASTWalker{
|
||||
public void visit(FormalParameter param) {
|
||||
if(param.getType() instanceof TypePlaceholder)
|
||||
inserts.add(TypeInsertFactory.createInsertPoints(
|
||||
param.getType(), param.getType().getOffset(), cl, method, results));
|
||||
param.getType(), param.getType().getOffset(), cl, method, results, constraints, classConstraints));
|
||||
super.visit(param);
|
||||
}
|
||||
|
||||
|
@ -1,29 +1,29 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Set;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class TypeInsertPoint {
|
||||
public Token point;
|
||||
private String insertString;
|
||||
private int extraOffset = 0;
|
||||
private KindOfTypeInsertPoint kind;
|
||||
|
||||
public TypeInsertPoint(Token point, String toInsert){
|
||||
public TypeInsertPoint(Token point, String toInsert, KindOfTypeInsertPoint kind){
|
||||
this.point = point;
|
||||
this.kind = kind;
|
||||
this.insertString = (toInsert.endsWith(" ")) ? toInsert : toInsert + " " ;
|
||||
}
|
||||
|
||||
public boolean isGenericClassInsertPoint() {
|
||||
return kind == KindOfTypeInsertPoint.GENERIC_CLASS_INSERT;
|
||||
}
|
||||
|
||||
public String insert(String intoSource, List<TypeInsertPoint> additionalOffset){
|
||||
int offset = additionalOffset.stream().filter((token ->
|
||||
//token.point.getLine() != point.getLine() && token.point.getCharPositionInLine() <= point.getCharPositionInLine()))
|
||||
token.point.getStartIndex() <= point.getStartIndex()))
|
||||
.mapToInt((typeInsertPoint -> typeInsertPoint.insertString.length())).sum();
|
||||
return new StringBuilder(intoSource).insert(point.getStartIndex()+offset+extraOffset, insertString).toString();
|
||||
return new StringBuilder(intoSource).insert(point.getStartIndex()+extraOffset, insertString).toString();
|
||||
}
|
||||
|
||||
public String getInsertString() {
|
||||
@ -44,16 +44,50 @@ public class TypeInsertPoint {
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
/*
|
||||
if(!(obj instanceof TypeInsertPoint)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return ((TypeInsertPoint)obj).point.equals(this.point) &&
|
||||
((TypeInsertPoint)obj).insertString.equals(this.insertString);
|
||||
}
|
||||
return
|
||||
((TypeInsertPoint)obj).getPositionInCode() == this.getPositionInCode() &&
|
||||
((TypeInsertPoint)obj).insertString.equals(this.insertString);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return getPositionInCode() * 11 * insertString.hashCode();
|
||||
}
|
||||
|
||||
public Set<TypeInsertPoint> getAdditionalPoints() {
|
||||
return this.getAdditionalPoints();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return point.toString() + " " + insertString.toString();
|
||||
return point.getLine() + ":" + point.getCharPositionInLine() + ":" + insertString;
|
||||
}
|
||||
|
||||
public static final class TypeInsertPointPositionComparator implements Comparator<TypeInsertPoint> {
|
||||
|
||||
@Override
|
||||
public int compare(TypeInsertPoint o1, TypeInsertPoint o2) {
|
||||
if (o1.point == null && o2.point == null) {
|
||||
return 0;
|
||||
} else if (o2.point == null) {
|
||||
return 1;
|
||||
} else if (o1.point == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (o1.getPositionInCode() > o2.getPositionInCode()) {
|
||||
return 1;
|
||||
} else if (o1.getPositionInCode() < o2.getPositionInCode()) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -186,6 +186,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
usedTasks.cancel();
|
||||
writeLog(nOfUnify.toString() + "cancel");
|
||||
System.out.println("cancel");
|
||||
try {
|
||||
logFile.write("Abbruch");
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.err.println("log-File nicht vorhanden");
|
||||
}
|
||||
}
|
||||
*/
|
||||
rules = new RuleSet(logFile);
|
||||
@ -303,6 +309,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
/*
|
||||
* Step 1: Repeated application of reduce, adapt, erase, swap
|
||||
*/
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
rekTiefe++;
|
||||
nOfUnify++;
|
||||
@ -463,7 +474,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
// .collect(Collectors.toCollection(HashSet::new));
|
||||
//Muss auskommentiert werden, wenn computeCartesianRecursive ENDE
|
||||
|
||||
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
Set<Set<UnifyPair>> eqPrimePrimeSet = new HashSet<>();
|
||||
|
||||
@ -907,6 +922,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
writeLog("wait "+ forkOrig.thNo);
|
||||
noOfThread--;
|
||||
res = forkOrig.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
forkOrig.writeLog("final Orig 1");
|
||||
forkOrig.closeLogFile();
|
||||
@ -922,6 +942,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
synchronized (this) {
|
||||
noOfThread--;
|
||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||
//noOfThread--; an das Ende von compute verschoben
|
||||
@ -1013,6 +1038,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
writeLog("wait "+ forkOrig.thNo);
|
||||
noOfThread--;
|
||||
res = forkOrig.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
forkOrig.writeLog("final Orig -1");
|
||||
forkOrig.closeLogFile();
|
||||
@ -1028,6 +1058,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
synchronized (this) {
|
||||
noOfThread--;
|
||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||
//noOfThread--; an das Ende von compute verschoben
|
||||
@ -1089,6 +1124,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
writeLog("wait "+ forkOrig.thNo);
|
||||
noOfThread--;
|
||||
res = forkOrig.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
forkOrig.writeLog("final Orig 2");
|
||||
forkOrig.closeLogFile();
|
||||
@ -1103,6 +1143,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
synchronized (this) {
|
||||
noOfThread--;
|
||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||
//noOfThread--; an das Ende von compute verschoben
|
||||
@ -1224,7 +1269,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) {
|
||||
//wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen
|
||||
result = par_res;
|
||||
if (par_res.iterator().next() instanceof WildcardType) {
|
||||
if (!par_res.isEmpty() && par_res.iterator().next() instanceof WildcardType) {
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package typeinference;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
@ -133,7 +134,8 @@ public class JavaTXCompilerTest {
|
||||
System.out.println(ASTPrinter.print(sf));
|
||||
}
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
//compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles);
|
||||
for(File f : compiler.sourceFiles.keySet()){
|
||||
SourceFile sf = compiler.sourceFiles.get(f);
|
||||
System.out.println(ASTTypePrinter.print(sf));
|
||||
@ -142,7 +144,7 @@ public class JavaTXCompilerTest {
|
||||
assert results.size()>0;
|
||||
Set<String> insertedTypes = new HashSet<>();
|
||||
for(ResultSet resultSet : results){
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet);
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles);
|
||||
assert result.size()>0;
|
||||
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
||||
for(TypeInsert tip : result){
|
||||
|
@ -1,5 +1,6 @@
|
||||
package typeinference;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
@ -105,6 +106,7 @@ public class Meth_GenTest {
|
||||
System.out.println(ASTPrinter.print(sf));
|
||||
}
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
|
||||
for(File f : compiler.sourceFiles.keySet()){
|
||||
SourceFile sf = compiler.sourceFiles.get(f);
|
||||
@ -114,7 +116,7 @@ public class Meth_GenTest {
|
||||
assert results.size()>0;
|
||||
Set<String> insertedTypes = new HashSet<>();
|
||||
for(ResultSet resultSet : results){
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet);
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles);
|
||||
assert result.size()>0;
|
||||
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
||||
for(TypeInsert tip : result){
|
||||
|
@ -1,5 +1,6 @@
|
||||
package typeinference;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
@ -131,6 +132,7 @@ public class UnifyTest {
|
||||
System.out.println(ASTPrinter.print(sf));
|
||||
}
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
|
||||
for(File f : compiler.sourceFiles.keySet()){
|
||||
SourceFile sf = compiler.sourceFiles.get(f);
|
||||
@ -140,7 +142,7 @@ public class UnifyTest {
|
||||
assert results.size()>0;
|
||||
Set<String> insertedTypes = new HashSet<>();
|
||||
for(ResultSet resultSet : results){
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet);
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles);
|
||||
assert result.size()>0;
|
||||
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
||||
for(TypeInsert tip : result){
|
||||
|
@ -3,7 +3,7 @@ import java.lang.Integer;
|
||||
|
||||
public class Fac {
|
||||
|
||||
getFac(n){
|
||||
getFac(java.lang.Integer n){
|
||||
var res = 1;
|
||||
var i = 1;
|
||||
while(i<=n) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
public class Field {
|
||||
public Integer x = 5;
|
||||
public x = 5;
|
||||
|
||||
m(){
|
||||
return x;
|
||||
|
@ -2,7 +2,7 @@ import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Object;
|
||||
|
||||
public class IfTest{
|
||||
public class IfTest {
|
||||
Object m1(b) {
|
||||
Integer i;
|
||||
if(b) {
|
||||
|
@ -14,7 +14,7 @@ call(String s){}
|
||||
|
||||
}
|
||||
|
||||
class Pair<A,B>{
|
||||
A left;
|
||||
B right;
|
||||
class Pair{
|
||||
left;
|
||||
right;
|
||||
}
|
@ -8,7 +8,7 @@ class Test{
|
||||
}
|
||||
|
||||
interface Klasse1{
|
||||
Klasse1 meth(List p);
|
||||
Klasse1 meth(p);
|
||||
Klasse1 meth(Klasse2 p);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user