forked from JavaTX/JavaCompilerCore
Merge branch 'targetBytecode' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into targetBytecode
This commit is contained in:
commit
268f2b72eb
@ -71,6 +71,9 @@ public class JavaTXCompiler {
|
|||||||
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
||||||
private final DirectoryClassLoader classLoader;
|
private final DirectoryClassLoader classLoader;
|
||||||
|
|
||||||
|
private Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> methCallargTypesRetType = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||||
this(Arrays.asList(sourceFile), null);
|
this(Arrays.asList(sourceFile), null);
|
||||||
}
|
}
|
||||||
@ -127,7 +130,9 @@ public class JavaTXCompiler {
|
|||||||
allClasses.addAll(sf.getClasses());
|
allClasses.addAll(sf.getClasses());
|
||||||
}
|
}
|
||||||
allClasses.addAll(importedClasses);
|
allClasses.addAll(importedClasses);
|
||||||
return new TYPE(sourceFiles.values(), allClasses).getConstraints();
|
TYPE ty = new TYPE(sourceFiles.values(), allClasses);
|
||||||
|
methCallargTypesRetType = ty.getMethCallargTypesRetType();
|
||||||
|
return ty.getConstraints();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMethods(SourceFile sf, ClassOrInterface cl, List<ClassOrInterface> importedClasses, ClassOrInterface objectClass) {
|
void addMethods(SourceFile sf, ClassOrInterface cl, List<ClassOrInterface> importedClasses, ClassOrInterface objectClass) {
|
||||||
@ -725,6 +730,7 @@ public class JavaTXCompiler {
|
|||||||
unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm,
|
unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm,
|
||||||
usedTasks);
|
usedTasks);
|
||||||
System.out.println("RESULT Final: " + li.getResults());
|
System.out.println("RESULT Final: " + li.getResults());
|
||||||
|
System.out.println("Constraints for Generated Generics: " + methCallargTypesRetType);
|
||||||
logFile.write("RES_FINAL: " + li.getResults().toString() + "\n");
|
logFile.write("RES_FINAL: " + li.getResults().toString() + "\n");
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
return li.getResults();
|
return li.getResults();
|
||||||
@ -753,6 +759,7 @@ public class JavaTXCompiler {
|
|||||||
return x; // wenn nichts veraendert wurde wird x zurueckgegeben
|
return x; // wenn nichts veraendert wurde wird x zurueckgegeben
|
||||||
}).collect(Collectors.toCollection(HashSet::new));
|
}).collect(Collectors.toCollection(HashSet::new));
|
||||||
System.out.println("RESULT Final: " + results);
|
System.out.println("RESULT Final: " + results);
|
||||||
|
System.out.println("Constraints for Generated Generics: " + methCallargTypesRetType);
|
||||||
logFile.write("RES_FINAL: " + results.toString() + "\n");
|
logFile.write("RES_FINAL: " + results.toString() + "\n");
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
logFile.write("PLACEHOLDERS: " + PlaceholderType.EXISTING_PLACEHOLDERS);
|
logFile.write("PLACEHOLDERS: " + PlaceholderType.EXISTING_PLACEHOLDERS);
|
||||||
|
@ -10,10 +10,6 @@ public class Constraint<A> extends HashSet<A> {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Boolean isInherited = false;//wird nur für die Method-Constraints benoetigt
|
private Boolean isInherited = false;//wird nur für die Method-Constraints benoetigt
|
||||||
|
|
||||||
/* es darf kein Constraint für den Return-Type erstellt werden, sonst gibt
|
|
||||||
* es Probleme beim Generated Generics
|
|
||||||
*/
|
|
||||||
public boolean isStatement = false;
|
|
||||||
|
|
||||||
private Constraint<A> extendConstraint = null;
|
private Constraint<A> extendConstraint = null;
|
||||||
|
|
||||||
@ -47,7 +43,7 @@ public class Constraint<A> extends HashSet<A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + "\nisInherited = " + isInherited + "\nisStatement = " + isStatement
|
return super.toString() + "\nisInherited = " + isInherited
|
||||||
//" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" )
|
//" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" )
|
||||||
+ "\n" ;
|
+ "\n" ;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import de.dhbwstuttgart.parser.scope.JavaClassName;
|
|||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||||
@ -14,6 +15,8 @@ public class TYPE {
|
|||||||
|
|
||||||
private final Collection<SourceFile> sfs;
|
private final Collection<SourceFile> sfs;
|
||||||
private final TypeInferenceInformation typeInferenceInformation;
|
private final TypeInferenceInformation typeInferenceInformation;
|
||||||
|
|
||||||
|
private Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> methCallargTypesRetType = new HashMap<>();
|
||||||
|
|
||||||
public TYPE(Collection<SourceFile> sourceFiles, Collection<ClassOrInterface> allAvailableClasses){
|
public TYPE(Collection<SourceFile> sourceFiles, Collection<ClassOrInterface> allAvailableClasses){
|
||||||
sfs = sourceFiles;
|
sfs = sourceFiles;
|
||||||
@ -21,6 +24,10 @@ public class TYPE {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> getMethCallargTypesRetType() {
|
||||||
|
return methCallargTypesRetType;
|
||||||
|
}
|
||||||
|
|
||||||
public ConstraintSet getConstraints() {
|
public ConstraintSet getConstraints() {
|
||||||
ConstraintSet ret = new ConstraintSet();
|
ConstraintSet ret = new ConstraintSet();
|
||||||
for(SourceFile sf : sfs)
|
for(SourceFile sf : sfs)
|
||||||
@ -72,6 +79,7 @@ public class TYPE {
|
|||||||
TypeInferenceBlockInformation blockInfo = new TypeInferenceBlockInformation(info.getAvailableClasses(), currentClass, m);
|
TypeInferenceBlockInformation blockInfo = new TypeInferenceBlockInformation(info.getAvailableClasses(), currentClass, m);
|
||||||
TYPEStmt methodScope = new TYPEStmt(blockInfo);
|
TYPEStmt methodScope = new TYPEStmt(blockInfo);
|
||||||
m.block.accept(methodScope);
|
m.block.accept(methodScope);
|
||||||
|
methCallargTypesRetType.putAll(methodScope.getMethCallargTypesRetType());
|
||||||
return methodScope.getConstraints();
|
return methodScope.getConstraints();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +89,7 @@ public class TYPE {
|
|||||||
//for(Statement stmt : m.fieldInitializations)stmt.accept(methodScope);
|
//for(Statement stmt : m.fieldInitializations)stmt.accept(methodScope);
|
||||||
ConstraintSet ret = this.getConstraintsMethod(m, info, currentClass);
|
ConstraintSet ret = this.getConstraintsMethod(m, info, currentClass);
|
||||||
ret.addAll(methodScope.getConstraints());
|
ret.addAll(methodScope.getConstraints());
|
||||||
|
methCallargTypesRetType.putAll(methodScope.getMethCallargTypesRetType());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
|
|
||||||
private final TypeInferenceBlockInformation info;
|
private final TypeInferenceBlockInformation info;
|
||||||
private final ConstraintSet constraintsSet = new ConstraintSet();
|
private final ConstraintSet constraintsSet = new ConstraintSet();
|
||||||
|
|
||||||
|
|
||||||
|
Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> methCallargTypesRetType = new HashMap<>();
|
||||||
|
|
||||||
public TYPEStmt(TypeInferenceBlockInformation info){
|
public TYPEStmt(TypeInferenceBlockInformation info){
|
||||||
this.info = info;
|
this.info = info;
|
||||||
@ -38,6 +41,10 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
public ConstraintSet getConstraints() {
|
public ConstraintSet getConstraints() {
|
||||||
return constraintsSet;
|
return constraintsSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> getMethCallargTypesRetType() {
|
||||||
|
return methCallargTypesRetType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Erstellt einen neuen GenericResolver
|
* Erstellt einen neuen GenericResolver
|
||||||
@ -166,6 +173,14 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
//Es wird in OderConstraints davon ausgegangen dass die Bedingungen für die Typen der Argumente links stehen
|
//Es wird in OderConstraints davon ausgegangen dass die Bedingungen für die Typen der Argumente links stehen
|
||||||
//und die Typen der Rückgabewerte immer rechts stehen (vgl. JavaTXCompiler)
|
//und die Typen der Rückgabewerte immer rechts stehen (vgl. JavaTXCompiler)
|
||||||
public void visit(MethodCall methodCall) {
|
public void visit(MethodCall methodCall) {
|
||||||
|
Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric> argTypesRetType = new HashMap<>();
|
||||||
|
argTypesRetType.put(methodCall.getArgumentList()
|
||||||
|
.getArguments()
|
||||||
|
.stream()
|
||||||
|
.map(x -> x.getType())
|
||||||
|
.collect(Collectors.toCollection(HashSet::new)),
|
||||||
|
methodCall.getType());
|
||||||
|
methCallargTypesRetType.put(methodCall.name, argTypesRetType);
|
||||||
methodCall.receiver.accept(this);
|
methodCall.receiver.accept(this);
|
||||||
//Overloading:
|
//Overloading:
|
||||||
Set<Constraint<Pair>> methodConstraints = new HashSet<>();
|
Set<Constraint<Pair>> methodConstraints = new HashSet<>();
|
||||||
@ -181,7 +196,6 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
? new Pair(x.TA1, new ExtendsWildcardType(x.TA2, x.TA2.getOffset()), PairOperator.EQUALSDOT)
|
? new Pair(x.TA1, new ExtendsWildcardType(x.TA2, x.TA2.getOffset()), PairOperator.EQUALSDOT)
|
||||||
: x)
|
: x)
|
||||||
.collect(Collectors.toCollection(() -> new Constraint<Pair>(oneMethodConstraint.isInherited())));
|
.collect(Collectors.toCollection(() -> new Constraint<Pair>(oneMethodConstraint.isInherited())));
|
||||||
extendsOneMethodConstraint.isStatement = oneMethodConstraint.isStatement;
|
|
||||||
oneMethodConstraint.setExtendConstraint(extendsOneMethodConstraint);
|
oneMethodConstraint.setExtendConstraint(extendsOneMethodConstraint);
|
||||||
extendsOneMethodConstraint.setExtendConstraint(oneMethodConstraint);
|
extendsOneMethodConstraint.setExtendConstraint(oneMethodConstraint);
|
||||||
methodConstraints.add(extendsOneMethodConstraint);
|
methodConstraints.add(extendsOneMethodConstraint);
|
||||||
@ -598,7 +612,6 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
||||||
|
|
||||||
|
|
||||||
methodConstraint.isStatement = forMethod.getStatement();
|
|
||||||
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(),
|
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(),
|
||||||
PairOperator.EQUALSDOT));
|
PairOperator.EQUALSDOT));
|
||||||
methodConstraint.addAll(generateParameterConstraints(forMethod, assumption, info, resolver));
|
methodConstraint.addAll(generateParameterConstraints(forMethod, assumption, info, resolver));
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
public interface Fun1$$<R, T> {
|
|
||||||
public R apply(T t);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user