forked from JavaTX/JavaCompilerCore
BigRefacoring branch hard rueberkopiert
This commit is contained in:
parent
42aee3dbec
commit
82d8ecba74
BIN
src/main/java/de/dhbwstuttgart/.DS_Store
vendored
BIN
src/main/java/de/dhbwstuttgart/.DS_Store
vendored
Binary file not shown.
@ -832,7 +832,9 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
System.out.println(methods[i]);
|
||||
}
|
||||
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methCallType, typesOfParams,methods);
|
||||
}catch (Exception e2) {
|
||||
}
|
||||
catch (Exception e2) {
|
||||
System.out.println("");
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
//PL 2018-12-19: typeInferenceOld nach typeInference uebertragen
|
||||
package de.dhbwstuttgart.core;
|
||||
|
||||
|
||||
@ -15,6 +16,7 @@ import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||
@ -30,6 +32,7 @@ import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnifyTask;
|
||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl;
|
||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultModel;
|
||||
@ -38,6 +41,7 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@ -50,7 +54,7 @@ public class JavaTXCompiler {
|
||||
final CompilationEnvironment environment;
|
||||
Boolean resultmodel = true;
|
||||
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
||||
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"/test/logFiles/log" 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 JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||
this(Arrays.asList(sourceFile));
|
||||
@ -109,7 +113,8 @@ public class JavaTXCompiler {
|
||||
return new ArrayList<>(allClasses);
|
||||
}
|
||||
|
||||
public List<ResultSet> typeInference() throws ClassNotFoundException {
|
||||
/*
|
||||
public List<ResultSet> typeInferenceOld() throws ClassNotFoundException {
|
||||
List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
|
||||
//Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
|
||||
for(SourceFile sf : this.sourceFiles.values()) {
|
||||
@ -193,10 +198,7 @@ public class JavaTXCompiler {
|
||||
}
|
||||
}
|
||||
return x;//HIER DIE JEWEILS RECHT BZW. LINKE SEITE AUF GLEICHE VARIANZ SETZEN WIE DIE JEWEILS ANDERE SEITE
|
||||
})
|
||||
/* PL 2018-11-07 wird in varianceInheritance erledigt
|
||||
.map( y -> {
|
||||
|
||||
}).map( y -> {
|
||||
if ((y.getLhsType() instanceof PlaceholderType) && (y.getRhsType() instanceof PlaceholderType)) {
|
||||
if (((PlaceholderType)y.getLhsType()).getVariance() != 0 && ((PlaceholderType)y.getRhsType()).getVariance() == 0) {
|
||||
((PlaceholderType)y.getRhsType()).setVariance(((PlaceholderType)y.getLhsType()).getVariance());
|
||||
@ -206,18 +208,14 @@ public class JavaTXCompiler {
|
||||
}
|
||||
}
|
||||
return y; } )
|
||||
*/
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
varianceInheritance(xConsSet);
|
||||
|
||||
|
||||
|
||||
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure, logFile, log);
|
||||
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||
System.out.println("RESULT: " + result);
|
||||
logFile.write("RES: " + result.toString()+"\n");
|
||||
logFile.flush();
|
||||
results.addAll(result);
|
||||
varianceInheritance(xConsSet);
|
||||
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure, logFile, log);
|
||||
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||
System.out.println("RESULT: " + result);
|
||||
logFile.write("RES: " + result.toString()+"\n");
|
||||
logFile.flush();
|
||||
results.addAll(result);
|
||||
}
|
||||
|
||||
results = results.stream().map(x -> {
|
||||
@ -242,12 +240,14 @@ public class JavaTXCompiler {
|
||||
return results.stream().map((unifyPairs ->
|
||||
new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Vererbt alle Variancen
|
||||
* Vererbt alle Variancen bei Paaren (a <. theta) oder (Theta <. a)
|
||||
* wenn a eine Variance !=0 hat auf alle Typvariablen in Theta.
|
||||
* @param eq The set of constraints
|
||||
*/
|
||||
private void varianceInheritance(Set<UnifyPair> eq) {
|
||||
/*
|
||||
private void varianceInheritance(Set<UnifyPair> eq) {
|
||||
Set<PlaceholderType> usedTPH = new HashSet<>();
|
||||
Set<PlaceholderType> phSet = eq.stream().map(x -> {
|
||||
Set<PlaceholderType> pair = new HashSet<>();
|
||||
@ -273,8 +273,6 @@ public class JavaTXCompiler {
|
||||
phSetVariance.removeIf(x -> (x.getVariance() == 0 || usedTPH.contains(x)));
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
*/
|
||||
|
||||
public UnifyResultModel typeInferenceAsync() throws ClassNotFoundException {
|
||||
@ -289,7 +287,7 @@ public class JavaTXCompiler {
|
||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||
UnifyResultModel urm = null;
|
||||
try {
|
||||
FileWriter logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
||||
Writer logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
||||
|
||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile);
|
||||
System.out.println(finiteClosure);
|
||||
@ -425,7 +423,7 @@ public class JavaTXCompiler {
|
||||
final ConstraintSet<Pair> cons = getConstraints();
|
||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||
try {
|
||||
FileWriter logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
||||
Writer logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
||||
|
||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile);
|
||||
System.out.println(finiteClosure);
|
||||
@ -630,7 +628,6 @@ public class JavaTXCompiler {
|
||||
return usedTPH;
|
||||
}
|
||||
|
||||
>>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package de.dhbwstuttgart.syntaxtree.factory;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -29,7 +31,7 @@ public class UnifyTypeFactory {
|
||||
|
||||
private static ArrayList<PlaceholderType> PLACEHOLDERS = new ArrayList<>();
|
||||
|
||||
public static FiniteClosure generateFC(List<ClassOrInterface> fromClasses) throws ClassNotFoundException {
|
||||
public static FiniteClosure generateFC(List<ClassOrInterface> fromClasses, Writer logFile) throws ClassNotFoundException {
|
||||
/*
|
||||
Die transitive Hülle muss funktionieren.
|
||||
Man darf schreiben List<A> extends AL<A>
|
||||
@ -40,7 +42,7 @@ public class UnifyTypeFactory {
|
||||
Generell dürfen sie immer die gleichen Namen haben.
|
||||
TODO: die transitive Hülle bilden
|
||||
*/
|
||||
return new FiniteClosure(FCGenerator.toUnifyFC(fromClasses));
|
||||
return new FiniteClosure(FCGenerator.toUnifyFC(fromClasses), logFile);
|
||||
}
|
||||
|
||||
public static UnifyPair generateSmallerPair(UnifyType tl, UnifyType tr){
|
||||
@ -63,26 +65,26 @@ public class UnifyTypeFactory {
|
||||
* Convert from
|
||||
* ASTType -> UnifyType
|
||||
*/
|
||||
public static UnifyType convert(RefTypeOrTPHOrWildcardOrGeneric t){
|
||||
public static UnifyType convert(RefTypeOrTPHOrWildcardOrGeneric t, Boolean innerType){
|
||||
if(t instanceof GenericRefType){
|
||||
return UnifyTypeFactory.convert((GenericRefType)t);
|
||||
return UnifyTypeFactory.convert((GenericRefType)t, innerType);
|
||||
}else
|
||||
if(t instanceof FunN){
|
||||
return UnifyTypeFactory.convert((FunN)t);
|
||||
return UnifyTypeFactory.convert((FunN)t, innerType);
|
||||
}else if(t instanceof TypePlaceholder){
|
||||
return UnifyTypeFactory.convert((TypePlaceholder)t);
|
||||
return UnifyTypeFactory.convert((TypePlaceholder)t, innerType);
|
||||
}else if(t instanceof ExtendsWildcardType){
|
||||
return UnifyTypeFactory.convert((ExtendsWildcardType)t);
|
||||
return UnifyTypeFactory.convert((ExtendsWildcardType)t, innerType);
|
||||
}else if(t instanceof SuperWildcardType){
|
||||
return UnifyTypeFactory.convert((SuperWildcardType)t);
|
||||
return UnifyTypeFactory.convert((SuperWildcardType)t, innerType);
|
||||
}else if(t instanceof RefType){
|
||||
return UnifyTypeFactory.convert((RefType)t);
|
||||
return UnifyTypeFactory.convert((RefType)t, innerType);
|
||||
}
|
||||
//Es wurde versucht ein Typ umzuwandeln, welcher noch nicht von der Factory abgedeckt ist
|
||||
throw new NotImplementedException("Der Typ "+t+" kann nicht umgewandelt werden");
|
||||
}
|
||||
|
||||
public static UnifyType convert(RefType t){
|
||||
public static UnifyType convert(RefType t, Boolean innerType){
|
||||
//Check if it is a FunN Type:
|
||||
Pattern p = Pattern.compile("Fun(\\d+)");
|
||||
Matcher m = p.matcher(t.getName().toString());
|
||||
@ -90,14 +92,14 @@ public class UnifyTypeFactory {
|
||||
if(b){
|
||||
Integer N = Integer.valueOf(m.group(1));
|
||||
if((N + 1) == t.getParaList().size()){
|
||||
return convert(new FunN(t.getParaList()));
|
||||
return convert(new FunN(t.getParaList()), false);
|
||||
}
|
||||
}
|
||||
UnifyType ret;
|
||||
if(t.getParaList() != null && t.getParaList().size() > 0){
|
||||
List<UnifyType> params = new ArrayList<>();
|
||||
for(RefTypeOrTPHOrWildcardOrGeneric pT : t.getParaList()){
|
||||
params.add(UnifyTypeFactory.convert(pT));
|
||||
params.add(UnifyTypeFactory.convert(pT, true));
|
||||
}
|
||||
ret = new ReferenceType(t.getName().toString(),new TypeParams(params));
|
||||
}else{
|
||||
@ -106,39 +108,45 @@ public class UnifyTypeFactory {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static UnifyType convert(FunN t){
|
||||
public static UnifyType convert(FunN t, Boolean innerType){
|
||||
UnifyType ret;
|
||||
List<UnifyType> params = new ArrayList<>();
|
||||
if(t.getParaList() != null && t.getParaList().size() > 0){
|
||||
for(RefTypeOrTPHOrWildcardOrGeneric pT : t.getParaList()){
|
||||
params.add(UnifyTypeFactory.convert(pT));
|
||||
params.add(UnifyTypeFactory.convert(pT, false));
|
||||
}
|
||||
}
|
||||
ret = FunNType.getFunNType(new TypeParams(params));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static UnifyType convert(TypePlaceholder tph){
|
||||
public static UnifyType convert(TypePlaceholder tph, Boolean innerType){
|
||||
if (tph.getName().equals("AFR")) {
|
||||
System.out.println("XXX"+innerType);
|
||||
}
|
||||
PlaceholderType ntph = new PlaceholderType(tph.getName());
|
||||
int in = PLACEHOLDERS.indexOf(ntph);
|
||||
if (in == -1) {
|
||||
PLACEHOLDERS.add(ntph);
|
||||
ntph.setInnerType(innerType);
|
||||
return ntph;
|
||||
}
|
||||
else {
|
||||
return PLACEHOLDERS.get(in);
|
||||
PlaceholderType oldpht = PLACEHOLDERS.get(in);
|
||||
oldpht.setInnerType(oldpht.isInnerType() || innerType);
|
||||
return oldpht;
|
||||
}
|
||||
}
|
||||
|
||||
public static UnifyType convert(GenericRefType t){
|
||||
public static UnifyType convert(GenericRefType t, Boolean innerType){
|
||||
return new ReferenceType(t.getParsedName());
|
||||
}
|
||||
|
||||
public static UnifyType convert(WildcardType t){
|
||||
public static UnifyType convert(WildcardType t, Boolean innerType){
|
||||
if(t.isExtends())
|
||||
return new ExtendsType(UnifyTypeFactory.convert(t.getInnerType()));
|
||||
return new ExtendsType(UnifyTypeFactory.convert(t.getInnerType(), false));
|
||||
else if(t.isSuper())
|
||||
return new SuperType(UnifyTypeFactory.convert(t.getInnerType()));
|
||||
return new SuperType(UnifyTypeFactory.convert(t.getInnerType(), false));
|
||||
else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@ -152,22 +160,42 @@ public class UnifyTypeFactory {
|
||||
}
|
||||
|
||||
public static UnifyPair convert(Pair p) {
|
||||
UnifyPair ret = null;
|
||||
if(p.GetOperator().equals(PairOperator.SMALLERDOT)) {
|
||||
UnifyPair ret = generateSmallerDotPair(UnifyTypeFactory.convert(p.TA1)
|
||||
, UnifyTypeFactory.convert(p.TA2));
|
||||
return ret;
|
||||
ret = generateSmallerDotPair(UnifyTypeFactory.convert(p.TA1, false)
|
||||
, UnifyTypeFactory.convert(p.TA2, false));
|
||||
//return ret;
|
||||
}else if(p.GetOperator().equals(PairOperator.SMALLERNEQDOT)) {
|
||||
UnifyPair ret = generateSmallNotEqualDotPair(UnifyTypeFactory.convert(p.TA1)
|
||||
, UnifyTypeFactory.convert(p.TA2));
|
||||
return ret;
|
||||
ret = generateSmallNotEqualDotPair(UnifyTypeFactory.convert(p.TA1, false)
|
||||
, UnifyTypeFactory.convert(p.TA2, false));
|
||||
//return ret;
|
||||
}else if(p.GetOperator().equals(PairOperator.EQUALSDOT)) {
|
||||
UnifyPair ret = generateEqualDotPair(UnifyTypeFactory.convert(p.TA1)
|
||||
, UnifyTypeFactory.convert(p.TA2));
|
||||
return ret;
|
||||
ret = generateEqualDotPair(UnifyTypeFactory.convert(p.TA1, false)
|
||||
, UnifyTypeFactory.convert(p.TA2, false));
|
||||
//return ret;
|
||||
}else if(p.GetOperator().equals(PairOperator.SMALLER)){
|
||||
return generateSmallerPair(UnifyTypeFactory.convert(p.TA1),
|
||||
UnifyTypeFactory.convert(p.TA2));
|
||||
ret = generateSmallerPair(UnifyTypeFactory.convert(p.TA1, false),
|
||||
UnifyTypeFactory.convert(p.TA2, false));
|
||||
}else throw new NotImplementedException();
|
||||
UnifyType lhs, rhs;
|
||||
if (((lhs = ret.getLhsType()) instanceof PlaceholderType)
|
||||
&& ((PlaceholderType)lhs).isWildcardable()
|
||||
&& (rhs = ret.getLhsType()) instanceof PlaceholderType) {
|
||||
if (lhs.getName().equals("AQ")) {
|
||||
System.out.println("");
|
||||
}
|
||||
((PlaceholderType)rhs).enableWildcardtable();
|
||||
}
|
||||
|
||||
if (((rhs = ret.getLhsType()) instanceof PlaceholderType)
|
||||
&& ((PlaceholderType)rhs).isWildcardable()
|
||||
&& (lhs = ret.getLhsType()) instanceof PlaceholderType) {
|
||||
if (rhs.getName().equals("AQ")) {
|
||||
System.out.println("");
|
||||
}
|
||||
((PlaceholderType)lhs).enableWildcardtable();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,7 @@ import de.dhbwstuttgart.typeinference.unify.GuavaSetOperations;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -53,4 +54,29 @@ public class ConstraintSet<A> {
|
||||
ret.oderConstraints = newOder;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void forEach (Consumer<? super A> c) {
|
||||
undConstraints.stream().forEach(c);
|
||||
for(Set<Constraint<A>> oderConstraint : oderConstraints){
|
||||
oderConstraint.parallelStream().forEach((Constraint<A> as) ->
|
||||
as.stream().forEach(c));
|
||||
}
|
||||
}
|
||||
|
||||
public Set<A> getAll () {
|
||||
Set<A> ret = new HashSet<>();
|
||||
ret.addAll(undConstraints);
|
||||
for(Set<Constraint<A>> oderConstraint : oderConstraints){
|
||||
oderConstraint.parallelStream().forEach((Constraint<A> as) -> ret.addAll(as));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<Set<Constraint<A>>> getOderConstraints() {
|
||||
return oderConstraints;
|
||||
}
|
||||
|
||||
public Set<A> getUndConstraints() {
|
||||
return undConstraints;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
//PL 2018-12-19: Merge chekcen
|
||||
package de.dhbwstuttgart.typeinference.typeAlgo;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
@ -229,6 +230,13 @@ public class TYPEStmt implements StatementVisitor{
|
||||
binary.operation.equals(BinaryExpr.Operator.SUB)){
|
||||
Set<Constraint<Pair>> numericAdditionOrStringConcatenation = new HashSet<>();
|
||||
|
||||
// TODO PL 2018-11-06
|
||||
|
||||
// Auf importierte Typen einschraenken
|
||||
// pruefen, ob Typen richtig bestimmt werden.
|
||||
|
||||
|
||||
|
||||
//Zuerst der Fall für Numerische AusdrücPairOpnumericeratorke, das sind Mul, Mod und Div immer:
|
||||
//see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17
|
||||
//Expression muss zu Numeric Convertierbar sein. also von Numeric erben
|
||||
|
@ -22,6 +22,8 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||
public class Match implements IMatch {
|
||||
|
||||
@Override
|
||||
//A<X> =. A<Integer> ==> True
|
||||
//A<Integer> =. A<X> ==> False
|
||||
public Optional<Unifier> match(ArrayList<UnifyPair> termsList) {
|
||||
|
||||
// Start with the identity unifier. Substitutions will be added later.
|
||||
|
@ -30,6 +30,7 @@ import de.dhbwstuttgart.typeinference.unify.distributeVariance;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Implementation of the type inference rules.
|
||||
@ -38,13 +39,13 @@ import java.io.IOException;
|
||||
*/
|
||||
public class RuleSet implements IRuleSet{
|
||||
|
||||
FileWriter logFile;
|
||||
Writer logFile;
|
||||
|
||||
public RuleSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
RuleSet(FileWriter logFile) {
|
||||
RuleSet(Writer logFile) {
|
||||
this.logFile = logFile;
|
||||
}
|
||||
|
||||
@ -321,20 +322,21 @@ public class RuleSet implements IRuleSet{
|
||||
|
||||
UnifyType lhsType = pair.getLhsType();
|
||||
ReferenceType lhsSType;
|
||||
UnifyType rhsType = pair.getRhsType();
|
||||
ReferenceType rhsSType;
|
||||
|
||||
if(lhsType instanceof ReferenceType)
|
||||
if ((lhsType instanceof ReferenceType) && (rhsType instanceof ReferenceType)) {
|
||||
lhsSType = (ReferenceType) lhsType;
|
||||
<<<<<<< HEAD
|
||||
else if(lhsType instanceof WildcardType) {
|
||||
=======
|
||||
rhsSType = (ReferenceType) rhsType;
|
||||
}
|
||||
else if (((lhsType instanceof ExtendsType) && (rhsType instanceof ExtendsType))
|
||||
|| ((lhsType instanceof SuperType) && (rhsType instanceof SuperType))) {
|
||||
>>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8
|
||||
UnifyType lhsSTypeRaw = ((WildcardType) lhsType).getWildcardedType();
|
||||
if(lhsSTypeRaw instanceof ReferenceType)
|
||||
UnifyType rhsSTypeRaw = ((WildcardType) rhsType).getWildcardedType();
|
||||
if ((lhsSTypeRaw instanceof ReferenceType) && (rhsSTypeRaw instanceof ReferenceType)) {
|
||||
lhsSType = (ReferenceType) lhsSTypeRaw;
|
||||
rhsSType = (ReferenceType) rhsSTypeRaw;
|
||||
}
|
||||
else
|
||||
return Optional.empty();
|
||||
}
|
||||
@ -344,6 +346,7 @@ public class RuleSet implements IRuleSet{
|
||||
if(lhsSType.getTypeParams().empty())
|
||||
return Optional.empty();
|
||||
|
||||
/* PL 2018-01-22 in obere Teil integriert
|
||||
UnifyType rhsType = pair.getRhsType();
|
||||
ReferenceType rhsSType;
|
||||
|
||||
@ -358,6 +361,7 @@ public class RuleSet implements IRuleSet{
|
||||
}
|
||||
else
|
||||
return Optional.empty();
|
||||
*/
|
||||
|
||||
if(!rhsSType.getName().equals(lhsSType.getName()))
|
||||
return Optional.empty();
|
||||
|
@ -1,24 +1,19 @@
|
||||
package de.dhbwstuttgart.typeinference.unify;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
>>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
public class TypeUnify {
|
||||
<<<<<<< HEAD
|
||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true, logFile, log);
|
||||
=======
|
||||
|
||||
/**
|
||||
* unify parallel ohne result modell
|
||||
@ -30,17 +25,14 @@ public class TypeUnify {
|
||||
* @param cons
|
||||
* @return
|
||||
*/
|
||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, FileWriter logFile, Boolean log, UnifyResultModel ret) {
|
||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
||||
>>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
pool.invoke(unifyTask);
|
||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||
return res;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/**
|
||||
* unify asynchron mit Rückgabe UnifyResultModel ohne dass alle results gesammelt sind
|
||||
* @param undConstrains
|
||||
@ -52,7 +44,7 @@ public class TypeUnify {
|
||||
* @param ret
|
||||
* @return
|
||||
*/
|
||||
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, FileWriter logFile, Boolean log, UnifyResultModel ret) {
|
||||
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
pool.invoke(unifyTask);
|
||||
@ -70,7 +62,7 @@ public class TypeUnify {
|
||||
* @param ret
|
||||
* @return
|
||||
*/
|
||||
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, FileWriter logFile, Boolean log, UnifyResultModel ret) {
|
||||
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
pool.invoke(unifyTask);
|
||||
@ -79,14 +71,11 @@ public class TypeUnify {
|
||||
}
|
||||
|
||||
/*
|
||||
>>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8
|
||||
public Set<Set<UnifyPair>> unifySequential(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false, logFile, log);
|
||||
Set<Set<UnifyPair>> res = unifyTask.compute();
|
||||
return res;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -99,11 +88,10 @@ public class TypeUnify {
|
||||
* @param cons
|
||||
* @return
|
||||
*/
|
||||
public Set<Set<UnifyPair>> unifyOderConstraints(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, FileWriter logFile, Boolean log, UnifyResultModel ret) {
|
||||
public Set<Set<UnifyPair>> unifyOderConstraints(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret);
|
||||
Set<Set<UnifyPair>> res = unifyTask.compute();
|
||||
return res;
|
||||
}
|
||||
>>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package de.dhbwstuttgart.typeinference.unify;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -16,7 +17,7 @@ public class TypeUnify2Task extends TypeUnifyTask {
|
||||
|
||||
Set<Set<UnifyPair>> setToFlatten;
|
||||
|
||||
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log, int rekTiefe, UnifyResultModel urm) {
|
||||
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) {
|
||||
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm);
|
||||
this.setToFlatten = setToFlatten;
|
||||
this.nextSetElement = nextSetElement;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,7 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||
*/
|
||||
public interface IFiniteClosure {
|
||||
|
||||
public void setLogTrue();
|
||||
/**
|
||||
* Returns all types of the finite closure that are subtypes of the argument.
|
||||
* @return The set of subtypes of the argument.
|
||||
|
@ -1,5 +1,7 @@
|
||||
package de.dhbwstuttgart.typeinference.unify.model;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -31,6 +33,11 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify;
|
||||
public class FiniteClosure //extends Ordering<UnifyType> //entfernt PL 2018-12-11
|
||||
implements IFiniteClosure {
|
||||
|
||||
FileWriter logFile;
|
||||
static Boolean log = false;
|
||||
public void setLogTrue() {
|
||||
log = true;
|
||||
}
|
||||
/**
|
||||
* A map that maps every type to the node in the inheritance graph that contains that type.
|
||||
*/
|
||||
@ -47,10 +54,21 @@ implements IFiniteClosure {
|
||||
*/
|
||||
private Set<UnifyPair> pairs;
|
||||
|
||||
/**
|
||||
* Hastable fuer die greater-Werte, damit sie nicht doppelt berechnet werden muessen
|
||||
*/
|
||||
Hashtable<hashKeyType, Set<UnifyType>> greaterHash = new Hashtable<>();
|
||||
|
||||
/**
|
||||
* Hastable fuer die smaller-Werte, damit sie nicht doppelt berechnet werden muessen
|
||||
*/
|
||||
Hashtable<hashKeyType, Set<UnifyType>> smallerHash = new Hashtable<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance using the inheritance tree defined in the pairs.
|
||||
*/
|
||||
public FiniteClosure(Set<UnifyPair> pairs) {
|
||||
public FiniteClosure(Set<UnifyPair> pairs, FileWriter logFile) {
|
||||
this.logFile = logFile;
|
||||
this.pairs = new HashSet<>(pairs);
|
||||
inheritanceGraph = new HashMap<UnifyType, Node<UnifyType>>();
|
||||
|
||||
@ -111,12 +129,29 @@ implements IFiniteClosure {
|
||||
*/
|
||||
@Override
|
||||
public Set<UnifyType> smaller(UnifyType type, Set<UnifyType> fBounded) {
|
||||
|
||||
Set<UnifyType> ret;
|
||||
if ((ret = smallerHash.get(new hashKeyType(type))) != null) {
|
||||
//System.out.println(greaterHash);
|
||||
return new HashSet<>(ret);
|
||||
}
|
||||
|
||||
if(type instanceof FunNType)
|
||||
return computeSmallerFunN((FunNType) type, fBounded);
|
||||
|
||||
Set<Pair<UnifyType,Set<UnifyType>>> ts = new HashSet<>();
|
||||
ts.add(new Pair<>(type, fBounded));
|
||||
return computeSmaller(ts);
|
||||
Set<UnifyType> result = computeSmaller(ts);
|
||||
smallerHash.put(new hashKeyType(type), result);
|
||||
/*
|
||||
try {
|
||||
logFile.write("\ntype: " + type + "\nret: " + ret + "\nresult: " + result);//"smallerHash: " + greaterHash.toString());
|
||||
logFile.flush();
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.err.println("no LogFile");
|
||||
}*/
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,6 +245,13 @@ implements IFiniteClosure {
|
||||
//Eingefuegt PL 2018-05-24 F-Bounded Problematik
|
||||
public Set<UnifyType> greater(UnifyType type, Set<UnifyType> fBounded) {
|
||||
|
||||
Set<UnifyType> ret;
|
||||
if ((ret = greaterHash.get(new hashKeyType(type))) != null) {
|
||||
//System.out.println(greaterHash);
|
||||
return new HashSet<>(ret);
|
||||
}
|
||||
|
||||
|
||||
if(type instanceof FunNType) {
|
||||
return computeGreaterFunN((FunNType) type, fBounded);
|
||||
}
|
||||
@ -227,6 +269,17 @@ implements IFiniteClosure {
|
||||
|
||||
// if T <* T' then sigma(T) <* sigma(T')
|
||||
Set<Node<UnifyType>> candidates = strInheritanceGraph.get(type.getName());
|
||||
|
||||
/*
|
||||
try {
|
||||
if (log) logFile.write(candidates.toString());
|
||||
//log = false;
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.err.println("no LogFile");
|
||||
}
|
||||
*/
|
||||
|
||||
for(Node<UnifyType> candidate : candidates) {
|
||||
UnifyType theta1 = candidate.getContent();
|
||||
|
||||
@ -235,9 +288,9 @@ implements IFiniteClosure {
|
||||
termList.add(new UnifyPair(theta1,type, PairOperator.EQUALSDOT));
|
||||
Optional<Unifier> optSigma = match.match(termList);
|
||||
//PL 18-04-05 Unifier durch Matcher ersetzt ENDE
|
||||
if(!optSigma.isPresent())
|
||||
if(!optSigma.isPresent()) {
|
||||
continue;
|
||||
|
||||
}
|
||||
Unifier sigma = optSigma.get();
|
||||
sigma.swapPlaceholderSubstitutionsReverse(theta1.getTypeParams());
|
||||
|
||||
@ -250,7 +303,15 @@ implements IFiniteClosure {
|
||||
PairResultFBounded.add(new Pair<>(theta2.apply(sigma), fBoundedNew));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
try {
|
||||
if (log) logFile.write(PairResultFBounded.toString());
|
||||
log = false;
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.err.println("no LogFile");
|
||||
}
|
||||
*/
|
||||
for(Pair<UnifyType,Set<UnifyType>> pt : PairResultFBounded) {
|
||||
UnifyType t = pt.getKey();
|
||||
Set<UnifyType> lfBounded = pt.getValue().get();
|
||||
@ -286,6 +347,16 @@ implements IFiniteClosure {
|
||||
//System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
greaterHash.put(new hashKeyType(type), result);
|
||||
/*
|
||||
try {
|
||||
logFile.write("\ntype: " + type + "\nret: " + ret + "\nresult: " + result);//"greaterHash: " + greaterHash.toString());
|
||||
logFile.flush();
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.err.println("no LogFile");
|
||||
}*/
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -624,8 +695,15 @@ implements IFiniteClosure {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ((right instanceof PlaceholderType) && (left instanceof WildcardType)) {
|
||||
return 0;
|
||||
if (right instanceof PlaceholderType) {//&& (left instanceof WildcardType)) {PL geloescht 2019-01-15 analog zu oben
|
||||
if ((left instanceof WildcardType) //PL eingefuegt 2019-01-15 analog zu oben
|
||||
&& ((ex = ((WildcardType)left).wildcardedType) instanceof PlaceholderType)
|
||||
&& ((PlaceholderType)right).getName().equals(((PlaceholderType)ex).getName())) {// ? extends a <. a oder ? super a <. a
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
UnifyPair up = new UnifyPair(left, right, pairop);
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask();
|
||||
|
@ -31,7 +31,8 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
* in dem compare(Theta, Theta') aufgerufen wird.
|
||||
*/
|
||||
public int compareEq (UnifyPair left, UnifyPair right) {
|
||||
if (left.getRhsType() instanceof WildcardType || right.getRhsType() instanceof WildcardType) {
|
||||
//if (left.getRhsType() instanceof WildcardType || right.getRhsType() instanceof WildcardType) {//PL 2019-01-12 ausgetauscht
|
||||
if (((PlaceholderType)left.getLhsType()).isInnerType() && ((PlaceholderType)right.getLhsType()).isInnerType()) {
|
||||
return fc.compare(left.getRhsType(), right.getRhsType(), PairOperator.SMALLERDOTWC);
|
||||
}
|
||||
else {
|
||||
@ -55,6 +56,20 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
UnifyPair up;
|
||||
if (left instanceof WildcardType || right instanceof WildcardType) {
|
||||
up = new UnifyPair(left, right, PairOperator.SMALLERDOTWC);
|
||||
if (((left instanceof ExtendsType)
|
||||
&& (((ExtendsType)left).getExtendedType().getName().equals("java.util.Vector"))
|
||||
&& (((ReferenceType)((ExtendsType)left).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)) ||
|
||||
((right instanceof ExtendsType)
|
||||
&& (((ExtendsType)right).getExtendedType().getName().equals("java.util.Vector"))
|
||||
&& (((ReferenceType)((ExtendsType)right).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)))
|
||||
{
|
||||
System.out.println("");
|
||||
}
|
||||
if (((right instanceof SuperType) && (((SuperType)right).getSuperedType().getName().equals("java.lang.Object")))
|
||||
||((left instanceof SuperType) && (((SuperType)left).getSuperedType().getName().equals("java.lang.Object"))))
|
||||
{
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
else {
|
||||
up = new UnifyPair(left, right, PairOperator.SMALLERDOT);
|
||||
@ -68,6 +83,19 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
else {
|
||||
if (left instanceof WildcardType || right instanceof WildcardType) {
|
||||
up = new UnifyPair(right, left, PairOperator.SMALLERDOTWC);
|
||||
if (((left instanceof ExtendsType)
|
||||
&& (((ExtendsType)left).getExtendedType().getName().equals("java.util.Vector"))
|
||||
&& (((ReferenceType)((ExtendsType)left).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)) ||
|
||||
((right instanceof ExtendsType)
|
||||
&& (((ExtendsType)right).getExtendedType().getName().equals("java.util.Vector"))
|
||||
&& (((ReferenceType)((ExtendsType)right).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)))
|
||||
{
|
||||
System.out.println("");
|
||||
}
|
||||
if (right instanceof SuperType)
|
||||
{
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
else {
|
||||
up = new UnifyPair(right, left, PairOperator.SMALLERDOT);
|
||||
@ -88,8 +116,6 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
* @see com.google.common.collect.Ordering#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public int compare (Set<UnifyPair> left, Set<UnifyPair> right) {
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/*
|
||||
//pairop = PairOperator.SMALLERDOTWC;
|
||||
List<UnifyType> al = new ArrayList<>();
|
||||
@ -137,7 +163,6 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
>>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8
|
||||
Set<UnifyPair> lefteq = left.stream()
|
||||
.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT))
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
@ -161,17 +186,25 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
&& x.getPairOp() == PairOperator.SMALLERDOTWC))
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
//System.out.println(left.toString());
|
||||
//Fall 2 und 3
|
||||
//Fall 2
|
||||
//if (lefteq.iterator().next().getLhsType().getName().equals("AJO")) {
|
||||
// System.out.print("");
|
||||
//}
|
||||
if (lefteq.size() == 1 && leftle.size() == 1 && righteq.size() == 0 && rightle.size() == 1) {
|
||||
if (lefteq.size() == 1 && lefteq.iterator().next().getRhsType() instanceof ExtendsType && leftle.size() == 1 && righteq.size() == 0 && rightle.size() == 1) {
|
||||
return 1;
|
||||
}
|
||||
//Fall 2 und 3
|
||||
if (lefteq.size() == 0 && leftle.size() == 1 && righteq.size() == 1 && rightle.size() == 1) {
|
||||
//Fall 2
|
||||
if (lefteq.size() == 0 && leftle.size() == 1 && righteq.size() == 1 && righteq.iterator().next().getRhsType() instanceof ExtendsType && rightle.size() == 1) {
|
||||
return -1;
|
||||
}
|
||||
//Fall 3
|
||||
if (lefteq.size() == 1 && lefteq.iterator().next().getRhsType() instanceof SuperType && leftle.size() == 1 && righteq.size() == 0 && rightle.size() == 1) {
|
||||
return -1;
|
||||
}
|
||||
//Fall 3
|
||||
if (lefteq.size() == 0 && leftle.size() == 1 && righteq.size() == 1 && righteq.iterator().next().getRhsType() instanceof SuperType && rightle.size() == 1) {
|
||||
return 1;
|
||||
}
|
||||
//Fall 5
|
||||
if (lefteq.size() == 1 && leftle.size() == 0 && righteq.size() == 1 && rightle.size() == 1) {
|
||||
return -1;
|
||||
|
@ -46,6 +46,11 @@ public final class PlaceholderType extends UnifyType{
|
||||
*/
|
||||
private boolean wildcardable = true;
|
||||
|
||||
/**
|
||||
* is innerType gibt an, ob der Type des PlaceholderType innerhalb eines Typkonstruktorsverwendet wird
|
||||
*/
|
||||
private boolean innerType = false;
|
||||
|
||||
/**
|
||||
* variance shows the variance of the pair
|
||||
* -1: contravariant
|
||||
@ -108,6 +113,15 @@ public final class PlaceholderType extends UnifyType{
|
||||
return variance;
|
||||
}
|
||||
|
||||
public void reversVariance() {
|
||||
if (variance == 1) {
|
||||
setVariance(-1);
|
||||
} else {
|
||||
if (variance == -1) {
|
||||
setVariance(1);
|
||||
}}
|
||||
}
|
||||
|
||||
public Boolean isWildcardable() {
|
||||
return wildcardable;
|
||||
}
|
||||
@ -115,6 +129,22 @@ public final class PlaceholderType extends UnifyType{
|
||||
wildcardable = false;
|
||||
}
|
||||
|
||||
public void enableWildcardtable() {
|
||||
wildcardable = true;
|
||||
}
|
||||
|
||||
public void setWildcardtable(Boolean wildcardable) {
|
||||
this.wildcardable = wildcardable;
|
||||
}
|
||||
|
||||
public Boolean isInnerType() {
|
||||
return innerType;
|
||||
}
|
||||
|
||||
public void setInnerType(Boolean innerType) {
|
||||
this.innerType = innerType;
|
||||
}
|
||||
|
||||
@Override
|
||||
Set<UnifyType> smArg(IFiniteClosure fc, Set<UnifyType> fBounded) {
|
||||
return fc.smArg(this, fBounded);
|
||||
@ -157,7 +187,7 @@ public final class PlaceholderType extends UnifyType{
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<? extends PlaceholderType> getInvolvedPlaceholderTypes() {
|
||||
public Collection<PlaceholderType> getInvolvedPlaceholderTypes() {
|
||||
ArrayList<PlaceholderType> ret = new ArrayList<>();
|
||||
ret.add(this);
|
||||
return ret;
|
||||
|
@ -121,6 +121,10 @@ public class UnifyPair {
|
||||
pairOp = po;
|
||||
}
|
||||
|
||||
public void addSubstitutions(Set<UnifyPair> sup) {
|
||||
substitution.addAll(sup);
|
||||
}
|
||||
|
||||
public byte getVariance() {
|
||||
return variance;
|
||||
}
|
||||
@ -152,6 +156,15 @@ public class UnifyPair {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Set<UnifyPair> getAllBases () {
|
||||
Set<UnifyPair> ret = new HashSet<>();
|
||||
if (basePair != null) {
|
||||
ret.add(getBasePair());
|
||||
ret.addAll(basePair.getAllBases());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public UnifyPair getGroundBasePair () {
|
||||
if (basePair == null) {
|
||||
return this;
|
||||
@ -206,12 +219,12 @@ public class UnifyPair {
|
||||
public String toString() {
|
||||
String ret = "";
|
||||
if (lhs instanceof PlaceholderType) {
|
||||
ret = new Integer(((PlaceholderType)lhs).getVariance()).toString();
|
||||
ret = new Integer(((PlaceholderType)lhs).getVariance()).toString() + " " + ((PlaceholderType)lhs).isInnerType();
|
||||
}
|
||||
if (rhs instanceof PlaceholderType) {
|
||||
ret = ret + ", " + new Integer(((PlaceholderType)rhs).getVariance()).toString();
|
||||
ret = ret + ", " + new Integer(((PlaceholderType)rhs).getVariance()).toString() + " " + ((PlaceholderType)rhs).isInnerType();
|
||||
}
|
||||
return "(" + lhs + " " + pairOp + " " + rhs + ", " + ret + ", [" + getfBounded().toString()+ "])";
|
||||
return "(" + lhs + " " + pairOp + " " + rhs + ", " + ret + ")"; //+ ", [" + getfBounded().toString()+ "])";
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -97,7 +97,7 @@ public abstract class UnifyType {
|
||||
return typeName + params;
|
||||
}
|
||||
|
||||
public Collection<? extends PlaceholderType> getInvolvedPlaceholderTypes() {
|
||||
public Collection<PlaceholderType> getInvolvedPlaceholderTypes() {
|
||||
ArrayList<PlaceholderType> ret = new ArrayList<>();
|
||||
ret.addAll(typeParams.getInvolvedPlaceholderTypes());
|
||||
return ret;
|
||||
|
@ -64,7 +64,7 @@ public abstract class WildcardType extends UnifyType {
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<? extends PlaceholderType> getInvolvedPlaceholderTypes() {
|
||||
public Collection<PlaceholderType> getInvolvedPlaceholderTypes() {
|
||||
ArrayList<PlaceholderType> ret = new ArrayList<>();
|
||||
ret.addAll(wildcardedType.getInvolvedPlaceholderTypes());
|
||||
return ret;
|
||||
|
@ -17,8 +17,6 @@ import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
0
src/test/java/bytecode/MatrixTest.java
Normal file → Executable file
0
src/test/java/bytecode/MatrixTest.java
Normal file → Executable file
@ -26,8 +26,8 @@ public class YTest {
|
||||
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/Y.jav";
|
||||
fileToTest = new File(path);
|
||||
// compiler = new JavaTXCompiler(fileToTest);
|
||||
// compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/");
|
||||
// pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
// compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||
// pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||
// loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
// classToTest = loader.loadClass("Y");
|
||||
/*
|
||||
|
@ -1,9 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Long;
|
||||
|
||||
public class AddLong{
|
||||
Long add(Integer a, Long b) {
|
||||
Long c = a+b;
|
||||
return c;
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
public class EmptyClass{
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
public class EmptyMethod{
|
||||
static String s1 ="";
|
||||
String s2;
|
||||
public void m1(){
|
||||
//String s = "";
|
||||
System.out.println("test");
|
||||
//Integer ab = Math.abs(1);
|
||||
//Math.abs(1);
|
||||
//String lV = "local";
|
||||
//s1 = "1";
|
||||
//s1.concat("2");
|
||||
s2 = s1;
|
||||
//m2();
|
||||
Clazz i = new Clazz();
|
||||
Integer i = new Integer(1);
|
||||
}
|
||||
|
||||
public void m2(){}
|
||||
}
|
||||
|
||||
class Clazz{}
|
||||
/*
|
||||
public class EmptyMethod2{
|
||||
public static test = "5";
|
||||
public void m1(Integer i, String j, Boolean b){
|
||||
//String s = "";
|
||||
EmptyMethod em = new EmptyMethod();
|
||||
em.m1();
|
||||
em.s1 = "";
|
||||
//Integer ab = Math.abs(1);
|
||||
//Math.abs(1);
|
||||
//String lV = "local";
|
||||
//s1 = "1";
|
||||
//s1.concat("2");
|
||||
//s2 = s1;
|
||||
}
|
||||
}*/
|
@ -1,8 +0,0 @@
|
||||
class Expressions{
|
||||
|
||||
void test(){
|
||||
var x = 2;
|
||||
x = x + 2;
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class Matrix extends Vector<Vector<Integer>> {
|
||||
|
||||
methode(m) {
|
||||
m.add(1);
|
||||
Matrix i;
|
||||
methode(i);
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
class Faculty {
|
||||
|
||||
Integer mul(Integer x, Integer y) {
|
||||
return x;
|
||||
}
|
||||
|
||||
m () {
|
||||
var fact = (Integer x) -> {
|
||||
return mul(x, fact.apply(x));
|
||||
};
|
||||
return fact;
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
class Faculty {
|
||||
|
||||
m () {
|
||||
|
||||
var fact = (Integer x) -> {
|
||||
if (x == 1) {
|
||||
return x;
|
||||
}
|
||||
else {
|
||||
return x * (fact.apply(x-1));
|
||||
}
|
||||
};
|
||||
return fact;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
class Faculty {
|
||||
|
||||
Integer mul(Integer x, Integer y) {
|
||||
return x;
|
||||
}
|
||||
|
||||
Fun1<java.lang.Integer,java.lang.Integer> m () {
|
||||
var fact = (Integer x) -> {
|
||||
return mul(x, fact.apply(x));
|
||||
};
|
||||
return fact;
|
||||
}
|
||||
}
|
||||
|
||||
interface Fun1<A,B>{
|
||||
B apply(A a);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import java.lang.String;
|
||||
|
||||
class Fields{
|
||||
test2 = "test";
|
||||
test;
|
||||
m(){
|
||||
var test3;
|
||||
return test;
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
import java.lang.String;
|
||||
|
||||
class Generics<B> {
|
||||
//<A extends B> A mt1(A a, B b){
|
||||
B mt1(B a, B b){
|
||||
return mt1(a, a);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
methode(String s){
|
||||
return new Generics<String>().mt1(s,s);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Problem:
|
||||
auto test = new List<String>();
|
||||
auto test2 = new List<Integer>();
|
||||
... //code, welcher möglicherweise test und test2 vertauscht
|
||||
test.add("hallo");
|
||||
*/
|
@ -1,14 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Object;
|
||||
|
||||
public class IfTest{
|
||||
Object m1(b) {
|
||||
Integer i;
|
||||
if(b) {
|
||||
return i;
|
||||
}else{
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class Import {
|
||||
void methode(){
|
||||
Vector v;
|
||||
v.add(v);
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
|
||||
class Apply { }
|
||||
|
||||
public class Lambda {
|
||||
|
||||
m () {
|
||||
var lam1 = (x) -> {
|
||||
return x;
|
||||
};
|
||||
return lam1.apply(new Apply());
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
import java.lang.String;
|
||||
|
||||
public class Lambda2
|
||||
{
|
||||
public static void main(List<String> args){
|
||||
var listOfStrings = new List<String>();
|
||||
var listOfObjects;
|
||||
listOfObjects = map(listOfStrings, (a) -> a);
|
||||
}
|
||||
|
||||
public map(a , b){
|
||||
b.apply(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
public static <I,O> List<O> map(List<I> input, Function<I,O> func) {
|
||||
List<O> output;
|
||||
output = new List<O>();
|
||||
output.add(func.apply(input.get()));
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
class List<A>{
|
||||
A get();
|
||||
void add(A);
|
||||
}
|
||||
|
||||
class Function<A,B>{
|
||||
B apply(A a);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
import java.lang.String;
|
||||
|
||||
public class Lambda2
|
||||
{
|
||||
/*
|
||||
public static <A> List<A> map(List<? extends A> input,
|
||||
Function<? super A, ? extends A> func){
|
||||
input.add(func.apply(input.get()));
|
||||
}
|
||||
*/
|
||||
public map(input,func){
|
||||
input.add(func.apply(input.get()));
|
||||
return map(new List<String>(), func);
|
||||
}
|
||||
}
|
||||
|
||||
class List<A>{
|
||||
A get();
|
||||
void add(A);
|
||||
}
|
||||
|
||||
class Function<A,B>{
|
||||
B apply(A a);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
public class LambdaField {
|
||||
|
||||
f = x -> x;
|
||||
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
import java.lang.Runnable;
|
||||
import java.lang.String;
|
||||
import java.lang.System;
|
||||
|
||||
public class LamRunnable{
|
||||
|
||||
public LamRunnable(){
|
||||
|
||||
|
||||
Runnable lam = () -> {System.out.println("lambda");};
|
||||
lam.run();
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
|
||||
class ListenerOverload{
|
||||
|
||||
call(p){
|
||||
call(p.left);
|
||||
call(p.right);
|
||||
}
|
||||
|
||||
call(Integer i){}
|
||||
|
||||
call(String s){}
|
||||
|
||||
}
|
||||
|
||||
class Pair<A,B>{
|
||||
A left;
|
||||
B right;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
|
||||
class Matrix extends Vector<Vector<Integer>> {
|
||||
Integer mul1(Integer x, Integer y) { return x;}
|
||||
Integer add1(Integer x, Integer y) { return x;}
|
||||
mul(m) {
|
||||
var ret = new Matrix();
|
||||
var i = 0;
|
||||
while(i < size()) {
|
||||
var v1 = this.elementAt(i);
|
||||
var v2 = new Vector<Integer>();
|
||||
var j = 0;
|
||||
while(j < v1.size()) {
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
while(k < v1.size()) {
|
||||
erg = erg + v1.elementAt(k) * m.elementAt(k).elementAt(j);
|
||||
//erg = add1(erg, mul1(v1.elementAt(k),
|
||||
// m.elementAt(k).elementAt(j)));
|
||||
k++; }
|
||||
v2.addElement(new Integer(erg));
|
||||
j++; }
|
||||
ret.addElement(v2);
|
||||
i++; }
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
class Meth_Gen {
|
||||
|
||||
m1(x, y) {
|
||||
m2(x);
|
||||
x = y;
|
||||
}
|
||||
|
||||
m2(y) {
|
||||
m1(y, y);
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
import java.lang.String;
|
||||
|
||||
class Generics<B> {
|
||||
//<A extends B> A mt1(A a, B b){
|
||||
B mt1(B a, B b){
|
||||
return mt1(a, a);
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
methode(String s){
|
||||
return new Generics<String>().mt1(s,s);
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
|
||||
class Methods {
|
||||
mt4(a,b,c) { return a.add(b).sub(c) ; }
|
||||
|
||||
mt1(a) {return a;}
|
||||
|
||||
mt2(a) {return a.f; }
|
||||
|
||||
mt3(a) {return a.add(); }
|
||||
}
|
||||
|
||||
class Test {
|
||||
java.lang.Object f;
|
||||
add(){}
|
||||
add(b){return b;}
|
||||
sub(b){}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
|
||||
class Methods {
|
||||
mt4(a,b,c) { return a.mt3(b).mt3(c) ; }
|
||||
|
||||
mt3(a) {return a.mt3(a); }
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
public class Op1{
|
||||
public Op1() {
|
||||
|
||||
Runnable lam = () -> {
|
||||
String test = "";
|
||||
String b = "b";
|
||||
test = b;
|
||||
System.out.println(test);};
|
||||
//lam.run();
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package strucType.input;
|
||||
|
||||
class Neu
|
||||
{
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
class Sorting{
|
||||
void merge(a, b){
|
||||
a.addAll(b);
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
public class Subclass extends Superclass {
|
||||
|
||||
public void printMethod() {
|
||||
super.printMethod();
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
public class Superclass {
|
||||
|
||||
public void printMethod() {
|
||||
System.out.println("Printed in Superclass.");
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
import java.lang.Object;
|
||||
|
||||
class MyVector{
|
||||
|
||||
id(x){
|
||||
Object i;
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
x.add(i);
|
||||
return x;
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
import java.util.List;
|
||||
|
||||
class Test{
|
||||
methode(param1, param2, param3) {
|
||||
param2.add(param3);
|
||||
return param1.meth(param2);
|
||||
}
|
||||
}
|
||||
|
||||
interface Klasse1{
|
||||
Klasse1 meth(List p);
|
||||
Klasse1 meth(Klasse2 p);
|
||||
}
|
||||
|
||||
interface Klasse2{
|
||||
Klasse1 meth(Klasse1 p);
|
||||
Klasse2 meth(Klasse2 p);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
|
||||
class mathStruc<A> {
|
||||
|
||||
mathStruc(A a) { }
|
||||
|
||||
A model(){ A a; return a; }
|
||||
|
||||
methode(){
|
||||
var innerOp = o -> ms ->
|
||||
new mathStruc<A>(o.apply(this.model(),ms.model()));
|
||||
return innerOp;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
class Test{
|
||||
methode(param1, param2, param3) {
|
||||
return param1.meth(param2.meth(param3));
|
||||
}
|
||||
}
|
||||
|
||||
interface Klasse1{
|
||||
Klasse1 meth(Klasse1 p);
|
||||
Klasse1 meth(Klasse2 p);
|
||||
}
|
||||
|
||||
interface Klasse2{
|
||||
Klasse1 meth(Klasse1 p);
|
||||
Klasse2 meth(Klasse2 p);
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
class Faculty {
|
||||
|
||||
int a;
|
||||
m (int x) {
|
||||
return a+x;
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package bytecode;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
|
||||
/**
|
||||
* @author fayez
|
||||
*
|
||||
*/
|
||||
public class LambdaCapturetest {
|
||||
private static String path;
|
||||
private static File fileToTest;
|
||||
private static JavaTXCompiler compiler;
|
||||
private static ClassLoader loader;
|
||||
private static Class<?> classToTest;
|
||||
private static String pathToClassFile;
|
||||
private static Object instanceOfClass;
|
||||
|
||||
@Test
|
||||
public void generateBC() throws Exception {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/LambdaCapture.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/");
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("LambdaCapture");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
public class Id {
|
||||
public class Id {
|
||||
|
||||
<BVKZ,BVLA extends BVKZ> BVKZ id(BVLA b){
|
||||
id(b){
|
||||
return b;
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
//import java.lang.Float;
|
||||
import java.lang.Float;
|
||||
//import java.lang.Byte;
|
||||
import java.lang.Boolean;
|
||||
//import java.lang.Boolean;
|
||||
|
||||
public class Matrix extends Vector<Vector<Integer>> {
|
||||
public class Matrix extends Vector<Vector<Integer>> {
|
||||
|
||||
Matrix () {
|
||||
}
|
||||
@ -19,7 +19,7 @@ public class Matrix extends Vector<Vector<Integer>> {
|
||||
}
|
||||
}
|
||||
|
||||
mul(java.util.Vector<? extends java.util.Vector<? extends java.lang.Integer>> m) {
|
||||
mul(m) {
|
||||
var ret = new Matrix();
|
||||
var i = 0;
|
||||
while(i < size()) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import java.util.List;
|
||||
import java.lang.Integer;
|
||||
import java.util.Collection;
|
||||
//import java.util.Collection;
|
||||
|
||||
class Merge {
|
||||
class Merge {
|
||||
|
||||
merge(a, b) {
|
||||
a.addAll(b);
|
||||
|
@ -4,9 +4,9 @@ import java.lang.Double;
|
||||
|
||||
|
||||
|
||||
public class OL {
|
||||
public class OL {
|
||||
|
||||
mjava.lang.String (java.lang.String x) { return x + x; }
|
||||
m(x) { return x + x; }
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,76 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package bytecode.simplifyalgo;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
||||
|
||||
/**
|
||||
* @author Fayez Abu Alia
|
||||
*
|
||||
*/
|
||||
public class CycleTest {
|
||||
|
||||
private static TPHExtractor tphExtractor;
|
||||
private static String methName;
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
tphExtractor = new TPHExtractor();
|
||||
// A < B
|
||||
TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS);
|
||||
// B < C
|
||||
TPHConstraint c2 = new ExtendsConstraint("B", "C", Relation.EXTENDS);
|
||||
// C < D
|
||||
TPHConstraint c3 = new ExtendsConstraint("C", "D", Relation.EXTENDS);
|
||||
// D < A
|
||||
TPHConstraint c4 = new ExtendsConstraint("D", "A", Relation.EXTENDS);
|
||||
// name
|
||||
methName = "m";
|
||||
MethodAndTPH mtph = new MethodAndTPH("m");
|
||||
mtph.getTphs().add("A");
|
||||
mtph.getTphs().add("B");
|
||||
mtph.getTphs().add("C");
|
||||
mtph.getTphs().add("D");
|
||||
tphExtractor.ListOfMethodsAndTph.add(mtph);
|
||||
tphExtractor.allCons.add(c1);
|
||||
tphExtractor.allCons.add(c2);
|
||||
tphExtractor.allCons.add(c3);
|
||||
tphExtractor.allCons.add(c4);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
HashMap<TPHConstraint, HashSet<String>> result = new HashMap<>();
|
||||
HashSet<String> equals = new HashSet<>();
|
||||
equals.add("A");
|
||||
equals.add("B");
|
||||
equals.add("C");
|
||||
equals.add("D");
|
||||
TPHConstraint k = new ExtendsConstraint("A", Type.getInternalName(Object.class), Relation.EXTENDS);
|
||||
result.put(k, equals);
|
||||
|
||||
HashMap<TPHConstraint, HashSet<String>> sim = Simplify.simplifyConstraints(methName, tphExtractor);
|
||||
boolean areEquals = SimpleCycle.areMapsEqual(result, sim);
|
||||
assertTrue(areEquals);
|
||||
}
|
||||
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
package bytecode.simplifyalgo;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsertPlacer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Fayez Abu Alia
|
||||
*
|
||||
*/
|
||||
public class SameLeftSide {
|
||||
// Typeplaceholders können nicht definiert werden, da die Konstruktor
|
||||
// private ist => Test geht nicht
|
||||
private static TPHExtractor tphExtractor;
|
||||
private static String methName;
|
||||
private static String methName2;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
tphExtractor = new TPHExtractor();
|
||||
// A < B
|
||||
TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS);
|
||||
// A < C
|
||||
TPHConstraint c2 = new ExtendsConstraint("A", "C", Relation.EXTENDS);
|
||||
// B < D
|
||||
TPHConstraint c3 = new ExtendsConstraint("B", "D", Relation.EXTENDS);
|
||||
// C < E
|
||||
TPHConstraint c4 = new ExtendsConstraint("C", "E", Relation.EXTENDS);
|
||||
// name
|
||||
methName = "m1";
|
||||
MethodAndTPH m1 = new MethodAndTPH("m1");
|
||||
|
||||
methName2 = "m2";
|
||||
MethodAndTPH m2 = new MethodAndTPH("m2");
|
||||
|
||||
m1.getTphs().add("A");
|
||||
m1.getTphs().add("B");
|
||||
m1.getTphs().add("D");
|
||||
|
||||
m2.getTphs().add("C");
|
||||
m2.getTphs().add("E");
|
||||
|
||||
tphExtractor.ListOfMethodsAndTph.add(m1);
|
||||
tphExtractor.ListOfMethodsAndTph.add(m2);
|
||||
|
||||
tphExtractor.allCons.add(c1);
|
||||
tphExtractor.allCons.add(c2);
|
||||
tphExtractor.allCons.add(c3);
|
||||
tphExtractor.allCons.add(c4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testM1() {
|
||||
HashMap<TPHConstraint, HashSet<String>> result = new HashMap<>();
|
||||
|
||||
TPHConstraint d = new ExtendsConstraint("D", Type.getInternalName(Object.class), Relation.EXTENDS);
|
||||
TPHConstraint a = new ExtendsConstraint("A", "D", Relation.EXTENDS);
|
||||
TPHConstraint b = new ExtendsConstraint("B", "D", Relation.EXTENDS);
|
||||
result.put(d, null);
|
||||
result.put(a, null);
|
||||
result.put(b, null);
|
||||
|
||||
HashMap<TPHConstraint, HashSet<String>> sim = Simplify.simplifyConstraints(methName, tphExtractor);
|
||||
boolean areEquals = SimpleCycle.areMapsEqual(result, sim);
|
||||
assertTrue(areEquals);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testM2() {
|
||||
HashMap<TPHConstraint, HashSet<String>> result = new HashMap<>();
|
||||
|
||||
TPHConstraint e = new ExtendsConstraint("E", Type.getInternalName(Object.class), Relation.EXTENDS);
|
||||
TPHConstraint c = new ExtendsConstraint("C", "E", Relation.EXTENDS);
|
||||
|
||||
result.put(e, null);
|
||||
result.put(c, null);
|
||||
|
||||
HashMap<TPHConstraint, HashSet<String>> sim = Simplify.simplifyConstraints(methName2, tphExtractor);
|
||||
boolean areEquals = SimpleCycle.areMapsEqual(result, sim);
|
||||
assertTrue(areEquals);
|
||||
}
|
||||
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package bytecode.simplifyalgo;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
||||
/**
|
||||
*
|
||||
* @author Fayez Abu Alia
|
||||
*
|
||||
*/
|
||||
public class SimpleCycle {
|
||||
private static TPHExtractor tphExtractor;
|
||||
private static String methName;
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
tphExtractor = new TPHExtractor();
|
||||
// A < B
|
||||
TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS);
|
||||
// B < A
|
||||
TPHConstraint c2 = new ExtendsConstraint("B", "A", Relation.EXTENDS);
|
||||
// name
|
||||
methName = "m";
|
||||
tphExtractor.allCons.add(c1);
|
||||
tphExtractor.allCons.add(c2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
HashMap<TPHConstraint, HashSet<String>> result = new HashMap<>();
|
||||
HashSet<String> equals = new HashSet<>();
|
||||
equals.add("A");
|
||||
equals.add("B");
|
||||
TPHConstraint k = new ExtendsConstraint("B", Type.getInternalName(Object.class), Relation.EXTENDS);
|
||||
result.put(k, equals);
|
||||
|
||||
HashMap<TPHConstraint, HashSet<String>> sim = Simplify.simplifyConstraints(methName, tphExtractor);
|
||||
boolean areEquals = areMapsEqual(result, sim);
|
||||
assertTrue(areEquals);
|
||||
}
|
||||
|
||||
public static boolean areMapsEqual(HashMap<TPHConstraint, HashSet<String>> m1, HashMap<TPHConstraint, HashSet<String>> m2) {
|
||||
|
||||
for(TPHConstraint c : m1.keySet()) {
|
||||
for(TPHConstraint c2 : m2.keySet()) {
|
||||
if(c.getLeft().equals(c2.getLeft()) && c.getRight().equals(c2.getRight()) && c.getRel()==c2.getRel()) {
|
||||
HashSet<String> eq1 = m1.get(c);
|
||||
HashSet<String> eq2 = m2.get(c2);
|
||||
|
||||
if((eq1 == null && eq2 != null) || (eq1 != null && eq2 == null))
|
||||
return false;
|
||||
if(eq1 != null) {
|
||||
if(eq1.size() != eq2.size())
|
||||
return false;
|
||||
|
||||
for(String tph:eq1) {
|
||||
if(!eq2.contains(tph))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.String;
|
||||
import java.lang.Byte;
|
||||
import java.lang.Short;
|
||||
import java.lang.Long;
|
||||
import java.lang.Float;
|
||||
import java.lang.Double;
|
||||
import java.lang.Character;
|
||||
|
||||
class AssignToLit {
|
||||
void m(){
|
||||
// String s = "Test";
|
||||
// Boolean b = false;
|
||||
// Byte byte1 = 5;
|
||||
// Byte byte2 = 55;
|
||||
// Short short1 = 5;
|
||||
// Short short2 = 55;
|
||||
// Integer int1 = 5;
|
||||
// Integer int2 = 8888888;
|
||||
// Long long1 = 1;
|
||||
// Long long2 = 5;
|
||||
// Long long3 = 89989898;
|
||||
// Float float1 = 1;
|
||||
// Float float2 = 55;
|
||||
// Double d1 = 1;
|
||||
// Double d2 = 55;
|
||||
Character c = 'A';
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Double;
|
||||
|
||||
public class BinaryInMeth {
|
||||
|
||||
m(a){
|
||||
return ++a;
|
||||
}
|
||||
|
||||
m2(a,b){
|
||||
return m(a+b);
|
||||
}
|
||||
|
||||
m3(a) {
|
||||
return m(++a);
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
public class DuMethod{
|
||||
|
||||
method(a){
|
||||
return a+a;
|
||||
}
|
||||
|
||||
method(a){
|
||||
return a;
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
public class EmptyMethod{
|
||||
|
||||
public void m1(){
|
||||
System.out.println("test");
|
||||
}
|
||||
|
||||
public void m2(){}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
import java.lang.String;
|
||||
|
||||
public class Example {
|
||||
|
||||
public m() {
|
||||
String x = "X";
|
||||
return x;
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
public class Exceptions {
|
||||
// m(Integer i) throws
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
//import java.lang.Double;
|
||||
|
||||
public class Fac {
|
||||
|
||||
getFac(n){
|
||||
var res = 1;
|
||||
var i = 1;
|
||||
while(i<=n) {
|
||||
res = res * i;
|
||||
i++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
public class Faculty {
|
||||
public fact;
|
||||
Faculty() {
|
||||
fact = (x) -> {
|
||||
if (x == 1) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return x * (fact.apply(x-1));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public getFact(x) {
|
||||
return fact.apply(x);
|
||||
}
|
||||
// m (x) {
|
||||
//
|
||||
//// var fact = (x) -> {
|
||||
//// if (x == 1) {
|
||||
//// return x;
|
||||
//// }
|
||||
//// else {
|
||||
//// return x * (fact.apply(x-1));
|
||||
//// }
|
||||
//// };
|
||||
//// return fact;
|
||||
//// var x = 13;
|
||||
//// if(x>22) {
|
||||
//// return 0;
|
||||
//// }else if(x <1){
|
||||
//// return x;
|
||||
//// }else {
|
||||
//// return 1;
|
||||
//// }
|
||||
//
|
||||
// if (x < 0) {
|
||||
// return 0;
|
||||
// }else if(x<2) {
|
||||
// return x;
|
||||
// } else {
|
||||
// return x * m(x-1);
|
||||
// }
|
||||
// }
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
class Faculty2 {
|
||||
|
||||
m () {
|
||||
|
||||
var fact = (Integer x) -> {
|
||||
return x;
|
||||
};
|
||||
return fact;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
public class Field {
|
||||
public Integer x = 5;
|
||||
|
||||
m(){
|
||||
return x;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
|
||||
class For{
|
||||
Integer m(Integer x){
|
||||
var c = x + 2;
|
||||
// Boolean b = true;
|
||||
// c = 5;
|
||||
// c++;
|
||||
// ++c;
|
||||
// c--;
|
||||
// --c;
|
||||
// while(x<2){
|
||||
// x = x +1;
|
||||
// b = false;
|
||||
// }
|
||||
return c;
|
||||
// for(int i = 0;i<10;i++) {
|
||||
// x = x + 5;
|
||||
// }
|
||||
}
|
||||
|
||||
// m2(Integer x){
|
||||
// if(x<2) {
|
||||
// return 1;
|
||||
// }else {
|
||||
// return 2;
|
||||
// }
|
||||
// }
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
//import java.lang.Byte;
|
||||
//import java.lang.Boolean;
|
||||
|
||||
public class FunOL {
|
||||
|
||||
add(f, y) {
|
||||
return f.apply() + y;
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.util.Vector;
|
||||
|
||||
public class Gen{
|
||||
Vector<Integer> m(Vector<Integer> v){
|
||||
return v;
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
|
||||
class Generics<B> {
|
||||
Generics(B b){
|
||||
}
|
||||
B mt1(B b){
|
||||
return mt1(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Problem:
|
||||
auto test = new List<String>();
|
||||
auto test2 = new List<Integer>();
|
||||
... //code, welcher möglicherweise test und test2 vertauscht
|
||||
test.add("hallo");
|
||||
*/
|
@ -1,6 +0,0 @@
|
||||
class Generics2<B extends String>{
|
||||
<B extends Integer> B m1(B b){
|
||||
return b;
|
||||
}
|
||||
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Long;
|
||||
import java.lang.Float;
|
||||
import java.lang.Double;
|
||||
|
||||
public class GreaterEqual {
|
||||
|
||||
gE(Integer a, Integer b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gE(Long a, Long b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gE(Float a, Float b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gE(Double a, Double b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gE(Long a, Integer b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gE(Float a, Integer b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gE(Double a, Integer b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gE(Float a, Long b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gE(Double a, Long b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gE(Double a, Float b){
|
||||
var c = a>=b;
|
||||
return c;
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Long;
|
||||
import java.lang.Float;
|
||||
import java.lang.Double;
|
||||
|
||||
public class GreaterThan {
|
||||
gT(Integer a, Integer b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gT(Long a, Long b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gT(Float a, Float b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gT(Double a, Double b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gT(Long a, Integer b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gT(Float a, Integer b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gT(Double a, Integer b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gT(Float a, Long b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gT(Double a, Long b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
|
||||
gT(Double a, Float b){
|
||||
var c = a>b;
|
||||
return c;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.String;
|
||||
|
||||
public class IfTest{
|
||||
Integer m1(Boolean b) {
|
||||
Integer i;
|
||||
String b;
|
||||
if(b) {
|
||||
return i;
|
||||
}else{
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class Import {
|
||||
void methode(){
|
||||
Vector v = new Vector<>();
|
||||
v.add("X");
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
public interface Interface1{
|
||||
public void test();
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
public class LamRunnable{
|
||||
|
||||
public LamRunnable(){
|
||||
|
||||
Runnable lam = () -> {System.out.println("lambda");};
|
||||
lam.run();
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
public class Lambda {
|
||||
|
||||
m () {
|
||||
var lam1 = (x) -> {
|
||||
return x;
|
||||
};
|
||||
return lam1;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
import java.lang.String;
|
||||
|
||||
public class Lambda2
|
||||
{
|
||||
public static void main(List<String> args){
|
||||
var listOfStrings = new List<String>();
|
||||
var listOfObjects;
|
||||
listOfObjects = map(listOfStrings, (a) -> a);
|
||||
}
|
||||
|
||||
public map(a , b){
|
||||
b.apply(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
public static <I,O> List<O> map(List<I> input, Function<I,O> func) {
|
||||
List<O> output;
|
||||
output = new List<O>();
|
||||
output.add(func.apply(input.get()));
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
class List<A>{
|
||||
/* A get();
|
||||
void add(A);
|
||||
*/
|
||||
}
|
||||
/*
|
||||
class Function<A,B>{
|
||||
B apply(A a);
|
||||
}
|
||||
*/
|
@ -1,23 +0,0 @@
|
||||
|
||||
public class Lambda2
|
||||
{
|
||||
/*
|
||||
public static <A> List<A> map(List<? extends A> input,
|
||||
Function<? super A, ? extends A> func){
|
||||
input.add(func.apply(input.get()));
|
||||
}
|
||||
*/
|
||||
public map(input,func){
|
||||
input.add(func.apply(input.get()));
|
||||
return map(new List<String>(), func);
|
||||
}
|
||||
}
|
||||
|
||||
class List<A>{
|
||||
A get();
|
||||
void add(A);
|
||||
}
|
||||
|
||||
class Function<A,B>{
|
||||
B apply(A a);
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
class Lambda{
|
||||
|
||||
methode(){
|
||||
return ((f) -> f);
|
||||
}
|
||||
}
|
||||
/*
|
||||
interface Fun0<A>{
|
||||
A apply();
|
||||
}
|
||||
|
||||
interface Fun1<A,B>{
|
||||
A apply(B b);
|
||||
}
|
||||
*/
|
||||
interface Fun2<A,B,C>{
|
||||
A apply(B b, C c);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
public class LambdaCapture {
|
||||
Integer i = 8;
|
||||
f;
|
||||
public LambdaCapture(){
|
||||
Integer w = 7;
|
||||
f = j ->{
|
||||
return w+i;};
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
public class Lambda {
|
||||
|
||||
m () {
|
||||
var lam1 = (x) -> { };
|
||||
return lam1;
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Long;
|
||||
import java.lang.Float;
|
||||
import java.lang.Double;
|
||||
|
||||
public class LessEqual {
|
||||
lessEqual(Integer a, Integer b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessEqual(Long a, Long b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessEqual(Float a, Float b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessEqual(Double a, Double b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessEqual(Long a, Integer b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessEqual(Float a, Integer b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessEqual(Double a, Integer b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessEqual(Float a, Long b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessEqual(Double a, Long b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessEqual(Double a, Float b){
|
||||
var c = a<=b;
|
||||
return c;
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Long;
|
||||
import java.lang.Float;
|
||||
import java.lang.Double;
|
||||
|
||||
public class LessThan {
|
||||
|
||||
lessThan(Integer a, Integer b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessThan(Long a, Long b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessThan(Float a, Float b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessThan(Double a, Double b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessThan(Long a, Integer b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessThan(Float a, Integer b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessThan(Double a, Integer b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessThan(Float a, Long b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessThan(Double a, Long b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
|
||||
lessThan(Double a, Float b){
|
||||
var c = a<b;
|
||||
return c;
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
//import java.lang.Float;
|
||||
//import java.lang.Byte;
|
||||
import java.lang.Boolean;
|
||||
|
||||
public class Matrix extends Vector<Vector<Integer>> {
|
||||
|
||||
Matrix () {
|
||||
}
|
||||
|
||||
Matrix(vv) {
|
||||
Integer i;
|
||||
i = 0;
|
||||
while(i < vv.size()) {
|
||||
// Boolean a = this.add(vv.elementAt(i));
|
||||
this.add(vv.elementAt(i));
|
||||
i=i+1;
|
||||
}
|
||||
}
|
||||
|
||||
mul(m) {
|
||||
var ret = new Matrix();
|
||||
var i = 0;
|
||||
while(i < size()) {
|
||||
var v1 = this.elementAt(i);
|
||||
var v2 = new Vector<Integer>();
|
||||
var j = 0;
|
||||
while(j < v1.size()) {
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
while(k < v1.size()) {
|
||||
erg = erg + v1.elementAt(k)
|
||||
* m.elementAt(k).elementAt(j);
|
||||
k++; }
|
||||
// v2.addElement(new Integer(erg));
|
||||
v2.addElement(erg);
|
||||
j++; }
|
||||
ret.addElement(v2);
|
||||
i++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
//import java.lang.Byte;
|
||||
import java.lang.Boolean;
|
||||
|
||||
public class MatrixOP extends Vector<Vector<Integer>> {
|
||||
|
||||
MatrixOP () {
|
||||
}
|
||||
|
||||
MatrixOP(vv) {
|
||||
Integer i;
|
||||
i = 0;
|
||||
while(i < vv.size()) {
|
||||
// Boolean a = this.add(vv.elementAt(i));
|
||||
this.add(vv.elementAt(i));
|
||||
i=i+1;
|
||||
}
|
||||
}
|
||||
|
||||
mul = (m1, m2) -> {
|
||||
var ret = new MatrixOP();
|
||||
var i = 0;
|
||||
while(i < size()) {
|
||||
var v1 = m1.elementAt(i);
|
||||
var v2 = new Vector<Integer>();
|
||||
var j = 0;
|
||||
while(j < v1.size()) {
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
while(k < v1.size()) {
|
||||
erg = erg + v1.elementAt(k)
|
||||
* m2.elementAt(k).elementAt(j);
|
||||
k++; }
|
||||
// v2.addElement(new Integer(erg));
|
||||
v2.addElement(erg);
|
||||
j++; }
|
||||
ret.addElement(v2);
|
||||
i++;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
import java.util.List;
|
||||
import java.lang.Integer;
|
||||
import java.util.Collection;
|
||||
|
||||
class Merge {
|
||||
|
||||
merge(a, b) {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sort(in){
|
||||
var firstHalf = in.subList(1,2);
|
||||
var secondHalf = in.subList(1,2);
|
||||
return merge(sort(firstHalf), sort(secondHalf));
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
class Methods {
|
||||
|
||||
m(a,b){
|
||||
var c=a+b;
|
||||
return c;
|
||||
}
|
||||
|
||||
method2(x){
|
||||
Integer i = this.m(x,2);
|
||||
return i;
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
import java.lang.String;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Double;
|
||||
|
||||
|
||||
|
||||
public class OL {
|
||||
|
||||
m(x) { return x + x; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class OLMain {
|
||||
|
||||
main(x) {
|
||||
var ol;
|
||||
ol = new OL();
|
||||
return ol.m(x);
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.lang.Long;
|
||||
import java.lang.Float;
|
||||
import java.lang.Double;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Short;
|
||||
import java.lang.Byte;
|
||||
|
||||
public class Op {
|
||||
|
||||
m(a, b) {
|
||||
//var c = a+b;
|
||||
return a+b;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
|
||||
public class Op2 {
|
||||
m(){
|
||||
var x = "";
|
||||
var a = 5+x;
|
||||
|
||||
return a;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class OverlaodGen {
|
||||
void method(Vector<Integer> v) {
|
||||
// Integer i = v.get(0);
|
||||
}
|
||||
|
||||
void method(Vector<String> v) {
|
||||
// String s = v.get(0);
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
import java.lang.String;
|
||||
|
||||
public class Overloading{
|
||||
|
||||
test(x){
|
||||
return x.methode();
|
||||
}
|
||||
|
||||
methode(){
|
||||
return "Overloading";
|
||||
}
|
||||
}
|
||||
|
||||
public class Overloading2{
|
||||
methode(){
|
||||
return "Overloading2";
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user