forked from JavaTX/JavaCompilerCore
Merge branch 'targetBytecode' of gohorb.ba-horb.de:/bahome/projekt/git/JavaCompilerCore into targetBytecode
This commit is contained in:
commit
e8eaa3ac6e
@ -71,6 +71,9 @@ public class JavaTXCompiler {
|
||||
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
||||
private final DirectoryClassLoader classLoader;
|
||||
|
||||
private Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> methCallargTypesRetType = new HashMap<>();
|
||||
|
||||
|
||||
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||
this(Arrays.asList(sourceFile), null);
|
||||
}
|
||||
@ -127,7 +130,9 @@ public class JavaTXCompiler {
|
||||
allClasses.addAll(sf.getClasses());
|
||||
}
|
||||
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) {
|
||||
@ -725,6 +730,7 @@ public class JavaTXCompiler {
|
||||
unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm,
|
||||
usedTasks);
|
||||
System.out.println("RESULT Final: " + li.getResults());
|
||||
System.out.println("Constraints for Generated Generics: " + methCallargTypesRetType);
|
||||
logFile.write("RES_FINAL: " + li.getResults().toString() + "\n");
|
||||
logFile.flush();
|
||||
return li.getResults();
|
||||
@ -753,6 +759,7 @@ public class JavaTXCompiler {
|
||||
return x; // wenn nichts veraendert wurde wird x zurueckgegeben
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
System.out.println("RESULT Final: " + results);
|
||||
System.out.println("Constraints for Generated Generics: " + methCallargTypesRetType);
|
||||
logFile.write("RES_FINAL: " + results.toString() + "\n");
|
||||
logFile.flush();
|
||||
logFile.write("PLACEHOLDERS: " + PlaceholderType.EXISTING_PLACEHOLDERS);
|
||||
|
@ -10,10 +10,6 @@ public class Constraint<A> extends HashSet<A> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
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;
|
||||
|
||||
@ -47,7 +43,7 @@ public class Constraint<A> extends HashSet<A> {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return super.toString() + "\nisInherited = " + isInherited + "\nisStatement = " + isStatement
|
||||
return super.toString() + "\nisInherited = " + isInherited
|
||||
//" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" )
|
||||
+ "\n" ;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
@ -15,12 +16,18 @@ public class TYPE {
|
||||
private final Collection<SourceFile> sfs;
|
||||
private final TypeInferenceInformation typeInferenceInformation;
|
||||
|
||||
private Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> methCallargTypesRetType = new HashMap<>();
|
||||
|
||||
public TYPE(Collection<SourceFile> sourceFiles, Collection<ClassOrInterface> allAvailableClasses){
|
||||
sfs = sourceFiles;
|
||||
this.typeInferenceInformation = new TypeInferenceInformation(allAvailableClasses);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> getMethCallargTypesRetType() {
|
||||
return methCallargTypesRetType;
|
||||
}
|
||||
|
||||
public ConstraintSet getConstraints() {
|
||||
ConstraintSet ret = new ConstraintSet();
|
||||
for(SourceFile sf : sfs)
|
||||
@ -72,6 +79,7 @@ public class TYPE {
|
||||
TypeInferenceBlockInformation blockInfo = new TypeInferenceBlockInformation(info.getAvailableClasses(), currentClass, m);
|
||||
TYPEStmt methodScope = new TYPEStmt(blockInfo);
|
||||
m.block.accept(methodScope);
|
||||
methCallargTypesRetType.putAll(methodScope.getMethCallargTypesRetType());
|
||||
return methodScope.getConstraints();
|
||||
}
|
||||
|
||||
@ -81,6 +89,7 @@ public class TYPE {
|
||||
//for(Statement stmt : m.fieldInitializations)stmt.accept(methodScope);
|
||||
ConstraintSet ret = this.getConstraintsMethod(m, info, currentClass);
|
||||
ret.addAll(methodScope.getConstraints());
|
||||
methCallargTypesRetType.putAll(methodScope.getMethCallargTypesRetType());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ public class TYPEStmt implements StatementVisitor{
|
||||
private final TypeInferenceBlockInformation info;
|
||||
private final ConstraintSet constraintsSet = new ConstraintSet();
|
||||
|
||||
|
||||
Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> methCallargTypesRetType = new HashMap<>();
|
||||
|
||||
public TYPEStmt(TypeInferenceBlockInformation info){
|
||||
this.info = info;
|
||||
}
|
||||
@ -39,6 +42,10 @@ public class TYPEStmt implements StatementVisitor{
|
||||
return constraintsSet;
|
||||
}
|
||||
|
||||
public Map<String, Map<Set<RefTypeOrTPHOrWildcardOrGeneric>, RefTypeOrTPHOrWildcardOrGeneric>> getMethCallargTypesRetType() {
|
||||
return methCallargTypesRetType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt einen neuen GenericResolver
|
||||
* Die Idee dieser Datenstruktur ist es, GTVs einen eindeutigen TPH zuzuweisen.
|
||||
@ -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
|
||||
//und die Typen der Rückgabewerte immer rechts stehen (vgl. JavaTXCompiler)
|
||||
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);
|
||||
//Overloading:
|
||||
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)
|
||||
: x)
|
||||
.collect(Collectors.toCollection(() -> new Constraint<Pair>(oneMethodConstraint.isInherited())));
|
||||
extendsOneMethodConstraint.isStatement = oneMethodConstraint.isStatement;
|
||||
oneMethodConstraint.setExtendConstraint(extendsOneMethodConstraint);
|
||||
extendsOneMethodConstraint.setExtendConstraint(oneMethodConstraint);
|
||||
methodConstraints.add(extendsOneMethodConstraint);
|
||||
@ -598,7 +612,6 @@ public class TYPEStmt implements StatementVisitor{
|
||||
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
||||
|
||||
|
||||
methodConstraint.isStatement = forMethod.getStatement();
|
||||
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(),
|
||||
PairOperator.EQUALSDOT));
|
||||
methodConstraint.addAll(generateParameterConstraints(forMethod, assumption, info, resolver));
|
||||
|
Loading…
Reference in New Issue
Block a user