forked from i21017/JavaCompilerCore
Compare commits
1 Commits
feat/unify
...
c10acc020e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c10acc020e |
@@ -1,8 +1,6 @@
|
|||||||
package de.dhbwstuttgart.server;
|
package de.dhbwstuttgart.server;
|
||||||
|
|
||||||
import de.dhbwstuttgart.util.Logger;
|
import de.dhbwstuttgart.util.Logger;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import org.java_websocket.WebSocket;
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
public class ServerTaskLogger extends Logger {
|
public class ServerTaskLogger extends Logger {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class SocketServer extends WebSocketServer {
|
|||||||
|
|
||||||
public static Logger logger = new Logger("SocketServer");
|
public static Logger logger = new Logger("SocketServer");
|
||||||
public static final int maxTasksPerSession = 100;
|
public static final int maxTasksPerSession = 100;
|
||||||
private static boolean serverRunning = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increase this every time a breaking change to the server communication is done.
|
* Increase this every time a breaking change to the server communication is done.
|
||||||
@@ -46,17 +45,12 @@ public class SocketServer extends WebSocketServer {
|
|||||||
super(new InetSocketAddress(port));
|
super(new InetSocketAddress(port));
|
||||||
this.setConnectionLostTimeout(30);
|
this.setConnectionLostTimeout(30);
|
||||||
|
|
||||||
serverRunning = true;
|
|
||||||
// add a shutdown hook to close all connections when the process ends or is stopped by a SIGINT signal
|
// add a shutdown hook to close all connections when the process ends or is stopped by a SIGINT signal
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(this::onShutdown));
|
Runtime.getRuntime().addShutdownHook(new Thread(this::onShutdown));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isServerRunning() {
|
|
||||||
return serverRunning;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onShutdown() {
|
private void onShutdown() {
|
||||||
serverRunning = false;
|
|
||||||
try {
|
try {
|
||||||
for (var webSocket : this.getConnections()) {
|
for (var webSocket : this.getConnections()) {
|
||||||
this.sendError(webSocket, "Sorry, i am shutting down. You are now on your own, good Luck!", true);
|
this.sendError(webSocket, "Sorry, i am shutting down. You are now on your own, good Luck!", true);
|
||||||
@@ -91,7 +85,7 @@ public class SocketServer extends WebSocketServer {
|
|||||||
// wait 10 seconds for the client to send a task and close the connection if nothing has been received until then
|
// wait 10 seconds for the client to send a task and close the connection if nothing has been received until then
|
||||||
final int secondsUntilTimeout = 10;
|
final int secondsUntilTimeout = 10;
|
||||||
timeoutExecutor.schedule(() -> {
|
timeoutExecutor.schedule(() -> {
|
||||||
if (webSocket.<SocketData>getAttachment().totalTasks.get() > 0 || !webSocket.isOpen()) {
|
if (webSocket.<SocketData>getAttachment().unhandledTasks.get() == 0 || !webSocket.isOpen()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendMessage(webSocket, "No task received after " + secondsUntilTimeout + " seconds. Closing connection...");
|
sendMessage(webSocket, "No task received after " + secondsUntilTimeout + " seconds. Closing connection...");
|
||||||
|
|||||||
@@ -37,10 +37,6 @@ public class Constraint<A extends IConstraintElement> extends HashSet<A> impleme
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint(int initialCapacity) {
|
|
||||||
super(initialCapacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Constraint(boolean isInherited, boolean isImplemented) {
|
public Constraint(boolean isInherited, boolean isImplemented) {
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
this.isImplemented = isImplemented;
|
this.isImplemented = isImplemented;
|
||||||
@@ -81,14 +77,6 @@ public class Constraint<A extends IConstraintElement> extends HashSet<A> impleme
|
|||||||
methodSignatureConstraint = c;
|
methodSignatureConstraint = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <B extends IConstraintElement> Constraint<B> createdMapped(Function<A,B> mapper) {
|
|
||||||
Constraint<B> result = new Constraint<>(this.size());
|
|
||||||
for (A element : this) {
|
|
||||||
result.add(mapper.apply(element));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + "\nisInherited = " + isInherited
|
return super.toString() + "\nisInherited = " + isInherited
|
||||||
+ " isOveridden = " + isImplemented
|
+ " isOveridden = " + isImplemented
|
||||||
|
|||||||
@@ -285,13 +285,8 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
// see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17
|
// see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17
|
||||||
// Expression muss zu Numeric Convertierbar sein. also von Numeric erben
|
// Expression muss zu Numeric Convertierbar sein. also von Numeric erben
|
||||||
Constraint<Pair> numeric;
|
Constraint<Pair> numeric;
|
||||||
HashSet<JavaClassName> classNames = TypeUnifyTaskHelper.getPresizedHashSet(info.getAvailableClasses().size());
|
|
||||||
for (var classEl : info.getAvailableClasses()) {
|
|
||||||
classNames.add(classEl.getClassName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// PL eingefuegt 2018-07-17
|
// PL eingefuegt 2018-07-17
|
||||||
if (classNames.contains(bytee.getName())) {
|
if (info.getAvailableClasses().stream().map(ClassOrInterface::getClassName).collect(Collectors.toCollection(HashSet::new)).contains(bytee.getName())) {
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
@@ -299,7 +294,7 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
// PL eingefuegt 2018-07-17
|
// PL eingefuegt 2018-07-17
|
||||||
if (classNames.contains(shortt.getName())) {
|
if (info.getAvailableClasses().stream().map(ClassOrInterface::getClassName).collect(Collectors.toCollection(HashSet::new)).contains(shortt.getName())) {
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), shortt, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.lexpr.getType(), shortt, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), shortt, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.rexpr.getType(), shortt, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
@@ -307,7 +302,7 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
// PL eingefuegt 2018-07-17
|
// PL eingefuegt 2018-07-17
|
||||||
if (classNames.contains(integer.getName())) {
|
if (info.getAvailableClasses().stream().map(ClassOrInterface::getClassName).collect(Collectors.toCollection(HashSet::new)).contains(integer.getName())) {
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
@@ -315,7 +310,7 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
// PL eingefuegt 2018-07-17
|
// PL eingefuegt 2018-07-17
|
||||||
if (classNames.contains(longg.getName())) {
|
if (info.getAvailableClasses().stream().map(ClassOrInterface::getClassName).collect(Collectors.toCollection(HashSet::new)).contains(longg.getName())) {
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
@@ -323,7 +318,7 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
// PL eingefuegt 2018-07-17
|
// PL eingefuegt 2018-07-17
|
||||||
if (classNames.contains(floatt.getName())) {
|
if (info.getAvailableClasses().stream().map(ClassOrInterface::getClassName).collect(Collectors.toCollection(HashSet::new)).contains(floatt.getName())) {
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
@@ -331,7 +326,7 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
// PL eingefuegt 2018-07-17
|
// PL eingefuegt 2018-07-17
|
||||||
if (classNames.contains(doublee.getName())) {
|
if (info.getAvailableClasses().stream().map(ClassOrInterface::getClassName).collect(Collectors.toCollection(HashSet::new)).contains(doublee.getName())) {
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.SMALLERDOT, loc(binary.getOffset())));
|
||||||
@@ -346,7 +341,7 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
|
|
||||||
if (binary.operation.equals(BinaryExpr.Operator.ADD)) {
|
if (binary.operation.equals(BinaryExpr.Operator.ADD)) {
|
||||||
// Dann kann der Ausdruck auch das aneinanderfügen zweier Strings sein: ("a" + "b") oder (1 + 2)
|
// Dann kann der Ausdruck auch das aneinanderfügen zweier Strings sein: ("a" + "b") oder (1 + 2)
|
||||||
if (classNames.contains(string.getName())) {
|
if (info.getAvailableClasses().stream().map(ClassOrInterface::getClassName).collect(Collectors.toCollection(HashSet::new)).contains(string.getName())) {
|
||||||
Constraint<Pair> stringConcat = new Constraint<>();
|
Constraint<Pair> stringConcat = new Constraint<>();
|
||||||
stringConcat.add(new Pair(binary.lexpr.getType(), string, PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
stringConcat.add(new Pair(binary.lexpr.getType(), string, PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
||||||
stringConcat.add(new Pair(binary.rexpr.getType(), string, PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
stringConcat.add(new Pair(binary.rexpr.getType(), string, PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ public class MartelliMontanariUnify implements IUnify {
|
|||||||
// SUBST - Rule
|
// SUBST - Rule
|
||||||
if(lhsType instanceof PlaceholderType) {
|
if(lhsType instanceof PlaceholderType) {
|
||||||
mgu.add((PlaceholderType) lhsType, rhsType);
|
mgu.add((PlaceholderType) lhsType, rhsType);
|
||||||
//PL 2018-04-01 nach checken, ob es richtig ist, dass keine Substitutionen uebergeben werden muessen.
|
//PL 2018-04-01 nach checken, ob es richtig ist, dass keine Substitutionen uebergeben werden muessen.
|
||||||
termsList.replaceAll(mgu::apply);
|
termsList = termsList.stream().map(x -> mgu.apply(x)).collect(Collectors.toCollection(ArrayList::new));
|
||||||
idx = idx+1 == termsList.size() ? 0 : idx+1;
|
idx = idx+1 == termsList.size() ? 0 : idx+1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -653,13 +652,12 @@ public class RuleSet implements IRuleSet{
|
|||||||
HashMap<UnifyType, Integer> typeMap = new HashMap<>(200);
|
HashMap<UnifyType, Integer> typeMap = new HashMap<>(200);
|
||||||
|
|
||||||
Stack<UnifyType> occuringTypes = new Stack<>();
|
Stack<UnifyType> occuringTypes = new Stack<>();
|
||||||
occuringTypes.ensureCapacity(pairs.size() * 3);
|
|
||||||
|
|
||||||
for(UnifyPair pair : pairs) {
|
for(UnifyPair pair : pairs) {
|
||||||
occuringTypes.push(pair.getLhsType());
|
occuringTypes.push(pair.getLhsType());
|
||||||
occuringTypes.push(pair.getRhsType());
|
occuringTypes.push(pair.getRhsType());
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!occuringTypes.isEmpty()) {
|
while(!occuringTypes.isEmpty()) {
|
||||||
UnifyType t1 = occuringTypes.pop();
|
UnifyType t1 = occuringTypes.pop();
|
||||||
if(!typeMap.containsKey(t1))
|
if(!typeMap.containsKey(t1))
|
||||||
@@ -671,9 +669,9 @@ public class RuleSet implements IRuleSet{
|
|||||||
if(t1 instanceof SuperType)
|
if(t1 instanceof SuperType)
|
||||||
occuringTypes.push(((SuperType) t1).getSuperedType());
|
occuringTypes.push(((SuperType) t1).getSuperedType());
|
||||||
else
|
else
|
||||||
t1.getTypeParams().forEach(occuringTypes::push);
|
t1.getTypeParams().forEach(x -> occuringTypes.push(x));
|
||||||
}
|
}
|
||||||
LinkedList<UnifyPair> result1 = new LinkedList<UnifyPair>(pairs);
|
Queue<UnifyPair> result1 = new LinkedList<UnifyPair>(pairs);
|
||||||
ArrayList<UnifyPair> result = new ArrayList<UnifyPair>();
|
ArrayList<UnifyPair> result = new ArrayList<UnifyPair>();
|
||||||
boolean applied = false;
|
boolean applied = false;
|
||||||
|
|
||||||
@@ -694,30 +692,19 @@ public class RuleSet implements IRuleSet{
|
|||||||
&& !((rhsType instanceof WildcardType) && ((WildcardType)rhsType).getWildcardedType().equals(lhsType))) //PL eigefuegt 2018-02-18
|
&& !((rhsType instanceof WildcardType) && ((WildcardType)rhsType).getWildcardedType().equals(lhsType))) //PL eigefuegt 2018-02-18
|
||||||
{
|
{
|
||||||
Unifier uni = new Unifier(lhsType, rhsType);
|
Unifier uni = new Unifier(lhsType, rhsType);
|
||||||
// apply unifier to result and result1 in place
|
result = result.stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(ArrayList::new));
|
||||||
result.replaceAll(p -> uni.apply(pair, p));
|
result1 = result1.stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(LinkedList::new));
|
||||||
ListIterator<UnifyPair> result1Iterator = result1.listIterator();
|
|
||||||
while (result1Iterator.hasNext()) {
|
|
||||||
UnifyPair x = result1Iterator.next();
|
|
||||||
result1Iterator.set(uni.apply(pair, x));
|
|
||||||
}
|
|
||||||
|
|
||||||
Function<? super Constraint<UnifyPair>,? extends Constraint<UnifyPair>> applyUni = b -> b.stream().map(
|
Function<? super Constraint<UnifyPair>,? extends Constraint<UnifyPair>> applyUni = b -> b.stream().map(
|
||||||
x -> uni.apply(pair,x)).collect(Collectors.toCollection((b.getExtendConstraint() != null)
|
x -> uni.apply(pair,x)).collect(Collectors.toCollection((b.getExtendConstraint() != null)
|
||||||
? () -> new Constraint<UnifyPair>(
|
? () -> new Constraint<UnifyPair>(
|
||||||
b.isInherited(),
|
b.isInherited(),
|
||||||
b.isImplemented(),
|
b.isImplemented(),
|
||||||
b.getExtendConstraint().createdMapped(x -> uni.apply(pair,x)),
|
b.getExtendConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(Constraint::new)),
|
||||||
b.getmethodSignatureConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(HashSet::new)))
|
b.getmethodSignatureConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(HashSet::new)))
|
||||||
: () -> new Constraint<UnifyPair>(b.isInherited(), b.isImplemented())
|
: () -> new Constraint<UnifyPair>(b.isInherited(), b.isImplemented())
|
||||||
));
|
));
|
||||||
oderConstraints.replaceAll(oc -> {
|
oderConstraints.replaceAll(oc -> oc.stream().map(applyUni).collect(Collectors.toCollection(HashSet::new)));
|
||||||
HashSet<Constraint<UnifyPair>> mapped = new HashSet<>(oc.size());
|
|
||||||
for (var element : oc) {
|
|
||||||
mapped.add(applyUni.apply(element));
|
|
||||||
}
|
|
||||||
return mapped;
|
|
||||||
});
|
|
||||||
/*
|
/*
|
||||||
oderConstraints = oderConstraints.stream().map(
|
oderConstraints = oderConstraints.stream().map(
|
||||||
a -> a.stream().map(applyUni
|
a -> a.stream().map(applyUni
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.RecursiveTask;
|
import java.util.concurrent.RecursiveTask;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.BinaryOperator;
|
import java.util.function.BinaryOperator;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -318,7 +316,14 @@ public class TypeUnifyTask extends RecursiveTask<CompletableFuture<Set<Set<Unify
|
|||||||
/*
|
/*
|
||||||
* Occurs-Check durchfuehren
|
* Occurs-Check durchfuehren
|
||||||
*/
|
*/
|
||||||
Set<UnifyPair> ocurrPairs = TypeUnifyTaskHelper.occursCheck(eq);
|
Set<UnifyPair> ocurrPairs = eq.stream().filter(x -> {
|
||||||
|
UnifyType lhs, rhs;
|
||||||
|
return (lhs = x.getLhsType()) instanceof PlaceholderType
|
||||||
|
&& !((rhs = x.getRhsType()) instanceof PlaceholderType)
|
||||||
|
&& rhs.getTypeParams().occurs((PlaceholderType) lhs);
|
||||||
|
})
|
||||||
|
.peek(UnifyPair::setUndefinedPair)
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
Set<UnifyPair> finalOcurrPairs = ocurrPairs;
|
Set<UnifyPair> finalOcurrPairs = ocurrPairs;
|
||||||
context.logger().debug(() -> "ocurrPairs: " + finalOcurrPairs);
|
context.logger().debug(() -> "ocurrPairs: " + finalOcurrPairs);
|
||||||
@@ -342,7 +347,14 @@ public class TypeUnifyTask extends RecursiveTask<CompletableFuture<Set<Set<Unify
|
|||||||
/* In commit dfd91b5f8b7fca1cb5f302eec4b0ba3330271c9b eingefuegt ANFANG */
|
/* In commit dfd91b5f8b7fca1cb5f302eec4b0ba3330271c9b eingefuegt ANFANG */
|
||||||
Set<UnifyPair> occurcheck = new HashSet<>(eq0);
|
Set<UnifyPair> occurcheck = new HashSet<>(eq0);
|
||||||
occurcheck.removeAll(eq0Prime);
|
occurcheck.removeAll(eq0Prime);
|
||||||
ocurrPairs = TypeUnifyTaskHelper.occursCheck(occurcheck);
|
ocurrPairs = occurcheck.stream().filter(x -> {
|
||||||
|
UnifyType lhs, rhs;
|
||||||
|
return (lhs = x.getLhsType()) instanceof PlaceholderType
|
||||||
|
&& !((rhs = x.getRhsType()) instanceof PlaceholderType)
|
||||||
|
&& rhs.getTypeParams().occurs((PlaceholderType) lhs);
|
||||||
|
})
|
||||||
|
.peek(UnifyPair::setUndefinedPair)
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
Set<UnifyPair> finalOcurrPairs1 = ocurrPairs;
|
Set<UnifyPair> finalOcurrPairs1 = ocurrPairs;
|
||||||
context.logger().debug(() -> "ocurrPairs: " + finalOcurrPairs1);
|
context.logger().debug(() -> "ocurrPairs: " + finalOcurrPairs1);
|
||||||
if (!ocurrPairs.isEmpty()) {
|
if (!ocurrPairs.isEmpty()) {
|
||||||
@@ -758,7 +770,6 @@ public class TypeUnifyTask extends RecursiveTask<CompletableFuture<Set<Set<Unify
|
|||||||
// - fork results : forkResults (frueher "add_res")
|
// - fork results : forkResults (frueher "add_res")
|
||||||
CompletableFuture<Tuple<Set<Set<UnifyPair>>, Set<Set<Set<UnifyPair>>>>> parallelResultDataFuture;
|
CompletableFuture<Tuple<Set<Set<UnifyPair>>, Set<Set<Set<UnifyPair>>>>> parallelResultDataFuture;
|
||||||
|
|
||||||
|
|
||||||
if (parallel) {
|
if (parallel) {
|
||||||
parallelResultDataFuture = varianceCase.computeParallel(
|
parallelResultDataFuture = varianceCase.computeParallel(
|
||||||
elems, eq, oderConstraints, fc, rekTiefe, methodSignatureConstraint,
|
elems, eq, oderConstraints, fc, rekTiefe, methodSignatureConstraint,
|
||||||
|
|||||||
@@ -186,24 +186,6 @@ public class TypeUnifyTaskHelper {
|
|||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Set<UnifyPair> occursCheck(final Set<UnifyPair> eq) {
|
|
||||||
Set<UnifyPair> ocurrPairs = new HashSet<>(eq.size());
|
|
||||||
for (UnifyPair x : eq) {
|
|
||||||
UnifyType lhs = x.getLhsType();
|
|
||||||
UnifyType rhs = x.getRhsType();
|
|
||||||
if (lhs instanceof PlaceholderType lhsPlaceholder &&
|
|
||||||
!(rhs instanceof PlaceholderType) &&
|
|
||||||
rhs.getTypeParams().occurs(lhsPlaceholder))
|
|
||||||
{
|
|
||||||
x.setUndefinedPair();
|
|
||||||
ocurrPairs.add(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ocurrPairs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static <T> HashSet<T> getPresizedHashSet(int minElements) {
|
public static <T> HashSet<T> getPresizedHashSet(int minElements) {
|
||||||
if (minElements < 16) return new HashSet<>();
|
if (minElements < 16) return new HashSet<>();
|
||||||
// HashSet and HashMap will resize at 75% load, so we account for that by multiplying with 1.5
|
// HashSet and HashMap will resize at 75% load, so we account for that by multiplying with 1.5
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class UnifyResultModel {
|
|||||||
this.fc = fc;
|
this.fc = fc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UnifyResultListener> listeners = new ArrayList<>();
|
private final List<UnifyResultListener> listeners = new ArrayList<>();
|
||||||
|
|
||||||
public void addUnifyResultListener(UnifyResultListener listenerToAdd) {
|
public void addUnifyResultListener(UnifyResultListener listenerToAdd) {
|
||||||
listeners.add(listenerToAdd);
|
listeners.add(listenerToAdd);
|
||||||
@@ -35,25 +35,31 @@ public class UnifyResultModel {
|
|||||||
public void removeUnifyResultListener(UnifyResultListener listenerToRemove) {
|
public void removeUnifyResultListener(UnifyResultListener listenerToRemove) {
|
||||||
listeners.remove(listenerToRemove);
|
listeners.remove(listenerToRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notify(Set<Set<UnifyPair>> eqPrimePrimeSet, UnifyContext context) {
|
private synchronized void announceResult(UnifyResultEvent event) {
|
||||||
Set<Set<UnifyPair>> eqPrimePrimeSetRet = eqPrimePrimeSet.stream().map(x -> {
|
|
||||||
Optional<Set<UnifyPair>> res = new RuleSet(context.placeholderRegistry()).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(context).applyTypeUnificationRules(res.get(), fc);
|
|
||||||
}
|
|
||||||
else return x; //wenn nichts veraendert wurde wird x zurueckgegeben
|
|
||||||
}).collect(Collectors.toCollection(HashSet::new));
|
|
||||||
List<ResultSet> newResult = eqPrimePrimeSetRet.stream().map(unifyPairs ->
|
|
||||||
new ResultSet(UnifyTypeFactory.convert(unifyPairs, de.dhbwstuttgart.typeinference.constraints.Pair.generateTPHMap(cons), context.placeholderRegistry())))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
UnifyResultEvent evt = new UnifyResultEvent(newResult);
|
|
||||||
|
|
||||||
for (UnifyResultListener listener : listeners) {
|
for (UnifyResultListener listener : listeners) {
|
||||||
listener.onNewTypeResultFound(evt);
|
listener.onNewTypeResultFound(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void notify(Set<Set<UnifyPair>> eqPrimePrimeSet, UnifyContext context) {
|
||||||
|
context.executor().execute(() -> {
|
||||||
|
Set<Set<UnifyPair>> eqPrimePrimeSetRet = eqPrimePrimeSet.stream().map(x -> {
|
||||||
|
Optional<Set<UnifyPair>> res = new RuleSet(context.placeholderRegistry()).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(context).applyTypeUnificationRules(res.get(), fc);
|
||||||
|
}
|
||||||
|
else return x; //wenn nichts veraendert wurde wird x zurueckgegeben
|
||||||
|
}).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
List<ResultSet> newResult = eqPrimePrimeSetRet.stream().map(unifyPairs ->
|
||||||
|
new ResultSet(UnifyTypeFactory.convert(unifyPairs, de.dhbwstuttgart.typeinference.constraints.Pair.generateTPHMap(cons), context.placeholderRegistry())))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
UnifyResultEvent evt = new UnifyResultEvent(newResult);
|
||||||
|
|
||||||
|
this.announceResult(evt);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,66 +170,30 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
left.add(p2);
|
left.add(p2);
|
||||||
left.add(p4);
|
left.add(p4);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Set<UnifyPair> lefteq = new HashSet<>();
|
Set<UnifyPair> lefteq = left.stream()
|
||||||
Set<UnifyPair> leftle = new HashSet<>();
|
.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT))
|
||||||
Set<UnifyPair> leftlewc = new HashSet<>();
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
Set<UnifyPair> lefteqOder = new HashSet<>();
|
Set<UnifyPair> righteq = right.stream()
|
||||||
Set<UnifyPair> lefteqRet = new HashSet<>();
|
.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT))
|
||||||
Set<UnifyPair> leftleOder = new HashSet<>();
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
for (var x : left) {
|
Set<UnifyPair> leftle = left.stream()
|
||||||
boolean isLeftPlaceholder = x.getLhsType() instanceof PlaceholderType;
|
.filter(x -> ((x.getLhsType() instanceof PlaceholderType || x.getRhsType() instanceof PlaceholderType)
|
||||||
boolean isRightPlaceholder = x.getRhsType() instanceof PlaceholderType;
|
&& x.getPairOp() == PairOperator.SMALLERDOT))
|
||||||
boolean hasPlaceholder = isLeftPlaceholder || isRightPlaceholder;
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
Set<UnifyPair> rightle = right.stream()
|
||||||
if (isLeftPlaceholder && x.getPairOp() == PairOperator.EQUALSDOT) lefteq.add(x);
|
.filter(x -> ((x.getLhsType() instanceof PlaceholderType || x.getRhsType() instanceof PlaceholderType)
|
||||||
if (hasPlaceholder && x.getPairOp() == PairOperator.SMALLERDOT) leftle.add(x);
|
&& x.getPairOp() == PairOperator.SMALLERDOT))
|
||||||
if (hasPlaceholder && x.getPairOp() == PairOperator.SMALLERDOTWC) leftlewc.add(x);
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
Set<UnifyPair> leftlewc = left.stream()
|
||||||
UnifyPair y = x.getGroundBasePair();
|
.filter(x -> ((x.getLhsType() instanceof PlaceholderType || x.getRhsType() instanceof PlaceholderType)
|
||||||
boolean isBasePairLeftPlaceholder = y.getLhsType() instanceof PlaceholderType;
|
&& x.getPairOp() == PairOperator.SMALLERDOTWC))
|
||||||
boolean isBasePairRightPlaceholder = y.getRhsType() instanceof PlaceholderType;
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
if (isBasePairLeftPlaceholder && !isBasePairRightPlaceholder && x.getPairOp() == PairOperator.EQUALSDOT) {
|
Set<UnifyPair> rightlewc = right.stream()
|
||||||
lefteqOder.add(x);
|
.filter(x -> ((x.getLhsType() instanceof PlaceholderType || x.getRhsType() instanceof PlaceholderType)
|
||||||
}
|
&& x.getPairOp() == PairOperator.SMALLERDOTWC))
|
||||||
else if (isBasePairRightPlaceholder && ((PlaceholderType)y.getRhsType()).getOrCons() == (byte)-1) {
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
lefteqRet.add(x);
|
|
||||||
}
|
|
||||||
else if (x.getPairOp() == PairOperator.SMALLERDOT) {
|
|
||||||
leftleOder.add(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Set<UnifyPair> righteq = new HashSet<>();
|
|
||||||
Set<UnifyPair> rightle = new HashSet<>();
|
|
||||||
Set<UnifyPair> rightlewc = new HashSet<>();
|
|
||||||
Set<UnifyPair> righteqOder = new HashSet<>();
|
|
||||||
Set<UnifyPair> righteqRet = new HashSet<>();
|
|
||||||
Set<UnifyPair> rightleOder = new HashSet<>();
|
|
||||||
for (var x : right) {
|
|
||||||
boolean isLeftPlaceholder = x.getLhsType() instanceof PlaceholderType;
|
|
||||||
boolean isRightPlaceholder = x.getRhsType() instanceof PlaceholderType;
|
|
||||||
boolean hasPlaceholder = isLeftPlaceholder || isRightPlaceholder;
|
|
||||||
|
|
||||||
if (isLeftPlaceholder && x.getPairOp() == PairOperator.EQUALSDOT) righteq.add(x);
|
|
||||||
if (hasPlaceholder && x.getPairOp() == PairOperator.SMALLERDOT) rightle.add(x);
|
|
||||||
if (hasPlaceholder && x.getPairOp() == PairOperator.SMALLERDOTWC) rightlewc.add(x);
|
|
||||||
|
|
||||||
UnifyPair y = x.getGroundBasePair();
|
|
||||||
boolean isBasePairLeftPlaceholder = y.getLhsType() instanceof PlaceholderType;
|
|
||||||
boolean isBasePairRightPlaceholder = y.getRhsType() instanceof PlaceholderType;
|
|
||||||
if (isBasePairLeftPlaceholder && !isBasePairRightPlaceholder && x.getPairOp() == PairOperator.EQUALSDOT) {
|
|
||||||
righteqOder.add(x);
|
|
||||||
}
|
|
||||||
else if (isBasePairRightPlaceholder && ((PlaceholderType)y.getRhsType()).getOrCons() == (byte)-1) {
|
|
||||||
righteqRet.add(x);
|
|
||||||
}
|
|
||||||
else if (x.getPairOp() == PairOperator.SMALLERDOT) {
|
|
||||||
rightleOder.add(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//context.logger().info(left.toString());
|
//context.logger().info(left.toString());
|
||||||
//Fall 2
|
//Fall 2
|
||||||
//if (lefteq.iterator().next().getLhsType().getName().equals("AJO")) {
|
//if (lefteq.iterator().next().getLhsType().getName().equals("AJO")) {
|
||||||
@@ -237,14 +201,54 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
//ODER-CONSTRAINT
|
//ODER-CONSTRAINT
|
||||||
// Set<UnifyPair> leftBase = left.stream().map(x -> x.getGroundBasePair()).collect(Collectors.toCollection(HashSet::new));
|
Set<UnifyPair> leftBase = left.stream().map(x -> x.getGroundBasePair()).collect(Collectors.toCollection(HashSet::new));
|
||||||
// Set<UnifyPair> rightBase = right.stream().map(x -> x.getGroundBasePair()).collect(Collectors.toCollection(HashSet::new));
|
Set<UnifyPair> rightBase = right.stream().map(x -> x.getGroundBasePair()).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
|
Set<UnifyPair> lefteqOder = left.stream()
|
||||||
|
.filter(x -> { UnifyPair y = x.getGroundBasePair();
|
||||||
|
/*try {
|
||||||
|
((FiniteClosure)fc).logFile.write("leftBase: " + leftBase.toString() +"\n");
|
||||||
|
((FiniteClosure)fc).logFile.write("rightBase: " + rightBase.toString() +"\n\n");
|
||||||
|
((FiniteClosure)fc).logFile.write("left: " + left.toString() +"\n");
|
||||||
|
((FiniteClosure)fc).logFile.write("right: " + right.toString() +"\n\n");
|
||||||
|
((FiniteClosure)fc).logFile.write("y: " + y.toString() +"\n");
|
||||||
|
((FiniteClosure)fc).logFile.write("y.getLhsType() : " + y.getLhsType() .toString() +"\n\n");
|
||||||
|
((FiniteClosure)fc).logFile.write("y.getRhsType(): " + y.getRhsType().toString() +"\n");
|
||||||
|
((FiniteClosure)fc).logFile.write("x.getPairOp(): " + x.getPairOp().toString() +"\n\n");
|
||||||
|
}
|
||||||
|
catch (IOException ie) {
|
||||||
|
} */
|
||||||
|
return (y.getLhsType() instanceof PlaceholderType &&
|
||||||
|
!(y.getRhsType() instanceof PlaceholderType) &&
|
||||||
|
x.getPairOp() == PairOperator.EQUALSDOT);})
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
left.removeAll(lefteqOder);
|
left.removeAll(lefteqOder);
|
||||||
left.removeAll(lefteqRet);
|
Set<UnifyPair> righteqOder = right.stream()
|
||||||
|
.filter(x -> { UnifyPair y = x.getGroundBasePair();
|
||||||
|
return (y.getLhsType() instanceof PlaceholderType &&
|
||||||
|
!(y.getRhsType() instanceof PlaceholderType) &&
|
||||||
|
x.getPairOp() == PairOperator.EQUALSDOT);})
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
right.removeAll(righteqOder);
|
right.removeAll(righteqOder);
|
||||||
|
Set<UnifyPair> lefteqRet = left.stream()
|
||||||
|
.filter(x -> { UnifyPair y = x.getGroundBasePair();
|
||||||
|
return (y.getRhsType() instanceof PlaceholderType &&
|
||||||
|
((PlaceholderType)y.getRhsType()).getOrCons() == (byte)-1);})
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
left.removeAll(lefteqRet);
|
||||||
|
Set<UnifyPair> righteqRet = right.stream()
|
||||||
|
.filter(x -> { UnifyPair y = x.getGroundBasePair();
|
||||||
|
return (y.getRhsType() instanceof PlaceholderType &&
|
||||||
|
((PlaceholderType)y.getRhsType()).getOrCons() == (byte)-1);})
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
right.removeAll(righteqRet);
|
right.removeAll(righteqRet);
|
||||||
|
Set<UnifyPair> leftleOder = left.stream()
|
||||||
|
.filter(x -> (x.getPairOp() == PairOperator.SMALLERDOT))
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
Set<UnifyPair> rightleOder = right.stream()
|
||||||
|
.filter(x -> (x.getPairOp() == PairOperator.SMALLERDOT))
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
try {
|
try {
|
||||||
@@ -269,43 +273,59 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
int compareEq;
|
int compareEq;
|
||||||
if (lefteqOder.size() == 1 && righteqOder.size() == 1 && lefteqRet.size() == 1 && righteqRet.size() == 1) {
|
if (lefteqOder.size() == 1 && righteqOder.size() == 1 && lefteqRet.size() == 1 && righteqRet.size() == 1) {
|
||||||
Match m = new Match();
|
Match m = new Match();
|
||||||
compareEq = compareEq(lefteqOder.iterator().next().getGroundBasePair(), righteqOder.iterator().next().getGroundBasePair());
|
if ((compareEq = compareEq(lefteqOder.iterator().next().getGroundBasePair(), righteqOder.iterator().next().getGroundBasePair())) == -1) {
|
||||||
|
ArrayList<UnifyPair> matchList =
|
||||||
if (compareEq == -1) {
|
rightleOder.stream().map(x -> {
|
||||||
ArrayList<UnifyPair> matchList =
|
UnifyPair leftElem = leftleOder.stream()
|
||||||
rightleOder.stream().map(x -> {
|
|
||||||
UnifyPair leftElem = leftleOder.stream()
|
|
||||||
.filter(y -> y.getGroundBasePair().getLhsType().equals(x.getGroundBasePair().getLhsType()))
|
.filter(y -> y.getGroundBasePair().getLhsType().equals(x.getGroundBasePair().getLhsType()))
|
||||||
.findAny().orElseThrow();
|
.findAny().get();
|
||||||
return new UnifyPair(x.getRhsType(), leftElem.getRhsType(), PairOperator.EQUALSDOT);}
|
return new UnifyPair(x.getRhsType(), leftElem.getRhsType(), PairOperator.EQUALSDOT);})
|
||||||
)
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
if (m.match(matchList).isPresent()) {
|
||||||
|
//try { ((FiniteClosure)fc).logFile.write("result1: -1 \n\n"); } catch (IOException ie) {}
|
||||||
return (m.match(matchList).isPresent()) ? -1 : 0;
|
return -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//try { ((FiniteClosure)fc).logFile.write("result1: 0 \n\n"); } catch (IOException ie) {}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} else if (compareEq == 1) {
|
} else if (compareEq == 1) {
|
||||||
ArrayList<UnifyPair> matchList =
|
ArrayList<UnifyPair> matchList =
|
||||||
leftleOder.stream().map(x -> {
|
leftleOder.stream().map(x -> {
|
||||||
UnifyPair rightElem = rightleOder.stream()
|
UnifyPair rightElem = rightleOder.stream()
|
||||||
.filter(y -> y.getGroundBasePair().getLhsType().equals(x.getGroundBasePair().getLhsType()))
|
.filter(y ->
|
||||||
.findAny().orElseThrow();
|
y.getGroundBasePair().getLhsType().equals(x.getGroundBasePair().getLhsType()))
|
||||||
return new UnifyPair(x.getRhsType(), rightElem.getRhsType(), PairOperator.EQUALSDOT);}
|
.findAny().get();
|
||||||
)
|
return new UnifyPair(x.getRhsType(), rightElem.getRhsType(), PairOperator.EQUALSDOT);})
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
return (m.match(matchList).isPresent()) ? 1 : 0;
|
if (m.match(matchList).isPresent()) {
|
||||||
|
//try { ((FiniteClosure)fc).logFile.write("result2: 1 \n\n"); } catch (IOException ie) {}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//try { ((FiniteClosure)fc).logFile.write("result2: 0 \n\n"); } catch (IOException ie) {}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
((FiniteClosure)fc).logFile.write("leftBase: " + leftBase.toString() +"\n");
|
synchronized(this) {
|
||||||
((FiniteClosure)fc).logFile.write("rightBase: " + rightBase.toString() +"\n\n");
|
try {
|
||||||
((FiniteClosure)fc).logFile.write("left: " + left.toString() +"\n");
|
((FiniteClosure)fc).logFile.write("leftBase: " + leftBase.toString() +"\n");
|
||||||
((FiniteClosure)fc).logFile.write("right: " + right.toString() +"\n\n");
|
((FiniteClosure)fc).logFile.write("rightBase: " + rightBase.toString() +"\n\n");
|
||||||
((FiniteClosure)fc).logFile.write("lefteqOder: " + lefteqOder.toString() +"\n");
|
((FiniteClosure)fc).logFile.write("left: " + left.toString() +"\n");
|
||||||
((FiniteClosure)fc).logFile.write("righteqOder: " + righteqOder.toString() +"\n\n");
|
((FiniteClosure)fc).logFile.write("right: " + right.toString() +"\n\n");
|
||||||
((FiniteClosure)fc).logFile.write("lefteqRet: " + lefteqRet.toString() +"\n");
|
((FiniteClosure)fc).logFile.write("lefteqOder: " + lefteqOder.toString() +"\n");
|
||||||
((FiniteClosure)fc).logFile.write("righteqRet: " + righteqRet.toString() +"\n\n");
|
((FiniteClosure)fc).logFile.write("righteqOder: " + righteqOder.toString() +"\n\n");
|
||||||
((FiniteClosure)fc).logFile.write("leftleOder: " + leftleOder.toString() +"\n");
|
((FiniteClosure)fc).logFile.write("lefteqRet: " + lefteqRet.toString() +"\n");
|
||||||
((FiniteClosure)fc).logFile.write("rightleOder: " + rightleOder.toString() +"\n\n");
|
((FiniteClosure)fc).logFile.write("righteqRet: " + righteqRet.toString() +"\n\n");
|
||||||
((FiniteClosure)fc).logFile.write("result3: 0 \n\n");
|
((FiniteClosure)fc).logFile.write("leftleOder: " + leftleOder.toString() +"\n");
|
||||||
((FiniteClosure)fc).logFile.flush();
|
((FiniteClosure)fc).logFile.write("rightleOder: " + rightleOder.toString() +"\n\n");
|
||||||
|
((FiniteClosure)fc).logFile.write("result3: 0 \n\n");
|
||||||
|
((FiniteClosure)fc).logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException ie) {
|
||||||
|
}
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -372,12 +392,12 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
//TODO: Hier wird bei Wildcards nicht das richtige compare aufgerufen PL 18-04-20
|
//TODO: Hier wird bei Wildcards nicht das richtige compare aufgerufen PL 18-04-20
|
||||||
Pair<Integer, Set<UnifyPair>> int_Unifier = compare(lseq.getRhsType(), rseq.getRhsType());
|
Pair<Integer, Set<UnifyPair>> int_Unifier = compare(lseq.getRhsType(), rseq.getRhsType());
|
||||||
Unifier uni = new Unifier();
|
Unifier uni = new Unifier();
|
||||||
int_Unifier.getValue().orElseThrow().forEach(x -> uni.add((PlaceholderType) x.getLhsType(), x.getRhsType()));
|
int_Unifier.getValue().get().forEach(x -> uni.add((PlaceholderType) x.getLhsType(), x.getRhsType()));
|
||||||
if (!lseq.getRhsType().getName().equals(rseq.getRhsType().getName())
|
if (!lseq.getRhsType().getName().equals(rseq.getRhsType().getName())
|
||||||
|| leftlewc.isEmpty() || rightlewc.isEmpty()) return int_Unifier.getKey();
|
|| leftlewc.isEmpty() || rightlewc.isEmpty()) return int_Unifier.getKey();
|
||||||
else {
|
else {
|
||||||
Set <UnifyPair> lsleuni = leftlewc.stream().map(uni::apply).collect(Collectors.toCollection(HashSet::new));
|
Set <UnifyPair> lsleuni = leftlewc.stream().map(x -> uni.apply(x)).collect(Collectors.toCollection(HashSet::new));
|
||||||
Set <UnifyPair> rsleuni = rightlewc.stream().map(uni::apply).collect(Collectors.toCollection(HashSet::new));
|
Set <UnifyPair> rsleuni = rightlewc.stream().map(x -> uni.apply(x)).collect(Collectors.toCollection(HashSet::new));
|
||||||
BinaryOperator<HashMap<UnifyType,UnifyPair>> combiner = (x,y) -> { x.putAll(y); return x;};
|
BinaryOperator<HashMap<UnifyType,UnifyPair>> combiner = (x,y) -> { x.putAll(y); return x;};
|
||||||
|
|
||||||
HashMap<UnifyType,UnifyPair> hm;
|
HashMap<UnifyType,UnifyPair> hm;
|
||||||
@@ -398,7 +418,6 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!leftlewc.isEmpty()) {
|
if (!leftlewc.isEmpty()) {
|
||||||
/*
|
|
||||||
Set<UnifyPair> subst;
|
Set<UnifyPair> subst;
|
||||||
subst = leftlewc.stream().map(x -> {
|
subst = leftlewc.stream().map(x -> {
|
||||||
if (x.getLhsType() instanceof PlaceholderType) {
|
if (x.getLhsType() instanceof PlaceholderType) {
|
||||||
@@ -407,7 +426,6 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
else {
|
else {
|
||||||
return new UnifyPair(x.getRhsType(), x.getLhsType(), PairOperator.EQUALSDOT);
|
return new UnifyPair(x.getRhsType(), x.getLhsType(), PairOperator.EQUALSDOT);
|
||||||
}}).collect(Collectors.toCollection(HashSet::new));
|
}}).collect(Collectors.toCollection(HashSet::new));
|
||||||
*/
|
|
||||||
Unifier uni = new Unifier();
|
Unifier uni = new Unifier();
|
||||||
lseq = uni.apply(lseq);
|
lseq = uni.apply(lseq);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,11 +106,7 @@ public class UnifyPair implements IConstraintElement, ISerializableData {
|
|||||||
|
|
||||||
public SourceLoc getLocation() {
|
public SourceLoc getLocation() {
|
||||||
if (location != null) return location;
|
if (location != null) return location;
|
||||||
else if (basePair != null) {
|
else if (basePair != null) return basePair.getLocation();
|
||||||
SourceLoc baseLocation = basePair.getLocation();
|
|
||||||
location = baseLocation;
|
|
||||||
return baseLocation;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,11 @@ package de.dhbwstuttgart.util;
|
|||||||
|
|
||||||
import com.diogonunes.jcolor.Attribute;
|
import com.diogonunes.jcolor.Attribute;
|
||||||
import de.dhbwstuttgart.core.ConsoleInterface;
|
import de.dhbwstuttgart.core.ConsoleInterface;
|
||||||
import de.dhbwstuttgart.server.SocketServer;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@@ -23,7 +20,6 @@ public class Logger {
|
|||||||
protected final String prefix;
|
protected final String prefix;
|
||||||
|
|
||||||
public static Logger NULL_LOGGER = new NullLogger();
|
public static Logger NULL_LOGGER = new NullLogger();
|
||||||
private static DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
|
|
||||||
public Logger() {
|
public Logger() {
|
||||||
this(null, "");
|
this(null, "");
|
||||||
@@ -88,14 +84,6 @@ public class Logger {
|
|||||||
*/
|
*/
|
||||||
protected void print(String s, LogLevel logLevel) {
|
protected void print(String s, LogLevel logLevel) {
|
||||||
String coloredPrefix = this.getPrefix(logLevel);
|
String coloredPrefix = this.getPrefix(logLevel);
|
||||||
|
|
||||||
// if we are running the server, prepend the timestamp
|
|
||||||
if(SocketServer.isServerRunning()) {
|
|
||||||
String timestamp = LocalDateTime.now().format(timeFormatter);
|
|
||||||
coloredPrefix = "[" + timestamp + "] " + coloredPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
// output to the correct output-stream
|
|
||||||
if (logLevel.isHigherOrEqualTo(LogLevel.ERROR)) {
|
if (logLevel.isHigherOrEqualTo(LogLevel.ERROR)) {
|
||||||
System.out.println(coloredPrefix + s);
|
System.out.println(coloredPrefix + s);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user