diff --git a/src/main/java/de/dhbwstuttgart/.DS_Store b/src/main/java/de/dhbwstuttgart/.DS_Store deleted file mode 100644 index aa8a1074..00000000 Binary files a/src/main/java/de/dhbwstuttgart/.DS_Store and /dev/null differ diff --git a/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java b/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java index b1ea614f..ff2c49a3 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java @@ -140,8 +140,7 @@ public class BytecodeGenMethod implements StatementVisitor { } public BytecodeGenMethod(LambdaExpression lambdaExpression, ArrayList usedVars, ResultSet resultSet, MethodVisitor mv, - int indexOfFirstParamLam, boolean isInterface, HashMap classFiles, String path, int lamCounter, SourceFile sf,HashMap genericsAndBoundsMethod, - HashMap genericsAndBounds) { + int indexOfFirstParamLam, boolean isInterface, HashMap classFiles, String path, int lamCounter, SourceFile sf) { this.resultSet = resultSet; this.mv = mv; @@ -150,9 +149,6 @@ public class BytecodeGenMethod implements StatementVisitor { this.path = path; this.lamCounter = lamCounter; this.sf = sf; - this.genericsAndBoundsMethod = genericsAndBoundsMethod; - this.genericsAndBounds = genericsAndBounds; - Iterator itr = lambdaExpression.params.iterator(); int i = indexOfFirstParamLam; @@ -648,8 +644,7 @@ public class BytecodeGenMethod implements StatementVisitor { ArrayList usedVars = kindOfLambda.getUsedVars(); new BytecodeGenMethod(lambdaExpression, usedVars,this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface, - classFiles,this.path, lamCounter, sf, genericsAndBoundsMethod, - genericsAndBounds); + classFiles,this.path, lamCounter, sf); mvLambdaBody.visitMaxs(0, 0); mvLambdaBody.visitEnd(); @@ -749,13 +744,6 @@ public class BytecodeGenMethod implements StatementVisitor { statement = new IfStatement(ifStmt.expr, ifStmt.then_block, ifStmt.else_block); isBinaryExp = statement.isExprBinary(); ifStmt.expr.accept(this); - if(!(ifStmt.expr instanceof BinaryExpr)) { - doUnboxing(getResolvedType(ifStmt.expr.getType())); - Label branchLabel = new Label(); - Label endLabel = new Label(); - mv.visitJumpInsn(Opcodes.IFEQ, branchLabel); - statement.genBCForRelOp(mv, branchLabel, endLabel, this); - } statement = null; } @@ -770,90 +758,86 @@ public class BytecodeGenMethod implements StatementVisitor { System.out.println("In MethodCall = " + methodCall.name); String receiverName = getResolvedType(methodCall.receiver.getType()); System.out.println("Methods of " + receiverName + " "); + ClassLoader cLoader = ClassLoader.getSystemClassLoader(); + // This will be used if the class is not standard class (not in API) + ClassLoader cLoader2; java.lang.reflect.Method methodRefl = null; String clazz = receiverName.replace("/", "."); -// if(!receiverName.equals(className)) { - ClassLoader cLoader = ClassLoader.getSystemClassLoader(); - // This will be used if the class is not standard class (not in API) - ClassLoader cLoader2; + String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()); + String[] typesOfParams = getTypes(methodCall.arglist.getArguments()); + try { + if(receiverName.contains("<")) { + clazz = clazz.substring(0, receiverName.indexOf("<")); + } - String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()); - String[] typesOfParams = getTypes(methodCall.arglist.getArguments()); - try { - if(receiverName.contains("<")) { - clazz = clazz.substring(0, receiverName.indexOf("<")); - } - - java.lang.reflect.Method[] methods = cLoader.loadClass(clazz).getMethods(); - System.out.println("Methods of " + receiverName + " "); - methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methods); - - } catch (Exception e) { -// try { -// cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)}); -// java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods(); -// System.out.println("Methods of " + receiverName + " "); -// for(int i = 0; i Refl != null"); receiverRefl = methodRefl.getAnnotatedReceiverType().getType().toString(); for(Parameter p:methodRefl.getParameters()) { System.out.println(p.getName() + " und is Primitive = " + p.getType().isPrimitive()); @@ -882,7 +865,7 @@ public class BytecodeGenMethod implements StatementVisitor { } } - System.out.println("Methodcall ("+ methodCall.name +") Desc : " + mDesc); + System.out.println("Methodcall Desc : " + mDesc); // methodCall.arglist.accept(this); @@ -1214,7 +1197,6 @@ public class BytecodeGenMethod implements StatementVisitor { break; case "java/lang/Boolean": - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false); break; case "java/lang/Byte": mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B", false); diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index b84c9441..6197aa19 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -34,15 +34,13 @@ 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.UnifyResultListener; import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl; import de.dhbwstuttgart.typeinference.unify.UnifyResultModel; import java.io.File; import java.io.FileOutputStream; -import java.io.FileWriter; +//import java.io.FileWriter; import java.io.IOException; -import java.io.OutputStreamWriter; import java.io.Writer; import java.util.*; import java.util.function.Function; @@ -50,7 +48,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.antlr.v4.parse.ANTLRParser.throwsSpec_return; -import org.apache.commons.io.output.NullOutputStream; public class JavaTXCompiler { @@ -278,7 +275,7 @@ public class JavaTXCompiler { } */ - public UnifyResultModel typeInferenceAsync(UnifyResultListener resultListener) throws ClassNotFoundException { + public UnifyResultModel typeInferenceAsync() throws ClassNotFoundException { List allClasses = new ArrayList<>();//environment.getAllAvailableClasses(); //Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC for(SourceFile sf : this.sourceFiles.values()) { @@ -288,14 +285,17 @@ public class JavaTXCompiler { final ConstraintSet cons = getConstraints(); Set> results = new HashSet<>(); - UnifyResultModel urm = new UnifyResultModel(); - urm.addUnifyResultListener(resultListener); + UnifyResultModel urm = null; try { - Writer logFile = new OutputStreamWriter(new NullOutputStream()); - //new FileWriter(new File("log_"+sourceFiles.keySet().iterator().next().getName())); + Writer logFile = new Writer() {//new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName())); + public void close() {} + public void flush() {} + public void write(char[] cbuf, int off, int len) { } + }; IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile); System.out.println(finiteClosure); + urm = new UnifyResultModel(cons, finiteClosure); ConstraintSet unifyCons = UnifyTypeFactory.convert(cons); Function distributeInnerVars = @@ -407,7 +407,7 @@ public class JavaTXCompiler { } return ret; }).collect(Collectors.toCollection(ArrayList::new)); - unify.unifyAsync(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, cons, urm); + unify.unifyAsync(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm); } catch (IOException e) { System.err.println("kein LogFile"); @@ -427,8 +427,11 @@ public class JavaTXCompiler { final ConstraintSet cons = getConstraints(); Set> results = new HashSet<>(); try { - Writer logFile = new OutputStreamWriter(new NullOutputStream()); - //new FileWriter(new File("log_"+sourceFiles.keySet().iterator().next().getName())); + Writer logFile = new Writer() {//new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName())); + public void close() {} + public void flush() {} + public void write(char[] cbuf, int off, int len) { } + }; IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile); System.out.println(finiteClosure); @@ -545,10 +548,10 @@ public class JavaTXCompiler { }).collect(Collectors.toCollection(ArrayList::new)); if (resultmodel) { /* UnifyResultModel Anfang */ - UnifyResultModel urm = new UnifyResultModel(); + UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure); UnifyResultListenerImpl li = new UnifyResultListenerImpl(); urm.addUnifyResultListener(li); - unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, cons, urm); + unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm); System.out.println("RESULT Final: " + li.getResults()); logFile.write("RES_FINAL: " + li.getResults().toString()+"\n"); logFile.flush(); @@ -556,8 +559,8 @@ public class JavaTXCompiler { } /* UnifyResultModel End */ else { - Set> result = unify.unify(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, cons); - //Set> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, cons); + Set> result = unify.unify(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure)); + //Set> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure)); System.out.println("RESULT: " + result); logFile.write("RES: " + result.toString()+"\n"); logFile.flush(); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java b/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java index 581f9fbd..1dda8dc5 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java @@ -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 { ret.oderConstraints = newOder; return ret; } + + public void forEach (Consumer c) { + undConstraints.stream().forEach(c); + for(Set> oderConstraint : oderConstraints){ + oderConstraint.parallelStream().forEach((Constraint as) -> + as.stream().forEach(c)); + } + } + + public Set getAll () { + Set ret = new HashSet<>(); + ret.addAll(undConstraints); + for(Set> oderConstraint : oderConstraints){ + oderConstraint.parallelStream().forEach((Constraint as) -> ret.addAll(as)); + } + return ret; + } + + public List>> getOderConstraints() { + return oderConstraints; + } + + public Set getUndConstraints() { + return undConstraints; + } } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index 2f705c67..4fd14fbc 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -1,3 +1,4 @@ +//PL 2018-12-19: Merge chekcen package de.dhbwstuttgart.typeinference.typeAlgo; import de.dhbwstuttgart.exceptions.NotImplementedException; @@ -228,6 +229,13 @@ public class TYPEStmt implements StatementVisitor{ binary.operation.equals(BinaryExpr.Operator.ADD)|| binary.operation.equals(BinaryExpr.Operator.SUB)){ Set> 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 diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java index 78f7360f..3e995607 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java @@ -22,6 +22,8 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType; public class Match implements IMatch { @Override + //A =. A ==> True + //A =. A ==> False public Optional match(ArrayList termsList) { // Start with the identity unifier. Substitutions will be added later. diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java index e333bdfe..da8998d2 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -4,10 +4,12 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; +import java.util.List; import java.util.Optional; import java.util.Queue; import java.util.Set; import java.util.Stack; +import java.util.function.Function; import java.util.stream.Collectors; import de.dhbwstuttgart.exceptions.DebugException; @@ -620,8 +622,12 @@ public class RuleSet implements IRuleSet{ return succ ? permutation : new int[0]; } - @Override public Optional> subst(Set pairs) { + return subst(pairs, new ArrayList<>()); + } + + @Override + public Optional> subst(Set pairs, List>> oderConstraints) { HashMap typeMap = new HashMap<>(); Stack occuringTypes = new Stack<>(); @@ -661,13 +667,35 @@ public class RuleSet implements IRuleSet{ if(lhsType != null //&& !((rhsType = pair.getRhsType()) instanceof PlaceholderType) //PL geloescht am 2017-09-29 Begründung: auch Typvariablen muessen ersetzt werden. && typeMap.get(lhsType) > 1 // The type occurs in more pairs in the set than just the recent pair. - && !rhsType.getTypeParams().occurs(lhsType)) { + && !rhsType.getTypeParams().occurs(lhsType) + && !((rhsType instanceof WildcardType) && ((WildcardType)rhsType).getWildcardedType().equals(lhsType))) //PL eigefuegt 2018-02-18 + { Unifier uni = new Unifier(lhsType, rhsType); result = result.stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(ArrayList::new)); result1 = result1.stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(LinkedList::new)); + + Function,? extends HashSet> applyUni = b -> b.stream().map( + x -> uni.apply(pair,x)).collect(Collectors.toCollection(HashSet::new)); + List>> oderConstraintsRet = new ArrayList<>(); + for(Set> oc : oderConstraints) { + //Set> ocRet = new HashSet<>(); + //for(Set cs : oc) { + Set> csRet = oc.stream().map(applyUni).collect(Collectors.toCollection(HashSet::new)); + oderConstraintsRet.add(csRet); + //} + } + oderConstraints.replaceAll(oc -> oc.stream().map(applyUni).collect(Collectors.toCollection(HashSet::new))); + /* + oderConstraints = oderConstraints.stream().map( + a -> a.stream().map(applyUni + //b -> b.stream().map( + // x -> uni.apply(pair,x)).collect(Collectors.toCollection(HashSet::new) ) + ).collect(Collectors.toCollection(HashSet::new)) + ).collect(Collectors.toList(ArrayList::new)); + } + */ applied = true; } - result.add(pair); } @@ -946,6 +974,8 @@ public class RuleSet implements IRuleSet{ UnifyType extendedType = ((ExtendsType)lhsType).getExtendedType(); + if (extendedType.equals(rhsType)) return Optional.empty(); //PL 2019-02-18 eingefügt ? extends a <.? a + boolean isGen = extendedType instanceof PlaceholderType && !((PlaceholderType) extendedType).isGenerated(); Set result = new HashSet<>(); @@ -972,6 +1002,8 @@ public class RuleSet implements IRuleSet{ UnifyType superedType = ((SuperType)lhsType).getSuperedType(); + if (superedType.equals(rhsType)) return Optional.empty(); //PL 2019-02-18 eingefügt ? super a <.? a + boolean isGen = superedType instanceof PlaceholderType && !((PlaceholderType) superedType).isGenerated(); Set result = new HashSet<>(); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java index 974581a9..2cea2184 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java @@ -14,23 +14,56 @@ import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure; import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; public class TypeUnify { - public Set> unify(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, ConstraintSet cons) { - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, new UnifyResultModel(), cons); + + /** + * unify parallel ohne result modell + * @param undConstrains + * @param oderConstraints + * @param fc + * @param logFile + * @param log + * @param cons + * @return + */ + public Set> unify(Set undConstrains, List>> 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); Set> res = unifyTask.join(); return res; } - public UnifyResultModel unifyAsync(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, ConstraintSet cons, UnifyResultModel ret) { - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, cons); + /** + * unify asynchron mit Rückgabe UnifyResultModel ohne dass alle results gesammelt sind + * @param undConstrains + * @param oderConstraints + * @param fc + * @param logFile + * @param log + * @param cons + * @param ret + * @return + */ + public UnifyResultModel unifyAsync(Set undConstrains, List>> 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); return ret; } - public UnifyResultModel unifyParallel(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, ConstraintSet cons, UnifyResultModel ret) { - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, cons); + /** + * unify parallel mit Rückgabe UnifyResultModel nachdem alle results gesammelt sind + * @param undConstrains + * @param oderConstraints + * @param fc + * @param logFile + * @param log + * @param cons + * @param ret + * @return + */ + public UnifyResultModel unifyParallel(Set undConstrains, List>> 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); Set> res = unifyTask.join(); @@ -45,8 +78,18 @@ public class TypeUnify { } */ - public Set> unifyOderConstraints(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, FileWriter logFile, Boolean log, ConstraintSet cons) { - TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, new UnifyResultModel(), cons); + /** + * unify sequentiell mit oderconstraints + * @param undConstrains + * @param oderConstraints + * @param fc + * @param logFile + * @param log + * @param cons + * @return + */ + public Set> unifyOderConstraints(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) { + TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret); Set> res = unifyTask.compute(); return res; } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java index ac6f04bb..31247aef 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java @@ -1,6 +1,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; @@ -16,9 +17,14 @@ public class TypeUnify2Task extends TypeUnifyTask { Set> setToFlatten; - public TypeUnify2Task(Set> setToFlatten, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, ConstraintSet cons) { - super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, cons); + public TypeUnify2Task(Set> setToFlatten, Set eq, List>> oderConstraints, Set 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; + } + + Set getNextSetElement() { + return nextSetElement; } @Override @@ -33,6 +39,17 @@ public class TypeUnify2Task extends TypeUnifyTask { else */ noOfThread--; - return res; + return res; + } + + public void closeLogFile() { + + try { + logFile.close(); + } + catch (IOException ioE) { + System.err.println("no log-File" + thNo); + } + } } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 43142773..f55c742a 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -42,7 +42,7 @@ import de.dhbwstuttgart.typeinference.unify.model.OrderingUnifyPair; import de.dhbwstuttgart.typeinference.unify.model.Pair; import java.io.File; -import java.io.FileWriter; +//import java.io.FileWriter; import java.io.IOException; import java.io.Writer; @@ -60,11 +60,15 @@ public class TypeUnifyTask extends RecursiveTask>> { private boolean printtag = false; Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"/test/logFiles/log" geschrieben werden soll? + /** + * Element, das aus dem nextSet den Gleichunen dieses Threads hinzugefuegt wurde + */ + Set nextSetElement; + /** * Fuer die Threads */ UnifyResultModel urm; - ConstraintSet cons; protected static int noOfThread = 0; private static int totalnoOfThread = 0; int thNo; @@ -129,7 +133,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } */ - public TypeUnifyTask(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, ConstraintSet cons2) { + public TypeUnifyTask(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) { synchronized (this) { this.eq = eq; //this.oderConstraints = oderConstraints.stream().map(x -> x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new)); @@ -143,21 +147,31 @@ public class TypeUnifyTask extends RecursiveTask>> { */ //x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new)); + this.nextSetElement = nextSetElement; this.fc = fc; this.oup = new OrderingUnifyPair(fc); this.parallel = parallel; this.logFile = logFile; this.log = log; + + noOfThread++; + totalnoOfThread++; + //writeLog("thNo1 " + thNo); + thNo = totalnoOfThread; + writeLog("thNo2 " + thNo); + try { + this.logFile = new Writer() {//FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"Thread_"+thNo)); + public void close() {} + public void flush() {} + public void write(char[] cbuf, int off, int len) { } + }; + } + catch (Exception e) { + System.err.println("log-File nicht vorhanden"); + } rules = new RuleSet(logFile); this.rekTiefeField = rekTiefe; this.urm = urm; - this.cons = cons2; - - noOfThread++; - totalnoOfThread++; - writeLog("thNo1 " + thNo); - thNo = totalnoOfThread; - writeLog("thNo2 " + thNo); } } @@ -209,6 +223,12 @@ public class TypeUnifyTask extends RecursiveTask>> { .collect(Collectors.toCollection(ArrayList::new)); Set> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField); noOfThread--; + try { + logFile.close(); + } + catch (IOException ioE) { + System.err.println("no log-File"); + } if (isUndefinedPairSetSet(res)) { return new HashSet<>(); } else return res; } @@ -543,6 +563,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } // Add the set of [a =. Theta | (a=. Theta) in Eq2'] + //TODO: Occurscheck anwenden als Fehler identifizieren Set bufferSet = eq2s.stream() .filter(x -> x.getPairOp() == PairOperator.EQUALSDOT && x.getLhsType() instanceof PlaceholderType) .collect(Collectors.toSet()); @@ -651,9 +672,13 @@ public class TypeUnifyTask extends RecursiveTask>> { * Step 5: Substitution */ //writeLog("vor Subst: " + eqPrime); - Optional> eqPrimePrime = rules.subst(eqPrime); + writeLog("vor Subst: " + oderConstraints); + String ocString = oderConstraints.toString(); + List>> newOderConstraints = new ArrayList<>(oderConstraints); + Optional> eqPrimePrime = rules.subst(eqPrime, newOderConstraints); Set> unifyres1 = null; Set> unifyres2 = null; + if (!ocString.equals(newOderConstraints.toString())) writeLog("nach Subst: " + newOderConstraints); //writeLog("nach Subst: " + eqPrimePrime); /* * Step 6 a) Restart (fork) for pairs where subst was applied @@ -687,36 +712,24 @@ public class TypeUnifyTask extends RecursiveTask>> { //PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent()) //PL 2018-05-18 beide Bedingungen muessen gelten, da eqPrime Veränderungen in allem ausser subst //eqPrimePrime Veraenderungen in subst repraesentieren. - try { + //try { if (isSolvedForm(eqPrime)) { - logFile.write("eqPrime:" + eqPrime.toString()+"\n"); - logFile.flush(); + writeLog("eqPrime:" + eqPrime.toString()+"\n"); } - } - catch (IOException e) { - System.err.println("log-File nicht vorhanden"); - } + //} + //catch (IOException e) { + // System.err.println("log-File nicht vorhanden"); + //} eqPrimePrimeSet.add(eqPrime); - Set> eqPrimePrimeSetRet = eqPrimePrimeSet.stream().map(x -> { - Optional> res = new RuleSet().subst(x.stream().map(y -> { - if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT); - return y; //alle Paare a <.? b erden durch a =. b ersetzt - }).collect(Collectors.toCollection(HashSet::new))); - if (res.isPresent()) {//wenn subst ein Erg liefert wurde was veraendert - return new TypeUnifyTask().applyTypeUnificationRules(res.get(), fc); - } - else return x; //wenn nichts veraendert wurde wird x zurueckgegeben - }).collect(Collectors.toCollection(HashSet::new)); - urm.notify(eqPrimePrimeSetRet.stream().map((unifyPairs -> - new ResultSet(UnifyTypeFactory.convert(unifyPairs, de.dhbwstuttgart.typeinference.constraints.Pair.generateTPHMap(cons))))).collect(Collectors.toList())); + urm.notify(eqPrimePrimeSet); } else if(eqPrimePrime.isPresent()) { - Set> unifyres = unifyres1 = unify(eqPrimePrime.get(), oderConstraints, fc, parallel, rekTiefe); + Set> unifyres = unifyres1 = unify(eqPrimePrime.get(), newOderConstraints, fc, parallel, rekTiefe); eqPrimePrimeSet.addAll(unifyres); } else { - Set> unifyres = unifyres2 = unify(eqPrime, oderConstraints, fc, parallel, rekTiefe); + Set> unifyres = unifyres2 = unify(eqPrime, newOderConstraints, fc, parallel, rekTiefe); eqPrimePrimeSet.addAll(unifyres); @@ -919,15 +932,16 @@ public class TypeUnifyTask extends RecursiveTask>> { //writeLog("Vor unify2 Aufruf: " + elems.toString()); Set> res = new HashSet<>(); Set>> add_res = new HashSet<>(); + Set> aParDef = new HashSet<>(); if(parallel && (variance == 1) && noOfThread <= MaxNoOfThreads) { - Set forks = new HashSet<>(); + Set forks = new HashSet<>(); Set newEqOrig = new HashSet<>(eq); Set> newElemsOrig = new HashSet<>(elems); List>> newOderConstraintsOrig = new ArrayList<>(oderConstraints); newElemsOrig.add(a); /* FORK ANFANG */ - TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, logFile, log, rekTiefe, urm, cons); + TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm); //forks.add(forkOrig); forkOrig.fork(); /* FORK ENDE */ @@ -945,7 +959,7 @@ public class TypeUnifyTask extends RecursiveTask>> { Set> newElems = new HashSet<>(elems); List>> newOderConstraints = new ArrayList<>(oderConstraints); newElems.add(nSaL); - TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, fc, parallel, logFile, log, rekTiefe, urm, cons); + TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm); forks.add(fork); fork.fork(); } @@ -953,7 +967,11 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { + noOfThread--; + writeLog("wait "+ forkOrig.thNo); res = forkOrig.join(); + forkOrig.writeLog("final Orig 1"); + forkOrig.closeLogFile(); //Set> fork_res = forkOrig.join(); writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString()); //noOfThread--; an das Ende von compute verschoben @@ -961,24 +979,33 @@ public class TypeUnifyTask extends RecursiveTask>> { }; /* FORK ENDE */ - for(TypeUnifyTask fork : forks) { + forks.forEach(x -> writeLog("wait: " + x.thNo)); + for(TypeUnify2Task fork : forks) { synchronized (this) { Set> fork_res = fork.join(); writeLog("Join " + new Integer(fork.thNo).toString()); - //noOfThread--; an das Ende von compute verschoben + //noOfThread--; an das Ende von compute verschoben + writeLog("fork_res: " + fork_res.toString()); + writeLog(new Boolean((isUndefinedPairSetSet(fork_res))).toString()); add_res.add(fork_res); + if (!isUndefinedPairSetSet(fork_res)) { + aParDef.add(fork.getNextSetElement()); + } + fork.writeLog("final 1"); + fork.closeLogFile(); }; - } + } + noOfThread++; } else { if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) { - Set forks = new HashSet<>(); + Set forks = new HashSet<>(); Set newEqOrig = new HashSet<>(eq); Set> newElemsOrig = new HashSet<>(elems); List>> newOderConstraintsOrig = new ArrayList<>(oderConstraints); newElemsOrig.add(a); /* FORK ANFANG */ - TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, logFile, log, rekTiefe, urm, cons); + TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm); //forks.add(forkOrig); forkOrig.fork(); /* FORK ENDE */ @@ -996,7 +1023,7 @@ public class TypeUnifyTask extends RecursiveTask>> { Set> newElems = new HashSet<>(elems); List>> newOderConstraints = new ArrayList<>(oderConstraints); newElems.add(nSaL); - TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, fc, parallel, logFile, log, rekTiefe, urm, cons); + TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm); forks.add(fork); fork.fork(); } @@ -1004,7 +1031,11 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { + noOfThread--; + writeLog("wait "+ forkOrig.thNo); res = forkOrig.join(); + forkOrig.writeLog("final Orig -1"); + forkOrig.closeLogFile(); //Set> fork_res = forkOrig.join(); writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString()); //noOfThread--; an das Ende von compute verschoben @@ -1012,25 +1043,34 @@ public class TypeUnifyTask extends RecursiveTask>> { }; /* FORK ENDE */ - for(TypeUnifyTask fork : forks) { + forks.forEach(x -> writeLog("wait: " + x.thNo)); + for(TypeUnify2Task fork : forks) { synchronized (this) { Set> fork_res = fork.join(); writeLog("Join " + new Integer(fork.thNo).toString()); //noOfThread--; an das Ende von compute verschoben + writeLog("fork_res: " + fork_res.toString()); + writeLog(new Boolean((isUndefinedPairSetSet(fork_res))).toString()); add_res.add(fork_res); + if (!isUndefinedPairSetSet(fork_res)) { + aParDef.add(fork.getNextSetElement()); + } + fork.writeLog("final -1"); + fork.closeLogFile(); }; } + noOfThread++; } else { if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) { writeLog("var2einstieg"); - Set forks = new HashSet<>(); + Set forks = new HashSet<>(); Set newEqOrig = new HashSet<>(eq); Set> newElemsOrig = new HashSet<>(elems); List>> newOderConstraintsOrig = new ArrayList<>(oderConstraints); newElemsOrig.add(a); /* FORK ANFANG */ - TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, logFile, log, rekTiefe, urm, cons); + TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm); //forks.add(forkOrig); forkOrig.fork(); /* FORK ENDE */ @@ -1046,7 +1086,7 @@ public class TypeUnifyTask extends RecursiveTask>> { Set> newElems = new HashSet<>(elems); List>> newOderConstraints = new ArrayList<>(oderConstraints); newElems.add(nSaL); - TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, fc, parallel, logFile, log, rekTiefe, urm, cons); + TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm); forks.add(fork); fork.fork(); } @@ -1054,23 +1094,30 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { + noOfThread--; + writeLog("wait "+ forkOrig.thNo); res = forkOrig.join(); + forkOrig.writeLog("final Orig 2"); + forkOrig.closeLogFile(); //Set> fork_res = forkOrig.join(); writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString()); //noOfThread--; an das Ende von compute verschoben //add_res.add(fork_res); //vermutlich falsch }; /* FORK ENDE */ - - for(TypeUnifyTask fork : forks) { + forks.forEach(x -> writeLog("wait: " + x.thNo)); + for(TypeUnify2Task fork : forks) { synchronized (this) { Set> fork_res = fork.join(); writeLog("Join " + new Integer(fork.thNo).toString()); //noOfThread--; an das Ende von compute verschoben add_res.add(fork_res); + fork.writeLog("final 2"); + fork.closeLogFile(); }; - }} - else { + } + noOfThread++; + } else { //parallel = false; //Wenn MaxNoOfThreads erreicht ist, sequentiell weiterarbeiten elems.add(a); //PL 2019-01-16 muss das wirklich hin steht schon in Zeile 859 ja braucht man siehe Zeile 859 res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe); @@ -1197,7 +1244,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } /* auskommentiert um alle Max und min Betrachtung auszuschalten ANFANG */ - if (!result.isEmpty() && !isUndefinedPairSetSet(res)) { + if (!result.isEmpty() && (!isUndefinedPairSetSet(res) || !aParDef.isEmpty())) { if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("B")).findFirst().isPresent() && nextSetasList.size()>1) System.out.print(""); Iterator> nextSetasListIt = new ArrayList>(nextSetasList).iterator(); @@ -1231,18 +1278,24 @@ public class TypeUnifyTask extends RecursiveTask>> { System.out.println(""); writeLog("a: " + rekTiefe + " variance: " + variance + a.toString()); - while (nextSetasListIt.hasNext()) { - Set a_next = nextSetasListIt.next(); - if (a.equals(a_next) || - (oup.compare(a, a_next) == 1)) { - writeLog("Removed: " + a_next.toString()); - nextSetasList.remove(a_next); + writeLog("aParDef: " + aParDef.toString()); + aParDef.add(a); + Iterator> aParDefIt = aParDef.iterator(); + while(aParDefIt.hasNext()) { + Set a_new = aParDefIt.next(); + while (nextSetasListIt.hasNext()) { + Set a_next = nextSetasListIt.next(); + if (a_new.equals(a_next) || + (oup.compare(a_new, a_next) == 1)) { + writeLog("Removed: " + a_next.toString()); + nextSetasList.remove(a_next); + } + else { + writeLog("Not Removed: " + a_next.toString()); + System.out.println(""); + } } - else { - writeLog("Not Removed: " + a_next.toString()); - System.out.println(""); - } - } + } } else { if (variance == -1) { /* vorgezogen vor das if @@ -1273,19 +1326,25 @@ public class TypeUnifyTask extends RecursiveTask>> { System.out.println(""); writeLog("a: " + rekTiefe + " variance: " + variance + a.toString()); - while (nextSetasListIt.hasNext()) { - Set a_next = nextSetasListIt.next(); - if (a.equals(a_next) || - (oup.compare(a, a_next) == -1)) { - writeLog("Removed: " + a_next.toString()); - nextSetasList.remove(a_next); //PL geaendert 2019-01-09 - } - else { - System.out.println(""); - writeLog("Not Removed: " + a_next.toString()); + writeLog("aParDef: " + aParDef.toString()); + aParDef.add(a); + Iterator> aParDefIt = aParDef.iterator(); + while(aParDefIt.hasNext()) { + Set a_new = aParDefIt.next(); + while (nextSetasListIt.hasNext()) { + Set a_next = nextSetasListIt.next(); + if (a_new.equals(a_next) || + (oup.compare(a_new, a_next) == -1)) { + writeLog("Removed: " + a_next.toString()); + nextSetasList.remove(a_next); //PL geaendert 2019-01-09 + } + else { + System.out.println(""); + writeLog("Not Removed: " + a_next.toString()); } } } + } else { if (variance == 0) { writeLog("a: " + rekTiefe + " variance: " + variance + a.toString()); break; } @@ -1319,7 +1378,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } /* auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */ - if (isUndefinedPairSetSet(res)) { + if (isUndefinedPairSetSet(res) && aParDef.isEmpty()) { int nofstred= 0; Set abhSubst = res.stream() .map(b -> diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultListener.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultListener.java new file mode 100644 index 00000000..f490ccde --- /dev/null +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultListener.java @@ -0,0 +1,7 @@ +package de.dhbwstuttgart.typeinference.unify; + +public interface UnifyResultListener { + + void onNewTypeResultFound(UnifyResultEvent evt); + +} diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java index fe72bfea..7a4f0ccf 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java @@ -1,13 +1,31 @@ package de.dhbwstuttgart.typeinference.unify; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; +import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory; +import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.result.ResultSet; +import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; +import de.dhbwstuttgart.typeinference.unify.model.PairOperator; +import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; public class UnifyResultModel { + ConstraintSet cons; + + IFiniteClosure fc; + + public UnifyResultModel(ConstraintSet cons, + IFiniteClosure fc) { + this.cons = cons; + this.fc = fc; + } + private List listeners = new ArrayList<>(); public void addUnifyResultListener(UnifyResultListener listenerToAdd) { @@ -18,7 +36,20 @@ public class UnifyResultModel { listeners.remove(listenerToRemove); } - public void notify(List newResult) { + public void notify(Set> eqPrimePrimeSet) { + Set> eqPrimePrimeSetRet = eqPrimePrimeSet.stream().map(x -> { + Optional> res = new RuleSet().subst(x.stream().map(y -> { + if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT); + return y; //alle Paare a <.? b erden durch a =. b ersetzt + }).collect(Collectors.toCollection(HashSet::new))); + if (res.isPresent()) {//wenn subst ein Erg liefert wurde was veraendert + return new TypeUnifyTask().applyTypeUnificationRules(res.get(), fc); + } + else return x; //wenn nichts veraendert wurde wird x zurueckgegeben + }).collect(Collectors.toCollection(HashSet::new)); + List newResult = eqPrimePrimeSetRet.stream().map(unifyPairs -> + new ResultSet(UnifyTypeFactory.convert(unifyPairs, de.dhbwstuttgart.typeinference.constraints.Pair.generateTPHMap(cons)))) + .collect(Collectors.toList()); UnifyResultEvent evt = new UnifyResultEvent(newResult); for (UnifyResultListener listener : listeners) { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java index 3e20f433..37d70d55 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java @@ -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. diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IRuleSet.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IRuleSet.java index a2b647c6..1ed46cb0 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IRuleSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IRuleSet.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.typeinference.unify.interfaces; +import java.util.List; import java.util.Optional; import java.util.Set; @@ -85,6 +86,13 @@ public interface IRuleSet { public Optional adaptExt(UnifyPair pair, IFiniteClosure fc); public Optional adaptSup(UnifyPair pair, IFiniteClosure fc); + /** + * Applies the subst-Rule to a set of pairs (usually Eq'). + * @param pairs The set of pairs where the subst rule should apply. + * @return An optional of the modified set, if there were any substitutions. An empty optional if there were no substitutions. + */ + public Optional> subst(Set pairs, List>> oderConstraints); + /** * Applies the subst-Rule to a set of pairs (usually Eq'). * @param pairs The set of pairs where the subst rule should apply. diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java index 29a0e198..6ce7b541 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java @@ -13,6 +13,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.BiFunction; import java.util.function.BinaryOperator; +import java.util.function.Predicate; import java.util.stream.Collectors; import com.google.common.collect.Ordering; @@ -657,11 +658,16 @@ implements IFiniteClosure { if (left.getName().equals("Matrix") || right.getName().equals("Matrix")) System.out.println(""); /* + pairop = PairOperator.SMALLERDOTWC; List al = new ArrayList<>(); PlaceholderType xx =new PlaceholderType("xx"); al.add(xx); left = new ExtendsType(new ReferenceType("Vector", new TypeParams(al))); - right = new ReferenceType("Vector", new TypeParams(new ArrayList<>(al))); + + List alr = new ArrayList<>(); + UnifyType exx = new ExtendsType(xx); + alr.add(exx); + right = new ExtendsType(new ReferenceType("Vector", new TypeParams(alr))); */ /* List al = new ArrayList<>(); @@ -712,8 +718,13 @@ implements IFiniteClosure { } catch (IOException e) { System.err.println("no LogFile");}} - //Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok. - long smallerLen = smallerRes.stream().filter(x -> !(x.getLhsType() instanceof PlaceholderType || x.getRhsType() instanceof PlaceholderType)).count(); + //Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok. + Predicate delFun = x -> !((x.getLhsType() instanceof PlaceholderType || + x.getRhsType() instanceof PlaceholderType) + && !((x.getLhsType() instanceof WildcardType) && //? extends/super a <.? a + ((WildcardType)x.getLhsType()).getWildcardedType().equals(x.getRhsType())) + ); + long smallerLen = smallerRes.stream().filter(delFun).count(); if (smallerLen == 0) return -1; else { up = new UnifyPair(right, left, pairop); @@ -729,7 +740,7 @@ implements IFiniteClosure { catch (IOException e) { System.err.println("no LogFile");}} //Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok. - long greaterLen = greaterRes.stream().filter(x -> !(x.getLhsType() instanceof PlaceholderType || x.getRhsType() instanceof PlaceholderType)).count(); + long greaterLen = greaterRes.stream().filter(delFun).count(); if (greaterLen == 0) return 1; else return 0; } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java index 1916712e..28da9a80 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; +import java.util.List; import java.util.Optional; import java.util.Set; import java.util.function.BinaryOperator; @@ -30,7 +31,8 @@ public class OrderingUnifyPair extends Ordering> { * 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 { @@ -54,6 +56,20 @@ public class OrderingUnifyPair extends Ordering> { 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); @@ -67,6 +83,19 @@ public class OrderingUnifyPair extends Ordering> { 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); @@ -87,6 +116,53 @@ public class OrderingUnifyPair extends Ordering> { * @see com.google.common.collect.Ordering#compare(java.lang.Object, java.lang.Object) */ public int compare (Set left, Set right) { + /* + //pairop = PairOperator.SMALLERDOTWC; + List al = new ArrayList<>(); + PlaceholderType xx = PlaceholderType.freshPlaceholder(); + al.add(xx); + UnifyType t1 = new ExtendsType(new ReferenceType("Vector", new TypeParams(al))); + + //PlaceholderType yy =new PlaceholderType("yy"); + List alr = new ArrayList<>(); + UnifyType exx = new ExtendsType(xx); + alr.add(exx); + UnifyType t2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(alr))); + + PlaceholderType a = PlaceholderType.freshPlaceholder(); + a.setInnerType(true); + UnifyPair p1 = new UnifyPair(a, t1, PairOperator.SMALLERDOTWC); + PlaceholderType b = PlaceholderType.freshPlaceholder(); + b.setInnerType(true); + UnifyPair p2 = new UnifyPair(b, t2, PairOperator.SMALLERDOTWC); + + List al3 = new ArrayList<>(); + al3.add(a); + + List al4 = new ArrayList<>(); + al4.add(b); + + UnifyPair p3 = new UnifyPair(new PlaceholderType("c"), new ReferenceType("Vector", new TypeParams(al3)), PairOperator.EQUALSDOT); + UnifyPair p4 = new UnifyPair(new PlaceholderType("c"), new ReferenceType("Vector", new TypeParams(al4)), PairOperator.EQUALSDOT); + + right = new HashSet<>(); + right.add(p1); + right.add(p3); + left = new HashSet<>(); + left.add(p2); + left.add(p4); + */ + + if ((left.size() == 1) && right.size() == 1) { + if (left.iterator().next().getLhsType().getName().equals("AFS")) { + System.out.println(""); + } + if (((right.iterator().next().getRhsType() instanceof SuperType) && (((SuperType)right.iterator().next().getRhsType()).getSuperedType().getName().equals("java.lang.Object"))) + ||((left.iterator().next().getRhsType() instanceof SuperType) && (((SuperType)left.iterator().next().getRhsType()).getSuperedType().getName().equals("java.lang.Object")))) + { + System.out.println(""); + } + } Set lefteq = left.stream() .filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT)) .collect(Collectors.toCollection(HashSet::new)); @@ -110,17 +186,25 @@ public class OrderingUnifyPair extends Ordering> { && 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; @@ -152,9 +236,9 @@ public class OrderingUnifyPair extends Ordering> { //Set varsleft = lefteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new)); //Set varsright = righteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new)); //filtern des Paares a = Theta, das durch a <. Thata' generiert wurde (nur im Fall 1 relevant) andere Substitutioen werden rausgefiltert - lefteq.removeIf(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) + lefteq.removeIf(x -> (x.getBasePair()!=null) && !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) ||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName())));//removeIf(x -> !varsright.contains(x.getLhsType())); - righteq.removeIf(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) + righteq.removeIf(x -> (x.getBasePair()!=null) && !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) ||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName())));//.removeIf(x -> !varsleft.contains(x.getLhsType())); UnifyPair lseq = lefteq.iterator().next(); UnifyPair rseq = righteq.iterator().next(); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java index 01209998..60cf342f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java @@ -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 smArg(IFiniteClosure fc, Set fBounded) { return fc.smArg(this, fBounded); @@ -157,7 +187,7 @@ public final class PlaceholderType extends UnifyType{ @Override - public Collection getInvolvedPlaceholderTypes() { + public Collection getInvolvedPlaceholderTypes() { ArrayList ret = new ArrayList<>(); ret.add(this); return ret; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java index d69138a7..19f6010f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java @@ -121,6 +121,10 @@ public class UnifyPair { pairOp = po; } + public void addSubstitutions(Set sup) { + substitution.addAll(sup); + } + public byte getVariance() { return variance; } @@ -152,6 +156,15 @@ public class UnifyPair { return ret; } + public Set getAllBases () { + Set 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()+ "])"; } /* diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java index bb7bc1c6..298f87e7 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java @@ -97,7 +97,7 @@ public abstract class UnifyType { return typeName + params; } - public Collection getInvolvedPlaceholderTypes() { + public Collection getInvolvedPlaceholderTypes() { ArrayList ret = new ArrayList<>(); ret.addAll(typeParams.getInvolvedPlaceholderTypes()); return ret; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java index 81999492..ea70139f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java @@ -64,7 +64,7 @@ public abstract class WildcardType extends UnifyType { @Override - public Collection getInvolvedPlaceholderTypes() { + public Collection getInvolvedPlaceholderTypes() { ArrayList ret = new ArrayList<>(); ret.addAll(wildcardedType.getInvolvedPlaceholderTypes()); return ret; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/hashKeyType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/hashKeyType.java new file mode 100644 index 00000000..dedfcd86 --- /dev/null +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/hashKeyType.java @@ -0,0 +1,25 @@ +package de.dhbwstuttgart.typeinference.unify.model; + +public class hashKeyType { + UnifyType realType; + + hashKeyType(UnifyType realType) { + this.realType= realType; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof hashKeyType) { + return realType.equals(((hashKeyType)obj).realType); + } + else + { + return false; + } + } + + @Override + public int hashCode() { + return realType.hashCode(); + } +} diff --git a/src/test/java/asp/gencay/GeneratorTest.java b/src/test/java/asp/gencay/GeneratorTest.java index bd268a4b..2c9fc46f 100644 --- a/src/test/java/asp/gencay/GeneratorTest.java +++ b/src/test/java/asp/gencay/GeneratorTest.java @@ -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; diff --git a/src/test/java/bytecode/MatrixTest.java b/src/test/java/bytecode/MatrixTest.java old mode 100644 new mode 100755 diff --git a/src/test/java/bytecode/YTest.java b/src/test/java/bytecode/YTest.java index 2a63a3ed..524170eb 100644 --- a/src/test/java/bytecode/YTest.java +++ b/src/test/java/bytecode/YTest.java @@ -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"); /* diff --git a/src/test/java/javFiles/AddLong.jav b/src/test/java/javFiles/AddLong.jav deleted file mode 100644 index d6d47e9f..00000000 --- a/src/test/java/javFiles/AddLong.jav +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/EmptyClass.jav b/src/test/java/javFiles/EmptyClass.jav deleted file mode 100644 index 8160d7da..00000000 --- a/src/test/java/javFiles/EmptyClass.jav +++ /dev/null @@ -1,3 +0,0 @@ -public class EmptyClass{ - -} \ No newline at end of file diff --git a/src/test/java/javFiles/EmptyMethod.jav b/src/test/java/javFiles/EmptyMethod.jav deleted file mode 100644 index dd28fc69..00000000 --- a/src/test/java/javFiles/EmptyMethod.jav +++ /dev/null @@ -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; - } -}*/ \ No newline at end of file diff --git a/src/test/java/javFiles/Expressions.jav b/src/test/java/javFiles/Expressions.jav deleted file mode 100644 index e2e992a1..00000000 --- a/src/test/java/javFiles/Expressions.jav +++ /dev/null @@ -1,8 +0,0 @@ -class Expressions{ - -void test(){ - var x = 2; - x = x + 2; -} - -} \ No newline at end of file diff --git a/src/test/java/javFiles/FC_Matrix.jav b/src/test/java/javFiles/FC_Matrix.jav deleted file mode 100644 index 75ead472..00000000 --- a/src/test/java/javFiles/FC_Matrix.jav +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.Vector; - -class Matrix extends Vector> { - - methode(m) { - m.add(1); - Matrix i; - methode(i); - } - } diff --git a/src/test/java/javFiles/Faculty.jav b/src/test/java/javFiles/Faculty.jav deleted file mode 100644 index ca539add..00000000 --- a/src/test/java/javFiles/Faculty.jav +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/FacultyIf.jav b/src/test/java/javFiles/FacultyIf.jav deleted file mode 100644 index 3c368923..00000000 --- a/src/test/java/javFiles/FacultyIf.jav +++ /dev/null @@ -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; - } -} diff --git a/src/test/java/javFiles/FacultyTyped.jav b/src/test/java/javFiles/FacultyTyped.jav deleted file mode 100644 index 089d2f33..00000000 --- a/src/test/java/javFiles/FacultyTyped.jav +++ /dev/null @@ -1,19 +0,0 @@ -import java.lang.Integer; - -class Faculty { - - Integer mul(Integer x, Integer y) { - return x; - } - - Fun1 m () { - var fact = (Integer x) -> { - return mul(x, fact.apply(x)); - }; - return fact; - } -} - -interface Fun1{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/java/javFiles/Fields.jav b/src/test/java/javFiles/Fields.jav deleted file mode 100644 index cd2add71..00000000 --- a/src/test/java/javFiles/Fields.jav +++ /dev/null @@ -1,11 +0,0 @@ -import java.lang.String; - -class Fields{ -test2 = "test"; -test; -m(){ - var test3; - return test; -} - -} \ No newline at end of file diff --git a/src/test/java/javFiles/Generics.jav b/src/test/java/javFiles/Generics.jav deleted file mode 100644 index dd7b4eba..00000000 --- a/src/test/java/javFiles/Generics.jav +++ /dev/null @@ -1,22 +0,0 @@ -import java.lang.String; - -class Generics { - // A mt1(A a, B b){ - B mt1(B a, B b){ - return mt1(a, a); - } -} - -class Test { - methode(String s){ - return new Generics().mt1(s,s); - } -} - -/* -Problem: -auto test = new List(); -auto test2 = new List(); -... //code, welcher möglicherweise test und test2 vertauscht -test.add("hallo"); -*/ \ No newline at end of file diff --git a/src/test/java/javFiles/IfTest.jav b/src/test/java/javFiles/IfTest.jav deleted file mode 100644 index 1e1141df..00000000 --- a/src/test/java/javFiles/IfTest.jav +++ /dev/null @@ -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; - } - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Import.jav b/src/test/java/javFiles/Import.jav deleted file mode 100644 index c48082ba..00000000 --- a/src/test/java/javFiles/Import.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.Vector; - -class Import { - void methode(){ - Vector v; - v.add(v); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Lambda.jav b/src/test/java/javFiles/Lambda.jav deleted file mode 100644 index 5bd67a0b..00000000 --- a/src/test/java/javFiles/Lambda.jav +++ /dev/null @@ -1,13 +0,0 @@ - -class Apply { } - -public class Lambda { - - m () { - var lam1 = (x) -> { - return x; - }; - return lam1.apply(new Apply()); - } -} - diff --git a/src/test/java/javFiles/Lambda2.jav b/src/test/java/javFiles/Lambda2.jav deleted file mode 100644 index cf1e910b..00000000 --- a/src/test/java/javFiles/Lambda2.jav +++ /dev/null @@ -1,33 +0,0 @@ -import java.lang.String; - -public class Lambda2 -{ - public static void main(List args){ - var listOfStrings = new List(); - var listOfObjects; - listOfObjects = map(listOfStrings, (a) -> a); -} - -public map(a , b){ - b.apply(a); - return a; -} - -/* -public static List map(List input, Function func) { - List output; - output = new List(); - output.add(func.apply(input.get())); - return output; -} -*/ -} - -class List{ - A get(); - void add(A); -} - -class Function{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/java/javFiles/Lambda3.jav b/src/test/java/javFiles/Lambda3.jav deleted file mode 100644 index 9e22f302..00000000 --- a/src/test/java/javFiles/Lambda3.jav +++ /dev/null @@ -1,24 +0,0 @@ -import java.lang.String; - -public class Lambda2 -{ - /* - public static List map(List input, - Function func){ - input.add(func.apply(input.get())); - } - */ - public map(input,func){ - input.add(func.apply(input.get())); - return map(new List(), func); - } -} - -class List{ - A get(); - void add(A); -} - -class Function{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/java/javFiles/LambdaField.jav b/src/test/java/javFiles/LambdaField.jav deleted file mode 100644 index 4eb53738..00000000 --- a/src/test/java/javFiles/LambdaField.jav +++ /dev/null @@ -1,6 +0,0 @@ -public class LambdaField { - - f = x -> x; - -} - diff --git a/src/test/java/javFiles/LambdaRunnable.jav b/src/test/java/javFiles/LambdaRunnable.jav deleted file mode 100644 index 37924ea2..00000000 --- a/src/test/java/javFiles/LambdaRunnable.jav +++ /dev/null @@ -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(); - } -} - diff --git a/src/test/java/javFiles/ListenerOverload.jav b/src/test/java/javFiles/ListenerOverload.jav deleted file mode 100644 index e1a8d65d..00000000 --- a/src/test/java/javFiles/ListenerOverload.jav +++ /dev/null @@ -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 left; - B right; -} \ No newline at end of file diff --git a/src/test/java/javFiles/Matrix.jav b/src/test/java/javFiles/Matrix.jav deleted file mode 100644 index 5e1eac08..00000000 --- a/src/test/java/javFiles/Matrix.jav +++ /dev/null @@ -1,28 +0,0 @@ -import java.util.Vector; -import java.lang.Integer; - -class Matrix extends Vector> { - 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(); - 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; - } -} diff --git a/src/test/java/javFiles/Meth_Gen.jav b/src/test/java/javFiles/Meth_Gen.jav deleted file mode 100644 index 056dd82f..00000000 --- a/src/test/java/javFiles/Meth_Gen.jav +++ /dev/null @@ -1,11 +0,0 @@ -class Meth_Gen { - - m1(x, y) { - m2(x); - x = y; - } - - m2(y) { - m1(y, y); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/MethodCallGenerics.jav b/src/test/java/javFiles/MethodCallGenerics.jav deleted file mode 100644 index 0d02509b..00000000 --- a/src/test/java/javFiles/MethodCallGenerics.jav +++ /dev/null @@ -1,14 +0,0 @@ -import java.lang.String; - -class Generics { - // A mt1(A a, B b){ - B mt1(B a, B b){ - return mt1(a, a); - } -} - -class Test { - methode(String s){ - return new Generics().mt1(s,s); - } -} diff --git a/src/test/java/javFiles/Methods.jav b/src/test/java/javFiles/Methods.jav deleted file mode 100644 index e45d9830..00000000 --- a/src/test/java/javFiles/Methods.jav +++ /dev/null @@ -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){} -} \ No newline at end of file diff --git a/src/test/java/javFiles/MethodsEasy.jav b/src/test/java/javFiles/MethodsEasy.jav deleted file mode 100644 index ee6f9daf..00000000 --- a/src/test/java/javFiles/MethodsEasy.jav +++ /dev/null @@ -1,7 +0,0 @@ - -class Methods { - mt4(a,b,c) { return a.mt3(b).mt3(c) ; } - - mt3(a) {return a.mt3(a); } -} - diff --git a/src/test/java/javFiles/Op1.jav b/src/test/java/javFiles/Op1.jav deleted file mode 100644 index 800f58b8..00000000 --- a/src/test/java/javFiles/Op1.jav +++ /dev/null @@ -1,11 +0,0 @@ -public class Op1{ - public Op1() { - - Runnable lam = () -> { - String test = ""; - String b = "b"; - test = b; - System.out.println(test);}; - //lam.run(); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Package.jav b/src/test/java/javFiles/Package.jav deleted file mode 100644 index bbc1e51d..00000000 --- a/src/test/java/javFiles/Package.jav +++ /dev/null @@ -1,5 +0,0 @@ -package strucType.input; - -class Neu -{ -} \ No newline at end of file diff --git a/src/test/java/javFiles/Sorting.jav b/src/test/java/javFiles/Sorting.jav deleted file mode 100644 index 04ef23e5..00000000 --- a/src/test/java/javFiles/Sorting.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.List; -import java.util.Collection; - -class Sorting{ - void merge(a, b){ - a.addAll(b); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Subclass.jav b/src/test/java/javFiles/Subclass.jav deleted file mode 100644 index fe6e9208..00000000 --- a/src/test/java/javFiles/Subclass.jav +++ /dev/null @@ -1,6 +0,0 @@ -public class Subclass extends Superclass { - - public void printMethod() { - super.printMethod(); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Superclass.jav b/src/test/java/javFiles/Superclass.jav deleted file mode 100644 index d58089de..00000000 --- a/src/test/java/javFiles/Superclass.jav +++ /dev/null @@ -1,6 +0,0 @@ -public class Superclass { - - public void printMethod() { - System.out.println("Printed in Superclass."); - } -} diff --git a/src/test/java/javFiles/Vector.jav b/src/test/java/javFiles/Vector.jav deleted file mode 100644 index 5c21cfff..00000000 --- a/src/test/java/javFiles/Vector.jav +++ /dev/null @@ -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; -} -} \ No newline at end of file diff --git a/src/test/java/javFiles/fc.jav b/src/test/java/javFiles/fc.jav deleted file mode 100644 index a3278cbc..00000000 --- a/src/test/java/javFiles/fc.jav +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/src/test/java/javFiles/mathStruc.jav b/src/test/java/javFiles/mathStruc.jav deleted file mode 100644 index 93f901ce..00000000 --- a/src/test/java/javFiles/mathStruc.jav +++ /dev/null @@ -1,13 +0,0 @@ - -class mathStruc { - -mathStruc(A a) { } - -A model(){ A a; return a; } - -methode(){ -var innerOp = o -> ms -> - new mathStruc(o.apply(this.model(),ms.model())); - return innerOp; - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/test.jav b/src/test/java/javFiles/test.jav deleted file mode 100644 index 303d167a..00000000 --- a/src/test/java/javFiles/test.jav +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/src/test/java/javFiles/test1.jav b/src/test/java/javFiles/test1.jav deleted file mode 100644 index 4b34948e..00000000 --- a/src/test/java/javFiles/test1.jav +++ /dev/null @@ -1,7 +0,0 @@ -class Faculty { - - int a; - m (int x) { - return a+x; - } -} diff --git a/src/test/resources/bytecode/LambdaCapturetest.java b/src/test/resources/bytecode/LambdaCapturetest.java deleted file mode 100644 index 438c2315..00000000 --- a/src/test/resources/bytecode/LambdaCapturetest.java +++ /dev/null @@ -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(); - } - -} diff --git a/src/test/resources/bytecode/javFiles/Matrix.jav b/src/test/resources/bytecode/javFiles/Matrix.jav index 48f6eda2..29505161 100644 --- a/src/test/resources/bytecode/javFiles/Matrix.jav +++ b/src/test/resources/bytecode/javFiles/Matrix.jav @@ -1,8 +1,8 @@ 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> { @@ -19,7 +19,7 @@ public class Matrix extends Vector> { } } - mul(m) { + mul(m) { var ret = new Matrix(); var i = 0; while(i < size()) { diff --git a/src/test/resources/bytecode/javFiles/Merge.jav b/src/test/resources/bytecode/javFiles/Merge.jav index 9240146e..ad5e103e 100644 --- a/src/test/resources/bytecode/javFiles/Merge.jav +++ b/src/test/resources/bytecode/javFiles/Merge.jav @@ -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); diff --git a/src/test/resources/bytecode/simplifyalgo/CycleTest.java b/src/test/resources/bytecode/simplifyalgo/CycleTest.java deleted file mode 100644 index 88697e6d..00000000 --- a/src/test/resources/bytecode/simplifyalgo/CycleTest.java +++ /dev/null @@ -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> result = new HashMap<>(); - HashSet 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> sim = Simplify.simplifyConstraints(methName, tphExtractor); - boolean areEquals = SimpleCycle.areMapsEqual(result, sim); - assertTrue(areEquals); - } - -} diff --git a/src/test/resources/bytecode/simplifyalgo/SameLeftSide.java b/src/test/resources/bytecode/simplifyalgo/SameLeftSide.java deleted file mode 100644 index b5c4e875..00000000 --- a/src/test/resources/bytecode/simplifyalgo/SameLeftSide.java +++ /dev/null @@ -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> 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> sim = Simplify.simplifyConstraints(methName, tphExtractor); - boolean areEquals = SimpleCycle.areMapsEqual(result, sim); - assertTrue(areEquals); - } - - @Test - public void testM2() { - HashMap> 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> sim = Simplify.simplifyConstraints(methName2, tphExtractor); - boolean areEquals = SimpleCycle.areMapsEqual(result, sim); - assertTrue(areEquals); - } - -} diff --git a/src/test/resources/bytecode/simplifyalgo/SimpleCycle.java b/src/test/resources/bytecode/simplifyalgo/SimpleCycle.java deleted file mode 100644 index 636eb026..00000000 --- a/src/test/resources/bytecode/simplifyalgo/SimpleCycle.java +++ /dev/null @@ -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> result = new HashMap<>(); - HashSet 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> sim = Simplify.simplifyConstraints(methName, tphExtractor); - boolean areEquals = areMapsEqual(result, sim); - assertTrue(areEquals); - } - - public static boolean areMapsEqual(HashMap> m1, HashMap> 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 eq1 = m1.get(c); - HashSet 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; - } - -} diff --git a/src/test/resources/javFiles/Faculty.jav b/src/test/resources/javFiles/Faculty.jav index ca539add..71f40515 100644 --- a/src/test/resources/javFiles/Faculty.jav +++ b/src/test/resources/javFiles/Faculty.jav @@ -5,7 +5,7 @@ class Faculty { Integer mul(Integer x, Integer y) { return x; } - + m () { var fact = (Integer x) -> { return mul(x, fact.apply(x)); diff --git a/src/test/resources/javFiles/bytecode/AssignToLit.jav b/src/test/resources/javFiles/bytecode/AssignToLit.jav deleted file mode 100644 index 873828ed..00000000 --- a/src/test/resources/javFiles/bytecode/AssignToLit.jav +++ /dev/null @@ -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'; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/BinaryInMeth.jav b/src/test/resources/javFiles/bytecode/BinaryInMeth.jav deleted file mode 100644 index 3b5fa77b..00000000 --- a/src/test/resources/javFiles/bytecode/BinaryInMeth.jav +++ /dev/null @@ -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); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/DuMethod.jav b/src/test/resources/javFiles/bytecode/DuMethod.jav deleted file mode 100644 index 3898a7ba..00000000 --- a/src/test/resources/javFiles/bytecode/DuMethod.jav +++ /dev/null @@ -1,11 +0,0 @@ -public class DuMethod{ - - method(a){ - return a+a; - } - - method(a){ - return a; - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/EmptyMethod.jav b/src/test/resources/javFiles/bytecode/EmptyMethod.jav deleted file mode 100644 index 961989df..00000000 --- a/src/test/resources/javFiles/bytecode/EmptyMethod.jav +++ /dev/null @@ -1,8 +0,0 @@ -public class EmptyMethod{ - - public void m1(){ - System.out.println("test"); - } - - public void m2(){} -} diff --git a/src/test/resources/javFiles/bytecode/Example.jav b/src/test/resources/javFiles/bytecode/Example.jav deleted file mode 100644 index b7455a3f..00000000 --- a/src/test/resources/javFiles/bytecode/Example.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.String; - -public class Example { - - public m() { - String x = "X"; - return x; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Exceptions.jav b/src/test/resources/javFiles/bytecode/Exceptions.jav deleted file mode 100644 index 9903511c..00000000 --- a/src/test/resources/javFiles/bytecode/Exceptions.jav +++ /dev/null @@ -1,3 +0,0 @@ -public class Exceptions { -// m(Integer i) throws -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Fac.jav b/src/test/resources/javFiles/bytecode/Fac.jav deleted file mode 100644 index 28650b45..00000000 --- a/src/test/resources/javFiles/bytecode/Fac.jav +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Faculty.jav b/src/test/resources/javFiles/bytecode/Faculty.jav deleted file mode 100644 index 2754b7f8..00000000 --- a/src/test/resources/javFiles/bytecode/Faculty.jav +++ /dev/null @@ -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); -// } -// } -} diff --git a/src/test/resources/javFiles/bytecode/Faculty2.jav b/src/test/resources/javFiles/bytecode/Faculty2.jav deleted file mode 100644 index 828f06f5..00000000 --- a/src/test/resources/javFiles/bytecode/Faculty2.jav +++ /dev/null @@ -1,10 +0,0 @@ -class Faculty2 { - - m () { - - var fact = (Integer x) -> { - return x; - }; - return fact; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Field.jav b/src/test/resources/javFiles/bytecode/Field.jav deleted file mode 100644 index b19b2308..00000000 --- a/src/test/resources/javFiles/bytecode/Field.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; - -public class Field { - public Integer x = 5; - - m(){ - return x; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/For.jav b/src/test/resources/javFiles/bytecode/For.jav deleted file mode 100644 index c4bd6677..00000000 --- a/src/test/resources/javFiles/bytecode/For.jav +++ /dev/null @@ -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; -// } -// } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/FunOL.jav b/src/test/resources/javFiles/bytecode/FunOL.jav deleted file mode 100644 index 60736e1f..00000000 --- a/src/test/resources/javFiles/bytecode/FunOL.jav +++ /dev/null @@ -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; - } -} diff --git a/src/test/resources/javFiles/bytecode/Gen.jav b/src/test/resources/javFiles/bytecode/Gen.jav deleted file mode 100644 index 3b58b188..00000000 --- a/src/test/resources/javFiles/bytecode/Gen.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.lang.Integer; -import java.util.Vector; - -public class Gen{ - Vector m(Vector v){ - return v; - } -} diff --git a/src/test/resources/javFiles/bytecode/Generics.jav b/src/test/resources/javFiles/bytecode/Generics.jav deleted file mode 100644 index bb7b2af5..00000000 --- a/src/test/resources/javFiles/bytecode/Generics.jav +++ /dev/null @@ -1,17 +0,0 @@ - -class Generics { - Generics(B b){ - } - B mt1(B b){ - return mt1(b); - } -} - - -/* -Problem: -auto test = new List(); -auto test2 = new List(); -... //code, welcher möglicherweise test und test2 vertauscht -test.add("hallo"); -*/ \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Generics2.jav b/src/test/resources/javFiles/bytecode/Generics2.jav deleted file mode 100644 index 52d5caa2..00000000 --- a/src/test/resources/javFiles/bytecode/Generics2.jav +++ /dev/null @@ -1,6 +0,0 @@ -class Generics2{ - B m1(B b){ - return b; - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/GreaterEqual.jav b/src/test/resources/javFiles/bytecode/GreaterEqual.jav deleted file mode 100644 index 3ec69e8a..00000000 --- a/src/test/resources/javFiles/bytecode/GreaterEqual.jav +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/GreaterThan.jav b/src/test/resources/javFiles/bytecode/GreaterThan.jav deleted file mode 100644 index 9077f5b1..00000000 --- a/src/test/resources/javFiles/bytecode/GreaterThan.jav +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/IfTest.jav b/src/test/resources/javFiles/bytecode/IfTest.jav deleted file mode 100644 index bbcda96c..00000000 --- a/src/test/resources/javFiles/bytecode/IfTest.jav +++ /dev/null @@ -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; - } - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Import.jav b/src/test/resources/javFiles/bytecode/Import.jav deleted file mode 100644 index c658568f..00000000 --- a/src/test/resources/javFiles/bytecode/Import.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.Vector; - -class Import { - void methode(){ - Vector v = new Vector<>(); - v.add("X"); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Interface1.jav b/src/test/resources/javFiles/bytecode/Interface1.jav deleted file mode 100644 index b741819c..00000000 --- a/src/test/resources/javFiles/bytecode/Interface1.jav +++ /dev/null @@ -1,3 +0,0 @@ -public interface Interface1{ - public void test(); -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/LamRunnable.jav b/src/test/resources/javFiles/bytecode/LamRunnable.jav deleted file mode 100644 index 451858f2..00000000 --- a/src/test/resources/javFiles/bytecode/LamRunnable.jav +++ /dev/null @@ -1,9 +0,0 @@ -public class LamRunnable{ - - public LamRunnable(){ - - Runnable lam = () -> {System.out.println("lambda");}; - lam.run(); - } -} - \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Lambda.jav b/src/test/resources/javFiles/bytecode/Lambda.jav deleted file mode 100644 index b0321fc2..00000000 --- a/src/test/resources/javFiles/bytecode/Lambda.jav +++ /dev/null @@ -1,10 +0,0 @@ -import java.lang.Integer; - -public class Lambda { - - m () { - var lam1 = (x) -> { - return x; - }; - return lam1; -} diff --git a/src/test/resources/javFiles/bytecode/Lambda2.jav b/src/test/resources/javFiles/bytecode/Lambda2.jav deleted file mode 100644 index 92f32b71..00000000 --- a/src/test/resources/javFiles/bytecode/Lambda2.jav +++ /dev/null @@ -1,35 +0,0 @@ -import java.lang.String; - -public class Lambda2 -{ - public static void main(List args){ - var listOfStrings = new List(); - var listOfObjects; - listOfObjects = map(listOfStrings, (a) -> a); -} - -public map(a , b){ - b.apply(a); - return a; -} - -/* -public static List map(List input, Function func) { - List output; - output = new List(); - output.add(func.apply(input.get())); - return output; -} -*/ -} - -class List{ - /* A get(); - void add(A); - */ -} -/* -class Function{ - B apply(A a); -} -*/ \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Lambda3.jav b/src/test/resources/javFiles/bytecode/Lambda3.jav deleted file mode 100644 index 9c4e960c..00000000 --- a/src/test/resources/javFiles/bytecode/Lambda3.jav +++ /dev/null @@ -1,23 +0,0 @@ - -public class Lambda2 -{ - /* - public static List map(List input, - Function func){ - input.add(func.apply(input.get())); - } - */ - public map(input,func){ - input.add(func.apply(input.get())); - return map(new List(), func); - } -} - -class List{ - A get(); - void add(A); -} - -class Function{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Lambda4.jav b/src/test/resources/javFiles/bytecode/Lambda4.jav deleted file mode 100644 index 378eb4d3..00000000 --- a/src/test/resources/javFiles/bytecode/Lambda4.jav +++ /dev/null @@ -1,18 +0,0 @@ -class Lambda{ - -methode(){ - return ((f) -> f); -} -} -/* -interface Fun0{ - A apply(); -} - -interface Fun1{ - A apply(B b); -} -*/ -interface Fun2{ - A apply(B b, C c); -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/LambdaCapture.jav b/src/test/resources/javFiles/bytecode/LambdaCapture.jav deleted file mode 100644 index ab1751f4..00000000 --- a/src/test/resources/javFiles/bytecode/LambdaCapture.jav +++ /dev/null @@ -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;}; - - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/LambdaVoid.jav b/src/test/resources/javFiles/bytecode/LambdaVoid.jav deleted file mode 100644 index dc16fcbf..00000000 --- a/src/test/resources/javFiles/bytecode/LambdaVoid.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; - -public class Lambda { - - m () { - var lam1 = (x) -> { }; - return lam1; - } -} diff --git a/src/test/resources/javFiles/bytecode/LessEqual.jav b/src/test/resources/javFiles/bytecode/LessEqual.jav deleted file mode 100644 index 2e3b7024..00000000 --- a/src/test/resources/javFiles/bytecode/LessEqual.jav +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/LessThan.jav b/src/test/resources/javFiles/bytecode/LessThan.jav deleted file mode 100644 index 04e1e83e..00000000 --- a/src/test/resources/javFiles/bytecode/LessThan.jav +++ /dev/null @@ -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> { - - 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(); - 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; - } -} diff --git a/src/test/resources/javFiles/bytecode/MatrixOP.jav b/src/test/resources/javFiles/bytecode/MatrixOP.jav deleted file mode 100644 index 828a270b..00000000 --- a/src/test/resources/javFiles/bytecode/MatrixOP.jav +++ /dev/null @@ -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> { - - 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(); - 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; - }; -} diff --git a/src/test/resources/javFiles/bytecode/Merge.jav b/src/test/resources/javFiles/bytecode/Merge.jav deleted file mode 100644 index 9240146e..00000000 --- a/src/test/resources/javFiles/bytecode/Merge.jav +++ /dev/null @@ -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)); - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Methods.jav b/src/test/resources/javFiles/bytecode/Methods.jav deleted file mode 100644 index 3c46739d..00000000 --- a/src/test/resources/javFiles/bytecode/Methods.jav +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/OL.jav b/src/test/resources/javFiles/bytecode/OL.jav deleted file mode 100644 index 700e50f0..00000000 --- a/src/test/resources/javFiles/bytecode/OL.jav +++ /dev/null @@ -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); - } -} diff --git a/src/test/resources/javFiles/bytecode/Op.jav b/src/test/resources/javFiles/bytecode/Op.jav deleted file mode 100644 index 082f48d8..00000000 --- a/src/test/resources/javFiles/bytecode/Op.jav +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Op2.jav b/src/test/resources/javFiles/bytecode/Op2.jav deleted file mode 100644 index 9d446eb2..00000000 --- a/src/test/resources/javFiles/bytecode/Op2.jav +++ /dev/null @@ -1,11 +0,0 @@ -import java.lang.Integer; -import java.lang.String; - -public class Op2 { - m(){ - var x = ""; - var a = 5+x; - - return a; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/OverlaodGen.jav b/src/test/resources/javFiles/bytecode/OverlaodGen.jav deleted file mode 100644 index d5946496..00000000 --- a/src/test/resources/javFiles/bytecode/OverlaodGen.jav +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.Vector; - -class OverlaodGen { - void method(Vector v) { -// Integer i = v.get(0); - } - - void method(Vector v) { -// String s = v.get(0); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Overloading.jav b/src/test/resources/javFiles/bytecode/Overloading.jav deleted file mode 100644 index fb48fe0f..00000000 --- a/src/test/resources/javFiles/bytecode/Overloading.jav +++ /dev/null @@ -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"; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Plus.jav b/src/test/resources/javFiles/bytecode/Plus.jav deleted file mode 100644 index 1cdecc8c..00000000 --- a/src/test/resources/javFiles/bytecode/Plus.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; -import java.lang.String; - -public class Plus { - - m(a,b) { - return a+b; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/PostIncDec.jav b/src/test/resources/javFiles/bytecode/PostIncDec.jav deleted file mode 100644 index 29c2ef17..00000000 --- a/src/test/resources/javFiles/bytecode/PostIncDec.jav +++ /dev/null @@ -1,27 +0,0 @@ -import java.lang.Integer; - -public class PostIncDec { - m() { - var i = 0; - i++; - return i; - } - - m2() { - var i = 0; - var j = i++; - return j; - } - - d() { - var i = 0; - i--; - return i; - } - - d2() { - var i = 0; - var j = i--; - return j; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/PreInc.jav b/src/test/resources/javFiles/bytecode/PreInc.jav deleted file mode 100644 index 011501f1..00000000 --- a/src/test/resources/javFiles/bytecode/PreInc.jav +++ /dev/null @@ -1,28 +0,0 @@ -import java.lang.Integer; - -public class PreInc { - m() { - var i = 0; - ++i; - return i; - } - - m2() { - var i = 0; - var j = ++i; - return j; - } - - d() { - var i = 0; - --i; - return i; - } - - d2() { - var i = 0; - var j = --i; - return j; - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/RecursiveMeth.jav b/src/test/resources/javFiles/bytecode/RecursiveMeth.jav deleted file mode 100644 index be35a43c..00000000 --- a/src/test/resources/javFiles/bytecode/RecursiveMeth.jav +++ /dev/null @@ -1,5 +0,0 @@ -public class RecursiveMeth{ - public Integer test(){ - return this.test(); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/RelOps.jav b/src/test/resources/javFiles/bytecode/RelOps.jav deleted file mode 100644 index 0fdd2cff..00000000 --- a/src/test/resources/javFiles/bytecode/RelOps.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.lang.Integer; -import java.lang.Boolean; - -public class RelOps { - m(a,b){ - return a a){ - a = merge(a,a); - } -*/ -} diff --git a/src/test/resources/javFiles/bytecode/StaticM.jav b/src/test/resources/javFiles/bytecode/StaticM.jav deleted file mode 100644 index 66890033..00000000 --- a/src/test/resources/javFiles/bytecode/StaticM.jav +++ /dev/null @@ -1,10 +0,0 @@ -public class StaticM { - - public static void m() { - System.out.println("Test"); - } - - public static void m2() { - m(); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/SubMatrix.jav b/src/test/resources/javFiles/bytecode/SubMatrix.jav deleted file mode 100644 index f761321c..00000000 --- a/src/test/resources/javFiles/bytecode/SubMatrix.jav +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.Vector; -import java.lang.Integer; - -public class Matrix2 extends Vector { - -} - -public class SubMatrix extends Matrix2 { - m(){ - Vector v = new Vector(); - v.add(1); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Tph.jav b/src/test/resources/javFiles/bytecode/Tph.jav deleted file mode 100644 index 4a49ac46..00000000 --- a/src/test/resources/javFiles/bytecode/Tph.jav +++ /dev/null @@ -1,12 +0,0 @@ -public class Tph { - - m(a,b){ - var c = m2(b); -// return a; - return m2(b); - } - - m2(b){ - return b; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Tph2.jav b/src/test/resources/javFiles/bytecode/Tph2.jav deleted file mode 100644 index c957eae6..00000000 --- a/src/test/resources/javFiles/bytecode/Tph2.jav +++ /dev/null @@ -1,10 +0,0 @@ -public class Tph2 { - m(a,b){ - var c = m2(a,b); - return a; - } - - m2(a,b){ - return b; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Tph3.jav b/src/test/resources/javFiles/bytecode/Tph3.jav deleted file mode 100644 index f2bcd2ef..00000000 --- a/src/test/resources/javFiles/bytecode/Tph3.jav +++ /dev/null @@ -1,13 +0,0 @@ -public class Tph3 { -// m(a,b){ -// var c = m2(a,b); -// return c; -// } -// -// m2(a,b){ -// return m(a,b); -// } - m1(x, y) { m2(x); x = y; } - - m2(y) { m1(y, y); } -} diff --git a/src/test/resources/javFiles/bytecode/Tph4.jav b/src/test/resources/javFiles/bytecode/Tph4.jav deleted file mode 100644 index 1eb529de..00000000 --- a/src/test/resources/javFiles/bytecode/Tph4.jav +++ /dev/null @@ -1,12 +0,0 @@ -public class Tph4{ - m(a,b){ - var c = m2(b); - var d = m2(c); - return a; - } - - m2(b){ - return b - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Tph5.jav b/src/test/resources/javFiles/bytecode/Tph5.jav deleted file mode 100644 index e73cfa2c..00000000 --- a/src/test/resources/javFiles/bytecode/Tph5.jav +++ /dev/null @@ -1,13 +0,0 @@ -public class Tph5 { -// m(a,b,c){ -// a = c; -// b = c; -// return a; -// } - - m(x,y){ - x = m2(y); - } - - m2(y) { return y; } -} diff --git a/src/test/resources/javFiles/bytecode/VectorAdd.jav b/src/test/resources/javFiles/bytecode/VectorAdd.jav deleted file mode 100644 index 814f46c2..00000000 --- a/src/test/resources/javFiles/bytecode/VectorAdd.jav +++ /dev/null @@ -1,19 +0,0 @@ -import java.util.Vector; -import java.lang.Integer; -import java.lang.String; -//import java.lang.Byte; -//import java.lang.Boolean; - -public class VectorAdd { - - add(v1, v2) { - var ret = new Vector(); - var i = 0; - var erg; - while(i < v1.size()) { - erg = v1.elementAt(i) + v2.elementAt(i); - ret.addElement(erg); - } - return ret; - } -} diff --git a/src/test/resources/javFiles/bytecode/VoidMeth.jav b/src/test/resources/javFiles/bytecode/VoidMeth.jav deleted file mode 100644 index 6b3ab212..00000000 --- a/src/test/resources/javFiles/bytecode/VoidMeth.jav +++ /dev/null @@ -1,4 +0,0 @@ -public class VoidMeth{ - public void test(){ - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/WC.jav b/src/test/resources/javFiles/bytecode/WC.jav deleted file mode 100644 index 389a4fcd..00000000 --- a/src/test/resources/javFiles/bytecode/WC.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.lang.Integer; -import java.util.List; -public class WC { - - void m (List a, List b) { - - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/While.jav b/src/test/resources/javFiles/bytecode/While.jav deleted file mode 100644 index cd2139a6..00000000 --- a/src/test/resources/javFiles/bytecode/While.jav +++ /dev/null @@ -1,12 +0,0 @@ -import java.lang.Integer; -import java.lang.Long; -import java.lang.Double; - -public class While { - m(x) { - while(x < 2) { - x = x+1; - } - return x; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Y.jav b/src/test/resources/javFiles/bytecode/Y.jav deleted file mode 100644 index 3c3e204d..00000000 --- a/src/test/resources/javFiles/bytecode/Y.jav +++ /dev/null @@ -1,28 +0,0 @@ -import java.lang.Integer; - -class Y { - y; - //factorial; - - Y() { - y = f -> t -> f.apply(y.apply(f)).apply(t); - //factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); }); - } -} - -/* -ergibt Parse-Error -class fac1 { - factorial; - - fac1() { - var y; - y = new Y<>().y; - factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); }); - } - public static void main(String args[]) { - System.out.println(new fac1().factorial.apply(3)); - } - -} -*/ \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/applyLambda.jav b/src/test/resources/javFiles/bytecode/applyLambda.jav deleted file mode 100644 index 331bfbfe..00000000 --- a/src/test/resources/javFiles/bytecode/applyLambda.jav +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.Vector; -class Apply { } - -public class applyLambda { - - m () { - var lam1 = (x) -> { - return x; - }; - - return lam1.apply(new Apply()); - //return lam1; - //return new Vector(); - } -} - diff --git a/src/test/resources/javFiles/parser/AntlrTest.jav b/src/test/resources/javFiles/parser/AntlrTest.jav deleted file mode 100644 index 31ab067d..00000000 --- a/src/test/resources/javFiles/parser/AntlrTest.jav +++ /dev/null @@ -1,6 +0,0 @@ -class Test{ -method(){ - if(true)i++; - if(true)i--; - else i++; -}} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/BoundedParameter.jav b/src/test/resources/javFiles/parser/BoundedParameter.jav deleted file mode 100644 index 6d7518a9..00000000 --- a/src/test/resources/javFiles/parser/BoundedParameter.jav +++ /dev/null @@ -1,3 +0,0 @@ -class Matrix{ - String op = "String"; -} diff --git a/src/test/resources/javFiles/parser/CastTest.jav b/src/test/resources/javFiles/parser/CastTest.jav deleted file mode 100644 index 86ca7519..00000000 --- a/src/test/resources/javFiles/parser/CastTest.jav +++ /dev/null @@ -1,8 +0,0 @@ - -class CastTest{ -void methode(){ - Object a; - String b; - a = (Object) b; -} -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/ExtendsTest.jav b/src/test/resources/javFiles/parser/ExtendsTest.jav deleted file mode 100644 index 9103f463..00000000 --- a/src/test/resources/javFiles/parser/ExtendsTest.jav +++ /dev/null @@ -1,4 +0,0 @@ -class C1 extends Object -{ - m(para) { return para; } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/FeatherWeightJava.jav b/src/test/resources/javFiles/parser/FeatherWeightJava.jav deleted file mode 100644 index e607b12a..00000000 --- a/src/test/resources/javFiles/parser/FeatherWeightJava.jav +++ /dev/null @@ -1,11 +0,0 @@ - -class FeatherWeightJava { - mt4(a,b,c) { return a.add(b).sub(c) ; } - - mt1(a) {return a; } - - mt2(a) {return a.f; } - - mt3(a) {return a.add(); } -} - diff --git a/src/test/resources/javFiles/parser/FieldInitializationTest.jav b/src/test/resources/javFiles/parser/FieldInitializationTest.jav deleted file mode 100644 index f7818cc3..00000000 --- a/src/test/resources/javFiles/parser/FieldInitializationTest.jav +++ /dev/null @@ -1,3 +0,0 @@ -class FieldInitializationTest{ - var var = "hallo"; -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/FieldVarTest.jav b/src/test/resources/javFiles/parser/FieldVarTest.jav deleted file mode 100644 index 6e897824..00000000 --- a/src/test/resources/javFiles/parser/FieldVarTest.jav +++ /dev/null @@ -1,5 +0,0 @@ -package test; - -class Test{ -Typ a; -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/GenericFieldVarTest.jav b/src/test/resources/javFiles/parser/GenericFieldVarTest.jav deleted file mode 100644 index a47b41eb..00000000 --- a/src/test/resources/javFiles/parser/GenericFieldVarTest.jav +++ /dev/null @@ -1,3 +0,0 @@ -class Test{ - A var; -} diff --git a/src/test/resources/javFiles/parser/ImportTest.jav b/src/test/resources/javFiles/parser/ImportTest.jav deleted file mode 100644 index 2de55cee..00000000 --- a/src/test/resources/javFiles/parser/ImportTest.jav +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; - -class ImportTest{ -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/ImportTest2.jav b/src/test/resources/javFiles/parser/ImportTest2.jav deleted file mode 100644 index 3492e31c..00000000 --- a/src/test/resources/javFiles/parser/ImportTest2.jav +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.ArrayList; - -class ImportTest{ -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/ImportTestGeneric.jav b/src/test/resources/javFiles/parser/ImportTestGeneric.jav deleted file mode 100644 index 094f4c5e..00000000 --- a/src/test/resources/javFiles/parser/ImportTestGeneric.jav +++ /dev/null @@ -1,5 +0,0 @@ -import java.util.List; - -class ImportTest{ - List test; -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/NewTest.jav b/src/test/resources/javFiles/parser/NewTest.jav deleted file mode 100644 index 992a2e8d..00000000 --- a/src/test/resources/javFiles/parser/NewTest.jav +++ /dev/null @@ -1,5 +0,0 @@ - -class NewTest { -main() { return new NewTest<>().mt(new NewTest(1) , new NewTest(2) , new -NewTest(3)); } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/OpratorTest.jav b/src/test/resources/javFiles/parser/OpratorTest.jav deleted file mode 100644 index 2764adf4..00000000 --- a/src/test/resources/javFiles/parser/OpratorTest.jav +++ /dev/null @@ -1,12 +0,0 @@ -import java.lang.Integer; - -class OpratorTest { - m(Integer a, Integer b) { - c = a+b; -// d = a-b; -// e = a*b; -// f = a/b; - - return c; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/PackageNameTest.jav b/src/test/resources/javFiles/parser/PackageNameTest.jav deleted file mode 100644 index 53c889b7..00000000 --- a/src/test/resources/javFiles/parser/PackageNameTest.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; -import java.lang.Comparable; - -class PackageNameTest{ -java.lang.Integer test(a){return a;} - -Comparable test2(a){return a;} - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/StatementsTest.jav b/src/test/resources/javFiles/parser/StatementsTest.jav deleted file mode 100644 index 891dff12..00000000 --- a/src/test/resources/javFiles/parser/StatementsTest.jav +++ /dev/null @@ -1,8 +0,0 @@ -class Statements{ - -public void methodeTest(){ - methodeTest(); - return null; -} - -} diff --git a/src/test/resources/javFiles/parser/StructuralTypes.jav b/src/test/resources/javFiles/parser/StructuralTypes.jav deleted file mode 100644 index b3c210c8..00000000 --- a/src/test/resources/javFiles/parser/StructuralTypes.jav +++ /dev/null @@ -1,5 +0,0 @@ - -class A { - mt(x, y, z) { return x.sub(y).add(z); } -} - diff --git a/src/test/resources/javFiles/parser/WhileTest.jav b/src/test/resources/javFiles/parser/WhileTest.jav deleted file mode 100644 index 2ce192bd..00000000 --- a/src/test/resources/javFiles/parser/WhileTest.jav +++ /dev/null @@ -1,14 +0,0 @@ -class WhileTest{ - void methode(){ - Boolean test; - do{ - test=test; - }while(test); - - - while(test){ - test = test; - } - return; - } -} \ No newline at end of file diff --git a/src/test/resources/testBytecode/Field.java b/src/test/resources/testBytecode/Field.java deleted file mode 100644 index 50002082..00000000 --- a/src/test/resources/testBytecode/Field.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Field{ - public void m(){ - MethFieldVar mF = new MethFieldVar(); - mF.s1 = "Field S1"; - } -} diff --git a/src/test/resources/testBytecode/Import.java b/src/test/resources/testBytecode/Import.java deleted file mode 100644 index f3519acb..00000000 --- a/src/test/resources/testBytecode/Import.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.Vector; - -class Import { - void methode(){ - Vector v = new Vector(); - v.add(v); - } -} diff --git a/src/test/resources/testBytecode/Lam1.java b/src/test/resources/testBytecode/Lam1.java deleted file mode 100644 index 142feed2..00000000 --- a/src/test/resources/testBytecode/Lam1.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.function.Function; -public class Lam1{ - public Lam1() { - Function fun = (x) -> x+"1"; - fun.apply("2"); - - Runnable lam = () -> System.out.println("lambda"); - lam.run(); - } -} diff --git a/src/test/resources/testBytecode/LamRun.java b/src/test/resources/testBytecode/LamRun.java deleted file mode 100644 index fdaf0852..00000000 --- a/src/test/resources/testBytecode/LamRun.java +++ /dev/null @@ -1,8 +0,0 @@ -public class LamRun{ - - public void mRun(){ - - Runnable lam = () -> System.out.println("lambda"); - lam.run(); - } -} diff --git a/src/test/resources/testBytecode/MethFieldVar.java b/src/test/resources/testBytecode/MethFieldVar.java deleted file mode 100644 index 74086a01..00000000 --- a/src/test/resources/testBytecode/MethFieldVar.java +++ /dev/null @@ -1,38 +0,0 @@ -public class MethFieldVar{ - String s1;// = ""; - String s2; - -/* public void meth(Integer i, String j, Boolean b){ - //String local = "a"; - //int localL = local.length(); - //int l = s.length(); - String s = null; - //s = ""; - //return s.length();//l+localL; - } -*/ - public void mm(){ -// return "mm"; - } - public void m2(){ - System.out.println(""); - // Math.abs(1); - // String lV = "local"; - // s1 = "1"; - // s1.concat("2"); - s2 = s1; - - mm(); - - Clazz i = new Clazz(); - - Runnable lam = ()->{ - String test = ""; - String b = "b"; - test = b; - System.out.println(test); - }; - } -} - -class Clazz{} diff --git a/src/test/resources/testBytecode/Subclass.java b/src/test/resources/testBytecode/Subclass.java deleted file mode 100644 index 3e8b5853..00000000 --- a/src/test/resources/testBytecode/Subclass.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Subclass extends Superclass { - - public void printMethod() { - super.printMethod(); - } -} diff --git a/src/test/resources/testBytecode/SuperTest.java b/src/test/resources/testBytecode/SuperTest.java deleted file mode 100644 index 1b6ac268..00000000 --- a/src/test/resources/testBytecode/SuperTest.java +++ /dev/null @@ -1,14 +0,0 @@ -public class Superclass { - - public void printMethod() { - System.out.println("Printed in Superclass."); - } -} - -public class Subclass extends Superclass { - - public void printMethod() { - super.printMethod(); - - } -} diff --git a/src/test/resources/testBytecode/Superclass.java b/src/test/resources/testBytecode/Superclass.java deleted file mode 100644 index d58089de..00000000 --- a/src/test/resources/testBytecode/Superclass.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Superclass { - - public void printMethod() { - System.out.println("Printed in Superclass."); - } -} diff --git a/src/test/resources/testBytecode/TestMyTest.java b/src/test/resources/testBytecode/TestMyTest.java deleted file mode 100644 index e1305f76..00000000 --- a/src/test/resources/testBytecode/TestMyTest.java +++ /dev/null @@ -1,11 +0,0 @@ -class TestMyTest{ -public static void main(String[] a){ - //test1 - //new TestClass(); - //test if statement - //new TestIf(new Boolean(true)); - // test lambda - //new TestClass(); - new LamRun(); -} -} diff --git a/src/test/resources/testBytecode/testF.java b/src/test/resources/testBytecode/testF.java deleted file mode 100644 index fa4a50b7..00000000 --- a/src/test/resources/testBytecode/testF.java +++ /dev/null @@ -1,5 +0,0 @@ -public class testTets(){ - public static void main(String[] args){ - new tetsF(); - } -} diff --git a/src/test/resources/testBytecode/testTets.java b/src/test/resources/testBytecode/testTets.java deleted file mode 100644 index 4f95cbc0..00000000 --- a/src/test/resources/testBytecode/testTets.java +++ /dev/null @@ -1,5 +0,0 @@ -public class testTets{ - public static void main(String[] args){ - new TetsF(); - } -} diff --git a/src/test/resources/testBytecode/testTetsF.java b/src/test/resources/testBytecode/testTetsF.java deleted file mode 100644 index fa4a50b7..00000000 --- a/src/test/resources/testBytecode/testTetsF.java +++ /dev/null @@ -1,5 +0,0 @@ -public class testTets(){ - public static void main(String[] args){ - new tetsF(); - } -}