forked from i21017/JavaCompilerCore
Compare commits
10 Commits
e8335715fb
...
c5c31bc372
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5c31bc372 | ||
|
|
130c491ac0 | ||
|
|
9f9b264ac4 | ||
|
|
1393db05c2 | ||
|
|
03042fab97 | ||
|
|
93e1a8787c | ||
|
|
0129d7540f | ||
|
|
7ea8337aee | ||
|
|
8d5b4ff54f | ||
|
|
28458d405f |
@@ -9,7 +9,7 @@ mkdir $TDIR
|
|||||||
|
|
||||||
cd $TDIR
|
cd $TDIR
|
||||||
git clone $REPO .
|
git clone $REPO .
|
||||||
git checkout feat/unify-server
|
git checkout feat/unify-server-0variance
|
||||||
# git checkout dad468368b86bdd5a3d3b2754b17617cee0a9107 # 1:55
|
# git checkout dad468368b86bdd5a3d3b2754b17617cee0a9107 # 1:55
|
||||||
# git checkout a0c11b60e8c9d7addcbe0d3a09c9ce2924e9d5c0 # 2:25
|
# git checkout a0c11b60e8c9d7addcbe0d3a09c9ce2924e9d5c0 # 2:25
|
||||||
# git checkout 4cddf73e6d6c9116d3e1705c4b27a8e7f18d80c3 # 2:27
|
# git checkout 4cddf73e6d6c9116d3e1705c4b27a8e7f18d80c3 # 2:27
|
||||||
@@ -20,11 +20,10 @@ git checkout feat/unify-server
|
|||||||
|
|
||||||
date "+%Y.%m.%d %H:%M:%S"
|
date "+%Y.%m.%d %H:%M:%S"
|
||||||
|
|
||||||
# mvn clean compile -DskipTests package
|
mkdir testOut
|
||||||
## prefix each stderr line with " | "
|
|
||||||
# exec 2> >(trap "" INT TERM; sed 's/^/ | /' >&2)
|
#mvn clean compile -DskipTests package
|
||||||
# echo -e "\nMatrix test:\n |"
|
#time java -jar target/JavaTXcompiler-0.1-jar-with-dependencies.jar resources/bytecode/javFiles/Merge.jav -vv -d testOut;
|
||||||
# time java -jar target/JavaTXcompiler-0.1-jar-with-dependencies.jar resources/bytecode/javFiles/Matrix.jav >/dev/null;
|
|
||||||
|
|
||||||
|
|
||||||
mvn clean compile test
|
mvn clean compile test
|
||||||
|
|||||||
7
pom.xml
7
pom.xml
@@ -49,11 +49,6 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
|||||||
<artifactId>Java-WebSocket</artifactId>
|
<artifactId>Java-WebSocket</artifactId>
|
||||||
<version>1.5.2</version>
|
<version>1.5.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-simple</artifactId>
|
|
||||||
<version>1.7.25</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
@@ -158,4 +153,4 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
|||||||
<url>file:///${project.basedir}/maven-repository/</url>
|
<url>file:///${project.basedir}/maven-repository/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||||
import de.dhbwstuttgart.util.Logger;
|
import de.dhbwstuttgart.util.Logger;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
@@ -39,9 +38,13 @@ public class SocketClient extends WebSocketClient {
|
|||||||
private UnifyResultPacket unifyResultPacket;
|
private UnifyResultPacket unifyResultPacket;
|
||||||
|
|
||||||
public SocketClient(String url) {
|
public SocketClient(String url) {
|
||||||
super(URI.create(url), Map.of(
|
super(
|
||||||
"packetProtocolVersion", SocketServer.packetProtocolVersion
|
URI.create(url), // target url
|
||||||
));
|
SocketServer.perMessageDeflateDraft, // enable compression
|
||||||
|
Map.of( // headers
|
||||||
|
"packetProtocolVersion", SocketServer.packetProtocolVersion
|
||||||
|
)
|
||||||
|
);
|
||||||
// make sure, the url is in a valid format
|
// make sure, the url is in a valid format
|
||||||
final String regex = "^wss?://(\\w+(\\.\\w+)?)*:(\\d+)$";
|
final String regex = "^wss?://(\\w+(\\.\\w+)?)*:(\\d+)$";
|
||||||
final Matcher matcher = Pattern.compile(regex).matcher(url);
|
final Matcher matcher = Pattern.compile(regex).matcher(url);
|
||||||
@@ -51,7 +54,7 @@ public class SocketClient extends WebSocketClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SocketClient(String host, int port, boolean secure) {
|
public SocketClient(String host, int port, boolean secure) {
|
||||||
super(URI.create(String.format("%s://%s:%d/", secure ? "wss" : "ws", host, port)));
|
this(String.format("%s://%s:%d/", secure ? "wss" : "ws", host, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,8 +90,7 @@ public class SocketClient extends WebSocketClient {
|
|||||||
System.err.println("Server connection interrupted: " + exception);
|
System.err.println("Server connection interrupted: " + exception);
|
||||||
this.notifyAll();
|
this.notifyAll();
|
||||||
throw new RuntimeException("Aborted server connection", exception);
|
throw new RuntimeException("Aborted server connection", exception);
|
||||||
}
|
} catch (Exception exception) {
|
||||||
catch (Exception exception) {
|
|
||||||
throw new RuntimeException("Exception occurred in server connection: ", exception);
|
throw new RuntimeException("Exception occurred in server connection: ", exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,15 +103,14 @@ public class SocketClient extends WebSocketClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specific client-side implementations to handle incoming packets
|
* Specific client-side implementations to handle incoming packets
|
||||||
*/
|
*/
|
||||||
protected void handleReceivedPacket(IPacket packet) {
|
protected void handleReceivedPacket(IPacket packet) {
|
||||||
if (packet instanceof IServerToClientPacket serverToClientPacket) {
|
if (packet instanceof IServerToClientPacket serverToClientPacket) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
serverToClientPacket.onHandle(this.getConnection(), this);
|
serverToClientPacket.onHandle(this.getConnection(), this);
|
||||||
}
|
} catch (Exception exception) {
|
||||||
catch (Exception exception) {
|
|
||||||
this.closeLatch.countDown();
|
this.closeLatch.countDown();
|
||||||
this.close();
|
this.close();
|
||||||
throw exception;
|
throw exception;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import de.dhbwstuttgart.server.packet.MessagePacket;
|
|||||||
import de.dhbwstuttgart.server.packet.PacketContainer;
|
import de.dhbwstuttgart.server.packet.PacketContainer;
|
||||||
import de.dhbwstuttgart.util.Logger;
|
import de.dhbwstuttgart.util.Logger;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -17,7 +18,11 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import org.java_websocket.WebSocket;
|
import org.java_websocket.WebSocket;
|
||||||
|
import org.java_websocket.drafts.Draft;
|
||||||
|
import org.java_websocket.drafts.Draft_6455;
|
||||||
|
import org.java_websocket.extensions.permessage_deflate.PerMessageDeflateExtension;
|
||||||
import org.java_websocket.handshake.ClientHandshake;
|
import org.java_websocket.handshake.ClientHandshake;
|
||||||
|
import org.java_websocket.server.DefaultWebSocketServerFactory;
|
||||||
import org.java_websocket.server.WebSocketServer;
|
import org.java_websocket.server.WebSocketServer;
|
||||||
|
|
||||||
public class SocketServer extends WebSocketServer {
|
public class SocketServer extends WebSocketServer {
|
||||||
@@ -30,8 +35,14 @@ public class SocketServer extends WebSocketServer {
|
|||||||
*/
|
*/
|
||||||
public static final String packetProtocolVersion = "1";
|
public static final String packetProtocolVersion = "1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draft object for enabling the perMessageDeflate extension for more packet compression
|
||||||
|
*/
|
||||||
|
public static final Draft perMessageDeflateDraft = new Draft_6455(new PerMessageDeflateExtension());
|
||||||
|
|
||||||
public SocketServer(int port) {
|
public SocketServer(int port) {
|
||||||
super(new InetSocketAddress(port));
|
super(new InetSocketAddress(port), Collections.singletonList(perMessageDeflateDraft));
|
||||||
|
this.setConnectionLostTimeout(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -201,5 +212,4 @@ public class SocketServer extends WebSocketServer {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class ErrorPacket implements IClientToServerPacket, IServerToClientPacket
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void onHandle(WebSocket webSocket, SocketClient socketClient) {
|
public void onHandle(WebSocket webSocket, SocketClient socketClient) {
|
||||||
System.err.println("[socket] " + "ErrorPacket: " + this.error);
|
SocketClient.logger.error("SocketError: " + this.error);
|
||||||
if (this.isFatal) {
|
if (this.isFatal) {
|
||||||
throw new RuntimeException("Received fatal error from server: " + this.error);
|
throw new RuntimeException("Received fatal error from server: " + this.error);
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ public class ErrorPacket implements IClientToServerPacket, IServerToClientPacket
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void onHandle(WebSocket webSocket, SocketServer socketServer) {
|
public void onHandle(WebSocket webSocket, SocketServer socketServer) {
|
||||||
socketServer.log("ErrorPacket: " + this.error, webSocket);
|
socketServer.log("SocketError: " + this.error, webSocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ public class MessagePacket implements IClientToServerPacket, IServerToClientPack
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void onHandle(WebSocket webSocket, SocketClient socketClient) {
|
public void onHandle(WebSocket webSocket, SocketClient socketClient) {
|
||||||
System.err.println("[socket] " + this.message);
|
SocketClient.logger.info("SocketMessage: " + this.message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ public class MethodAssumption extends Assumption{
|
|||||||
private ClassOrInterface receiver;
|
private ClassOrInterface receiver;
|
||||||
private RefTypeOrTPHOrWildcardOrGeneric retType;
|
private RefTypeOrTPHOrWildcardOrGeneric retType;
|
||||||
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params;
|
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params;
|
||||||
private final Boolean isInherited;
|
private final boolean isInherited;
|
||||||
private final Boolean isOverridden;
|
private final boolean isOverridden;
|
||||||
|
|
||||||
public MethodAssumption(ClassOrInterface receiver, RefTypeOrTPHOrWildcardOrGeneric retType,
|
public MethodAssumption(ClassOrInterface receiver, RefTypeOrTPHOrWildcardOrGeneric retType,
|
||||||
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params, TypeScope scope, Boolean isInherited, Boolean isOverridden){
|
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params, TypeScope scope, boolean isInherited, boolean isOverridden){
|
||||||
super(scope);
|
super(scope);
|
||||||
this.receiver = receiver;
|
this.receiver = receiver;
|
||||||
this.retType = retType;
|
this.retType = retType;
|
||||||
@@ -73,11 +73,11 @@ public class MethodAssumption extends Assumption{
|
|||||||
return TYPEStmt.getReceiverType(receiver, resolver);
|
return TYPEStmt.getReceiverType(receiver, resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isInherited() {
|
public boolean isInherited() {
|
||||||
return isInherited;
|
return isInherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isOverridden() {
|
public boolean isOverridden() {
|
||||||
return isOverridden;
|
return isOverridden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class Constraint<A extends IConstraintElement> extends HashSet<A> implements ISerializableData {
|
public class Constraint<A extends IConstraintElement> extends HashSet<A> implements ISerializableData {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Boolean isInherited = false;//wird beides nur für die Method-Constraints benoetigt
|
private boolean isInherited = false;//wird beides nur für die Method-Constraints benoetigt
|
||||||
private Boolean isImplemented = false;
|
private boolean isImplemented = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wird verwendet um bei der Codegenerierung die richtige Methoden - Signatur
|
* wird verwendet um bei der Codegenerierung die richtige Methoden - Signatur
|
||||||
@@ -37,27 +37,27 @@ public class Constraint<A extends IConstraintElement> extends HashSet<A> impleme
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint(Boolean isInherited, Boolean isImplemented) {
|
public Constraint(boolean isInherited, boolean isImplemented) {
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
this.isImplemented = isImplemented;
|
this.isImplemented = isImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint(Boolean isInherited, Boolean isImplemented, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
|
public Constraint(boolean isInherited, boolean isImplemented, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
this.isImplemented = isImplemented;
|
this.isImplemented = isImplemented;
|
||||||
this.extendConstraint = extendConstraint;
|
this.extendConstraint = extendConstraint;
|
||||||
this.methodSignatureConstraint = methodSignatureConstraint;
|
this.methodSignatureConstraint = methodSignatureConstraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsInherited(Boolean isInherited) {
|
public void setIsInherited(boolean isInherited) {
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isInherited() {
|
public boolean isInherited() {
|
||||||
return isInherited;
|
return isInherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isImplemented() {
|
public boolean isImplemented() {
|
||||||
return isImplemented;
|
return isImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class Pair implements Serializable, IConstraintElement, ISerializableData
|
|||||||
private SourceLoc location;
|
private SourceLoc location;
|
||||||
|
|
||||||
private PairOperator eOperator = PairOperator.SMALLER;
|
private PairOperator eOperator = PairOperator.SMALLER;
|
||||||
private Boolean noUnification = false;
|
private boolean noUnification = false;
|
||||||
|
|
||||||
|
|
||||||
private Pair(RefTypeOrTPHOrWildcardOrGeneric TA1, RefTypeOrTPHOrWildcardOrGeneric TA2) {
|
private Pair(RefTypeOrTPHOrWildcardOrGeneric TA1, RefTypeOrTPHOrWildcardOrGeneric TA2) {
|
||||||
@@ -43,7 +43,7 @@ public class Pair implements Serializable, IConstraintElement, ISerializableData
|
|||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair(RefTypeOrTPHOrWildcardOrGeneric TA1, RefTypeOrTPHOrWildcardOrGeneric TA2, PairOperator eOp, Boolean noUnification) {
|
public Pair(RefTypeOrTPHOrWildcardOrGeneric TA1, RefTypeOrTPHOrWildcardOrGeneric TA2, PairOperator eOp, boolean noUnification) {
|
||||||
// Konstruktor
|
// Konstruktor
|
||||||
this(TA1, TA2);
|
this(TA1, TA2);
|
||||||
this.eOperator = eOp;
|
this.eOperator = eOp;
|
||||||
@@ -161,7 +161,7 @@ public class Pair implements Serializable, IConstraintElement, ISerializableData
|
|||||||
String op = data.getValue("op").getOf(String.class);
|
String op = data.getValue("op").getOf(String.class);
|
||||||
SerialMap ta1 = data.getMap("ta1");
|
SerialMap ta1 = data.getMap("ta1");
|
||||||
SerialMap ta2 = data.getMap("ta2");
|
SerialMap ta2 = data.getMap("ta2");
|
||||||
Boolean noUnification = data.getValue("noUnification").getOf(Integer.class) == 1;
|
boolean noUnification = data.getValue("noUnification").getOf(Integer.class) == 1;
|
||||||
SerialMap location = data.getMapOrNull("location");
|
SerialMap location = data.getMapOrNull("location");
|
||||||
|
|
||||||
var pair = new Pair(
|
var pair = new Pair(
|
||||||
|
|||||||
@@ -858,8 +858,8 @@ public class RuleSet implements IRuleSet{
|
|||||||
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
||||||
} );
|
} );
|
||||||
|
|
||||||
logger.debug("FUNgreater: " + pair);
|
logger.debug(() -> "FUNgreater: " + pair);
|
||||||
logger.debug("FUNred: " + result);
|
logger.debug(() -> "FUNred: " + result);
|
||||||
|
|
||||||
|
|
||||||
return Optional.of(result);
|
return Optional.of(result);
|
||||||
@@ -927,8 +927,8 @@ public class RuleSet implements IRuleSet{
|
|||||||
|
|
||||||
Set<UnifyPair> result = new HashSet<UnifyPair>();
|
Set<UnifyPair> result = new HashSet<UnifyPair>();
|
||||||
|
|
||||||
Integer variance = ((PlaceholderType)rhsType).getVariance();
|
int variance = ((PlaceholderType)rhsType).getVariance();
|
||||||
Integer inversVariance = distributeVariance.inverseVariance(variance);
|
int inversVariance = distributeVariance.inverseVariance(variance);
|
||||||
|
|
||||||
UnifyType[] freshPlaceholders = new UnifyType[funNLhsType.getTypeParams().size()];
|
UnifyType[] freshPlaceholders = new UnifyType[funNLhsType.getTypeParams().size()];
|
||||||
for(int i = 0; i < freshPlaceholders.length-1; i++) {
|
for(int i = 0; i < freshPlaceholders.length-1; i++) {
|
||||||
@@ -946,13 +946,13 @@ public class RuleSet implements IRuleSet{
|
|||||||
result.add(new UnifyPair(rhsType, funNLhsType.setTypeParams(new TypeParams(freshPlaceholders)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
result.add(new UnifyPair(rhsType, funNLhsType.setTypeParams(new TypeParams(freshPlaceholders)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||||
|
|
||||||
result.stream().forEach(x -> { UnifyType l = x.getLhsType();
|
result.stream().forEach(x -> { UnifyType l = x.getLhsType();
|
||||||
if (l instanceof PlaceholderType) { ((PlaceholderType)l).disableWildcardtable(); }
|
if (l instanceof PlaceholderType) { ((PlaceholderType)l).disableWildcardtable(); }
|
||||||
UnifyType r = x.getRhsType();
|
UnifyType r = x.getRhsType();
|
||||||
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
||||||
} );
|
} );
|
||||||
|
|
||||||
logger.debug("FUNgreater: " + pair);
|
logger.debug(() -> "FUNgreater: " + pair);
|
||||||
logger.debug("FUNgreater: " + result);
|
logger.debug(() -> "FUNgreater: " + result);
|
||||||
|
|
||||||
return Optional.of(result);
|
return Optional.of(result);
|
||||||
}
|
}
|
||||||
@@ -972,8 +972,8 @@ public class RuleSet implements IRuleSet{
|
|||||||
|
|
||||||
Set<UnifyPair> result = new HashSet<UnifyPair>();
|
Set<UnifyPair> result = new HashSet<UnifyPair>();
|
||||||
|
|
||||||
Integer variance = ((PlaceholderType)lhsType).getVariance();
|
int variance = ((PlaceholderType)lhsType).getVariance();
|
||||||
Integer inversVariance = distributeVariance.inverseVariance(variance);
|
int inversVariance = distributeVariance.inverseVariance(variance);
|
||||||
|
|
||||||
UnifyType[] freshPlaceholders = new UnifyType[funNRhsType.getTypeParams().size()];
|
UnifyType[] freshPlaceholders = new UnifyType[funNRhsType.getTypeParams().size()];
|
||||||
for(int i = 0; i < freshPlaceholders.length-1; i++) {
|
for(int i = 0; i < freshPlaceholders.length-1; i++) {
|
||||||
@@ -992,14 +992,14 @@ public class RuleSet implements IRuleSet{
|
|||||||
result.add(new UnifyPair(lhsType, funNRhsType.setTypeParams(new TypeParams(freshPlaceholders)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
result.add(new UnifyPair(lhsType, funNRhsType.setTypeParams(new TypeParams(freshPlaceholders)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||||
|
|
||||||
result.stream().forEach(x -> { UnifyType l = x.getLhsType();
|
result.stream().forEach(x -> { UnifyType l = x.getLhsType();
|
||||||
if (l instanceof PlaceholderType) { ((PlaceholderType)l).disableWildcardtable(); }
|
if (l instanceof PlaceholderType) { ((PlaceholderType)l).disableWildcardtable(); }
|
||||||
UnifyType r = x.getRhsType();
|
UnifyType r = x.getRhsType();
|
||||||
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
logger.debug("FUNgreater: " + pair);
|
logger.debug(() -> "FUNgreater: " + pair);
|
||||||
logger.debug("FUNsmaller: " + result);
|
logger.debug(() -> "FUNsmaller: " + result);
|
||||||
|
|
||||||
return Optional.of(result);
|
return Optional.of(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,18 +106,18 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
|
|
||||||
int rekTiefeField;
|
int rekTiefeField;
|
||||||
|
|
||||||
Integer nOfUnify = 0;
|
int nOfUnify = 0;
|
||||||
|
|
||||||
Integer noUndefPair = 0;
|
int noUndefPair = 0;
|
||||||
|
|
||||||
Integer noAllErasedElements = 0;
|
int noAllErasedElements = 0;
|
||||||
|
|
||||||
// some statistics for local output (they will not make sense when executed on the server)
|
// some statistics for local output (they will not make sense when executed on the server)
|
||||||
public static int noBacktracking;
|
public static int noBacktracking;
|
||||||
public static int noShortendElements;
|
public static int noShortendElements;
|
||||||
public static int noou = 0;
|
public static int noou = 0;
|
||||||
|
|
||||||
Boolean myIsCanceled = false;
|
boolean myIsCanceled = false;
|
||||||
|
|
||||||
public TypeUnifyTask(UnifyContext context) {
|
public TypeUnifyTask(UnifyContext context) {
|
||||||
this.context = context.newWithLogger(Logger.NULL_LOGGER);
|
this.context = context.newWithLogger(Logger.NULL_LOGGER);
|
||||||
@@ -213,7 +213,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void myCancel(Boolean b) {
|
void myCancel(boolean b) {
|
||||||
myIsCanceled = true;
|
myIsCanceled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,8 +292,8 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
|
|
||||||
rekTiefe++;
|
rekTiefe++;
|
||||||
nOfUnify++;
|
nOfUnify++;
|
||||||
context.logger().debug(nOfUnify.toString() + " Unifikation: " + eq.toString());
|
context.logger().debug(() -> nOfUnify + " Unifikation: " + eq.toString());
|
||||||
context.logger().debug(nOfUnify.toString() + " Oderconstraints: " + oderConstraints.toString());
|
context.logger().debug(() -> nOfUnify + " Oderconstraints: " + oderConstraints.toString());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variancen auf alle Gleichungen vererben
|
* Variancen auf alle Gleichungen vererben
|
||||||
@@ -323,7 +323,9 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
})
|
})
|
||||||
.peek(UnifyPair::setUndefinedPair)
|
.peek(UnifyPair::setUndefinedPair)
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
context.logger().debug("ocurrPairs: " + ocurrPairs);
|
|
||||||
|
Set<UnifyPair> finalOcurrPairs = ocurrPairs;
|
||||||
|
context.logger().debug(() -> "ocurrPairs: " + finalOcurrPairs);
|
||||||
if (!ocurrPairs.isEmpty()) {
|
if (!ocurrPairs.isEmpty()) {
|
||||||
Set<Set<UnifyPair>> ret = new HashSet<>();
|
Set<Set<UnifyPair>> ret = new HashSet<>();
|
||||||
ret.add(ocurrPairs);
|
ret.add(ocurrPairs);
|
||||||
@@ -352,7 +354,8 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
})
|
})
|
||||||
.peek(UnifyPair::setUndefinedPair)
|
.peek(UnifyPair::setUndefinedPair)
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
context.logger().debug("ocurrPairs: " + ocurrPairs);
|
Set<UnifyPair> finalOcurrPairs1 = ocurrPairs;
|
||||||
|
context.logger().debug(() -> "ocurrPairs: " + finalOcurrPairs1);
|
||||||
if (!ocurrPairs.isEmpty()) {
|
if (!ocurrPairs.isEmpty()) {
|
||||||
Set<Set<UnifyPair>> ret = new HashSet<>();
|
Set<Set<UnifyPair>> ret = new HashSet<>();
|
||||||
ret.add(ocurrPairs);
|
ret.add(ocurrPairs);
|
||||||
@@ -364,8 +367,8 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
|
|
||||||
eq0.forEach(UnifyPair::disableCondWildcards);
|
eq0.forEach(UnifyPair::disableCondWildcards);
|
||||||
|
|
||||||
context.logger().debug(nOfUnify.toString() + " Unifikation nach applyTypeUnificationRules: " + eq.toString());
|
context.logger().debug(() ->nOfUnify + " Unifikation nach applyTypeUnificationRules: " + eq.toString());
|
||||||
context.logger().debug(nOfUnify.toString() + " Oderconstraints nach applyTypeUnificationRules: " + oderConstraints.toString());
|
context.logger().debug(() -> nOfUnify + " Oderconstraints nach applyTypeUnificationRules: " + oderConstraints.toString());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Step 2 and 3: Create a subset eq1s of pairs where both sides are TPH and eq2s of the other pairs
|
* Step 2 and 3: Create a subset eq1s of pairs where both sides are TPH and eq2s of the other pairs
|
||||||
@@ -417,21 +420,21 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
//nicht ausgewertet Faculty Beispiel im 1. Schritt
|
//nicht ausgewertet Faculty Beispiel im 1. Schritt
|
||||||
//PL 2017-10-03 geloest, muesste noch mit FCs mit kleineren
|
//PL 2017-10-03 geloest, muesste noch mit FCs mit kleineren
|
||||||
//Typen getestet werden.
|
//Typen getestet werden.
|
||||||
context.logger().debug(nOfUnify.toString() + " Oderconstraints2: " + oderConstraintsOutput.toString());
|
context.logger().debug(() -> nOfUnify + " Oderconstraints2: " + oderConstraintsOutput.toString());
|
||||||
if (printtag) context.logger().info("secondLevelSets:" + secondLevelSets);
|
if (printtag) context.logger().info("secondLevelSets:" + secondLevelSets);
|
||||||
// If pairs occured that did not match one of the cartesian product cases,
|
// If pairs occured that did not match one of the cartesian product cases,
|
||||||
// those pairs are contradictory and the unification is impossible.
|
// those pairs are contradictory and the unification is impossible.
|
||||||
if (!undefinedPairs.isEmpty()) {
|
if (!undefinedPairs.isEmpty()) {
|
||||||
noUndefPair++;
|
noUndefPair++;
|
||||||
for (UnifyPair up : undefinedPairs) {
|
for (UnifyPair up : undefinedPairs) {
|
||||||
context.logger().debug(noUndefPair.toString() + " UndefinedPairs; " + up);
|
context.logger().debug(() -> noUndefPair + " UndefinedPairs; " + up);
|
||||||
context.logger().debug("BasePair; " + up.getBasePair());
|
context.logger().debug(() -> "BasePair; " + up.getBasePair());
|
||||||
}
|
}
|
||||||
Set<Set<UnifyPair>> error = new HashSet<>();
|
Set<Set<UnifyPair>> error = new HashSet<>();
|
||||||
undefinedPairs = undefinedPairs.stream().peek(UnifyPair::setUndefinedPair)
|
undefinedPairs = undefinedPairs.stream().peek(UnifyPair::setUndefinedPair)
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
error.add(undefinedPairs);
|
error.add(undefinedPairs);
|
||||||
undefinedPairs.forEach(x -> context.logger().debug("AllSubst: " + x.getAllSubstitutions().toString()));
|
undefinedPairs.forEach(x -> context.logger().debug(() -> "AllSubst: " + x.getAllSubstitutions().toString()));
|
||||||
return CompletableFuture.completedFuture(error);
|
return CompletableFuture.completedFuture(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,14 +509,14 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
* Step 5: Substitution
|
* Step 5: Substitution
|
||||||
*/
|
*/
|
||||||
//writeLog("vor Subst: " + eqPrime);
|
//writeLog("vor Subst: " + eqPrime);
|
||||||
context.logger().debug("vor Subst: " + oderConstraints);
|
context.logger().debug(() -> "vor Subst: " + oderConstraints);
|
||||||
String ocString = oderConstraints.toString();
|
String ocString = oderConstraints.toString();
|
||||||
List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||||
Optional<Set<UnifyPair>> eqPrimePrime = rules.subst(eqPrime, newOderConstraints);
|
Optional<Set<UnifyPair>> eqPrimePrime = rules.subst(eqPrime, newOderConstraints);
|
||||||
Set<Set<UnifyPair>> unifyres1 = null;
|
Set<Set<UnifyPair>> unifyres1 = null;
|
||||||
Set<Set<UnifyPair>> unifyres2 = null;
|
Set<Set<UnifyPair>> unifyres2 = null;
|
||||||
if (!ocString.equals(newOderConstraints.toString()))
|
if (!ocString.equals(newOderConstraints.toString()))
|
||||||
context.logger().debug("nach Subst: " + newOderConstraints);
|
context.logger().debug(() -> "nach Subst: " + newOderConstraints);
|
||||||
|
|
||||||
|
|
||||||
{// sequentiell (Step 6b is included)
|
{// sequentiell (Step 6b is included)
|
||||||
@@ -536,7 +539,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
return eqPrimePrimeSet;
|
return eqPrimePrimeSet;
|
||||||
});
|
});
|
||||||
if (finalresult && isSolvedForm(eqPrime)) {
|
if (finalresult && isSolvedForm(eqPrime)) {
|
||||||
context.logger().debug("eqPrime:" + eqPrime.toString() + "\n");
|
context.logger().debug(() -> "eqPrime:" + eqPrime.toString() + "\n");
|
||||||
|
|
||||||
/* methodconstraintsets werden zum Ergebnis hinzugefuegt
|
/* methodconstraintsets werden zum Ergebnis hinzugefuegt
|
||||||
* Anfang
|
* Anfang
|
||||||
@@ -592,7 +595,8 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
return eqPrimePrimeSetFuture.thenApply(eqPrimePrimeSet -> {
|
return eqPrimePrimeSetFuture.thenApply(eqPrimePrimeSet -> {
|
||||||
eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x) || this.isUndefinedPairSet(x)).collect(Collectors.toCollection(HashSet::new));
|
eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x) || this.isUndefinedPairSet(x)).collect(Collectors.toCollection(HashSet::new));
|
||||||
if (!eqPrimePrimeSet.isEmpty() && !isUndefinedPairSetSet(eqPrimePrimeSet)) {
|
if (!eqPrimePrimeSet.isEmpty() && !isUndefinedPairSetSet(eqPrimePrimeSet)) {
|
||||||
context.logger().debug("Result1 " + eqPrimePrimeSet);
|
Set<Set<UnifyPair>> finalEqPrimePrimeSet = eqPrimePrimeSet;
|
||||||
|
context.logger().debug(() -> "Result1 " + finalEqPrimePrimeSet);
|
||||||
}
|
}
|
||||||
return eqPrimePrimeSet;
|
return eqPrimePrimeSet;
|
||||||
});
|
});
|
||||||
@@ -680,14 +684,16 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
*/
|
*/
|
||||||
Set<UnifyPair> sameEqSet = new HashSet<>();
|
Set<UnifyPair> sameEqSet = new HashSet<>();
|
||||||
//optOrigPair enthaelt ggf. das Paar a = ty \in nextSet
|
//optOrigPair enthaelt ggf. das Paar a = ty \in nextSet
|
||||||
Optional<UnifyPair> optOrigPair = Optional.empty();
|
Optional<UnifyPair> optOrigPair;
|
||||||
if (!oderConstraint) {
|
if (!oderConstraint) {
|
||||||
optOrigPair = TypeUnifyTaskHelper.findEqualityConstrainedUnifyPair(nextSetElement);
|
optOrigPair = TypeUnifyTaskHelper.findEqualityConstrainedUnifyPair(nextSetElement);
|
||||||
context.logger().debug("optOrigPair: " + optOrigPair);
|
context.logger().debug(() -> "optOrigPair: " + optOrigPair);
|
||||||
|
|
||||||
if (optOrigPair.isPresent()) {
|
if (optOrigPair.isPresent()) {
|
||||||
sameEqSet = TypeUnifyTaskHelper.findConstraintsWithSameTVAssociation(optOrigPair.get(), singleElementSets);
|
sameEqSet = TypeUnifyTaskHelper.findConstraintsWithSameTVAssociation(optOrigPair.get(), singleElementSets);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
optOrigPair = Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -697,7 +703,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
|
|
||||||
return resultFuture.thenApply(result -> {
|
return resultFuture.thenApply(result -> {
|
||||||
//2020-02-02: if (variance ==2) Hier Aufruf von filterOverriding einfuegen
|
//2020-02-02: if (variance ==2) Hier Aufruf von filterOverriding einfuegen
|
||||||
context.logger().debug("Return computeCR: " + result.toString());
|
context.logger().debug(() ->"Return computeCR: " + result.toString());
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -724,14 +730,14 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
|
|
||||||
VarianceCase varianceCase = VarianceCase.createFromVariance(variance, oderConstraint, this, context);
|
VarianceCase varianceCase = VarianceCase.createFromVariance(variance, oderConstraint, this, context);
|
||||||
|
|
||||||
context.logger().debug("nextSet: " + nextSet.toString());
|
context.logger().debug(() -> "nextSet: " + nextSet.toString());
|
||||||
context.logger().debug("nextSetasList: " + prevNextSetAsList.toString());
|
context.logger().debug(() -> "nextSetasList: " + prevNextSetAsList.toString());
|
||||||
|
|
||||||
varianceCase.selectNextData(this, prevNextSetAsList, optOrigPair);
|
varianceCase.selectNextData(this, prevNextSetAsList, optOrigPair);
|
||||||
|
|
||||||
if (oderConstraint) {//Methodconstraints werden abgespeichert für die Bytecodegenerierung von Methodenaufrufen
|
if (oderConstraint) {//Methodconstraints werden abgespeichert für die Bytecodegenerierung von Methodenaufrufen
|
||||||
methodSignatureConstraint.addAll(((Constraint<UnifyPair>) varianceCase.a).getmethodSignatureConstraint());
|
methodSignatureConstraint.addAll(((Constraint<UnifyPair>) varianceCase.a).getmethodSignatureConstraint());
|
||||||
context.logger().debug("ERSTELLUNG methodSignatureConstraint: " + methodSignatureConstraint);
|
context.logger().debug(() -> "ERSTELLUNG methodSignatureConstraint: " + methodSignatureConstraint);
|
||||||
//context.logger().info("ERSTELLUNG methodSignatureConstraint: " +noOfThread+" "+methodSignatureConstraint);
|
//context.logger().info("ERSTELLUNG methodSignatureConstraint: " +noOfThread+" "+methodSignatureConstraint);
|
||||||
//context.logger().info("a: " +a);
|
//context.logger().info("a: " +a);
|
||||||
//context.logger().info("eq: " +eq);
|
//context.logger().info("eq: " +eq);
|
||||||
@@ -740,7 +746,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
Set<Set<UnifyPair>> elems = new HashSet<>(singleElementSets);
|
Set<Set<UnifyPair>> elems = new HashSet<>(singleElementSets);
|
||||||
context.logger().debug("a1: " + rekTiefe + " " + "variance: " + variance + " " + varianceCase.a.toString() + "\n");
|
context.logger().debug(() -> "a1: " + rekTiefe + " " + "variance: " + variance + " " + varianceCase.a.toString() + "\n");
|
||||||
|
|
||||||
Set<Set<UnifyPair>> aParDef = new HashSet<>();
|
Set<Set<UnifyPair>> aParDef = new HashSet<>();
|
||||||
|
|
||||||
@@ -814,7 +820,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
//context.logger().info(a_last);
|
//context.logger().info(a_last);
|
||||||
|
|
||||||
try {//PL eingefuegt 2019-03-06 da bei map mmer wieder Nullpointer kamen
|
try {//PL eingefuegt 2019-03-06 da bei map mmer wieder Nullpointer kamen
|
||||||
a_last.forEach(x -> context.logger().debug("a_last_elem:" + x + " basepair: " + x.getBasePair()));//PL 2019-05-13 ins try hinzugefuegt Nullpointer-Exception ist in der Zeile aufgetaucht.
|
a_last.forEach(x -> context.logger().debug(() -> "a_last_elem:" + x + " basepair: " + x.getBasePair()));//PL 2019-05-13 ins try hinzugefuegt Nullpointer-Exception ist in der Zeile aufgetaucht.
|
||||||
List<PlaceholderType> varsLast_a = TypeUnifyTaskHelper.extractMatchingPlaceholderTypes(a_last);
|
List<PlaceholderType> varsLast_a = TypeUnifyTaskHelper.extractMatchingPlaceholderTypes(a_last);
|
||||||
//[(java.util.Vector<java.lang.Integer> <. gen_aq, , 1), (CEK =. ? extends gen_aq, 1)] KANN VORKOMMEN
|
//[(java.util.Vector<java.lang.Integer> <. gen_aq, , 1), (CEK =. ? extends gen_aq, 1)] KANN VORKOMMEN
|
||||||
//erstes Element genügt, da vars immer auf die gleichen Elemente zugeordnet werden muessen
|
//erstes Element genügt, da vars immer auf die gleichen Elemente zugeordnet werden muessen
|
||||||
@@ -823,11 +829,12 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
|
|
||||||
varianceCase.applyComputedResults(result, currentThreadResult, compResult, compRes);
|
varianceCase.applyComputedResults(result, currentThreadResult, compResult, compRes);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
context.logger().debug("NullPointerException: " + a_last.toString());
|
context.logger().debug(() -> "NullPointerException: " + a_last.toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden
|
//alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden
|
||||||
context.logger().debug("RES Fst: result: " + result.toString() + " currentThreadResult: " + currentThreadResult.toString());
|
Set<Set<UnifyPair>> finalResult = result;
|
||||||
|
context.logger().debug(() -> "RES Fst: result: " + finalResult.toString() + " currentThreadResult: " + currentThreadResult.toString());
|
||||||
result.addAll(currentThreadResult);
|
result.addAll(currentThreadResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -841,9 +848,15 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
|
|
||||||
if (parallel) {
|
if (parallel) {
|
||||||
for (Set<Set<UnifyPair>> par_res : forkResults) {
|
for (Set<Set<UnifyPair>> par_res : forkResults) {
|
||||||
if (variance == 0 && (!result.isEmpty() && (!isUndefinedPairSetSet(currentThreadResult)))) {
|
|
||||||
this.cancelChildExecution();
|
if (variance == 0) {
|
||||||
return CompletableFuture.completedFuture(result);
|
if (!result.isEmpty() && !isUndefinedPairSetSet(currentThreadResult)) {
|
||||||
|
return CompletableFuture.completedFuture(result);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.addAll(par_res);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) {
|
if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) {
|
||||||
@@ -857,7 +870,8 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
|| (!isUndefinedPairSetSet(par_res) && !isUndefinedPairSetSet(result))
|
|| (!isUndefinedPairSetSet(par_res) && !isUndefinedPairSetSet(result))
|
||||||
|| result.isEmpty()) {
|
|| result.isEmpty()) {
|
||||||
//alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden
|
//alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden
|
||||||
context.logger().debug("RES var1 ADD:" + result.toString() + " " + par_res.toString());
|
Set<Set<UnifyPair>> finalResult1 = result;
|
||||||
|
context.logger().debug(() ->"RES var1 ADD:" + finalResult1.toString() + " " + par_res.toString());
|
||||||
result.addAll(par_res);
|
result.addAll(par_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -882,12 +896,11 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
return CompletableFuture.completedFuture(result);
|
return CompletableFuture.completedFuture(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.logger().debug("a: " + rekTiefe + " variance: " + variance + varianceCase.a.toString());
|
context.logger().debug(() -> "a: " + rekTiefe + " variance: " + variance + varianceCase.a.toString());
|
||||||
}
|
}
|
||||||
/* auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */
|
/* auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */
|
||||||
|
|
||||||
if (isUndefinedPairSetSet(currentThreadResult) && aParDef.isEmpty()) {
|
if (isUndefinedPairSetSet(currentThreadResult) && aParDef.isEmpty()) {
|
||||||
int nofstred = 0;
|
|
||||||
Set<UnifyPair> abhSubst = TypeUnifyTaskHelper.collectFromThreadResult(currentThreadResult, UnifyPair::getAllSubstitutions);
|
Set<UnifyPair> abhSubst = TypeUnifyTaskHelper.collectFromThreadResult(currentThreadResult, UnifyPair::getAllSubstitutions);
|
||||||
abhSubst.addAll(
|
abhSubst.addAll(
|
||||||
TypeUnifyTaskHelper.collectFromThreadResult(currentThreadResult, UnifyPair::getThisAndAllBases)
|
TypeUnifyTaskHelper.collectFromThreadResult(currentThreadResult, UnifyPair::getThisAndAllBases)
|
||||||
@@ -919,7 +932,8 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
if (currentThreadResult.size() > 1) {
|
if (currentThreadResult.size() > 1) {
|
||||||
// context.logger().info();
|
// context.logger().info();
|
||||||
}
|
}
|
||||||
context.logger().debug("nextSetasList vor filter-Aufruf: " + nextSetAsList);
|
List<Set<UnifyPair>> finalNextSetAsList = nextSetAsList;
|
||||||
|
context.logger().debug(() -> "nextSetasList vor filter-Aufruf: " + finalNextSetAsList);
|
||||||
if (!oderConstraint) {//PL 2023-02-08 eingefuegt: Bei oderconstraints sind Subststitutionen nicht als Substitutionen in idesem Sinne zu sehen
|
if (!oderConstraint) {//PL 2023-02-08 eingefuegt: Bei oderconstraints sind Subststitutionen nicht als Substitutionen in idesem Sinne zu sehen
|
||||||
nextSetAsList = nextSetAsList.stream().filter(x -> {
|
nextSetAsList = nextSetAsList.stream().filter(x -> {
|
||||||
//Boolean ret = false;
|
//Boolean ret = false;
|
||||||
@@ -930,23 +944,28 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
})//.filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) //fuer testzwecke auskommentiert um nofstred zu bestimmen PL 2018-10-10
|
})//.filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) //fuer testzwecke auskommentiert um nofstred zu bestimmen PL 2018-10-10
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
}
|
}
|
||||||
context.logger().debug("nextSetasList nach filter-Aufruf: " + nextSetAsList);
|
|
||||||
nofstred = nextSetAsList.size();
|
if (context.logger().isLogLevelActive(Logger.LogLevel.DEBUG)) {
|
||||||
//NOCH NICHT korrekt PL 2018-10-12
|
List<Set<UnifyPair>> finalNextSetAsList1 = nextSetAsList;
|
||||||
//nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y))
|
context.logger().debug(() -> "nextSetasList nach filter-Aufruf: " + finalNextSetAsList1);
|
||||||
// .collect(Collectors.toCollection(ArrayList::new));
|
int nofstred = nextSetAsList.size();
|
||||||
context.logger().debug("currentThreadResult (undef): " + currentThreadResult.toString());
|
//NOCH NICHT korrekt PL 2018-10-12
|
||||||
context.logger().debug("abhSubst: " + abhSubst.toString());
|
//nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y))
|
||||||
context.logger().debug("a2: " + rekTiefe + " " + varianceCase.a.toString());
|
// .collect(Collectors.toCollection(ArrayList::new));
|
||||||
context.logger().debug("Durchschnitt: " + durchschnitt.toString());
|
context.logger().debug("currentThreadResult (undef): " + currentThreadResult.toString());
|
||||||
context.logger().debug("nextSet: " + nextSet.toString());
|
context.logger().debug("abhSubst: " + abhSubst.toString());
|
||||||
context.logger().debug("nextSetasList: " + nextSetAsList.toString());
|
context.logger().debug("a2: " + rekTiefe + " " + varianceCase.a.toString());
|
||||||
context.logger().debug("Number first erased Elements (undef): " + (len - nofstred));
|
context.logger().debug("Durchschnitt: " + durchschnitt.toString());
|
||||||
context.logger().debug("Number second erased Elements (undef): " + (nofstred - nextSetAsList.size()));
|
context.logger().debug("nextSet: " + nextSet.toString());
|
||||||
context.logger().debug("Number erased Elements (undef): " + (len - nextSetAsList.size()));
|
context.logger().debug("nextSetasList: " + nextSetAsList.toString());
|
||||||
noAllErasedElements += (len - nextSetAsList.size());
|
context.logger().debug("Number first erased Elements (undef): " + (len - nofstred));
|
||||||
context.logger().debug("Number of all erased Elements (undef): " + noAllErasedElements.toString());
|
context.logger().debug("Number second erased Elements (undef): " + (nofstred - nextSetAsList.size()));
|
||||||
context.logger().debug("Number of Backtracking: " + noBacktracking++);
|
context.logger().debug("Number erased Elements (undef): " + (len - nextSetAsList.size()));
|
||||||
|
noAllErasedElements += (len - nextSetAsList.size());
|
||||||
|
context.logger().debug("Number of all erased Elements (undef): " + noAllErasedElements);
|
||||||
|
context.logger().debug("Number of Backtracking: " + noBacktracking++);
|
||||||
|
}
|
||||||
|
|
||||||
// context.logger().info("");
|
// context.logger().info("");
|
||||||
}
|
}
|
||||||
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
|
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
|
||||||
@@ -956,7 +975,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
// result.removeIf(y -> isUndefinedPairSet(y));
|
// result.removeIf(y -> isUndefinedPairSet(y));
|
||||||
//}
|
//}
|
||||||
//else result.stream().filter(y -> !isUndefinedPairSet(y));
|
//else result.stream().filter(y -> !isUndefinedPairSet(y));
|
||||||
context.logger().debug("currentThreadResult: " + currentThreadResult.toString());
|
context.logger().debug(() -> "currentThreadResult: " + currentThreadResult.toString());
|
||||||
|
|
||||||
return this.innerCartesianLoop(variance, rekTiefe, oderConstraint, parallel, result, varianceCase.a, nextSet,
|
return this.innerCartesianLoop(variance, rekTiefe, oderConstraint, parallel, result, varianceCase.a, nextSet,
|
||||||
nextSetAsList, optOrigPair, methodSignatureConstraint, singleElementSets, sameEqSet, oderConstraints);
|
nextSetAsList, optOrigPair, methodSignatureConstraint, singleElementSets, sameEqSet, oderConstraints);
|
||||||
@@ -973,7 +992,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
* the error constraints. Error constraints are added
|
* the error constraints. Error constraints are added
|
||||||
* @result contradiction of (a = ty) in sameEqSet
|
* @result contradiction of (a = ty) in sameEqSet
|
||||||
*/
|
*/
|
||||||
public Boolean checkNoContradiction(Set<UnifyPair> a, Set<UnifyPair> sameEqSet, Set<Set<UnifyPair>> result) {
|
public boolean checkNoContradiction(Set<UnifyPair> a, Set<UnifyPair> sameEqSet, Set<Set<UnifyPair>> result) {
|
||||||
|
|
||||||
//optAPair enthaelt ggf. das Paar a = ty' \in a
|
//optAPair enthaelt ggf. das Paar a = ty' \in a
|
||||||
//unterscheidet sich von optOrigPair, da dort a = ty
|
//unterscheidet sich von optOrigPair, da dort a = ty
|
||||||
@@ -993,7 +1012,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
UnifyPair aPair = optAPair.get();
|
UnifyPair aPair = optAPair.get();
|
||||||
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
||||||
|
|
||||||
context.logger().debug("checkA: " + aPair + "sameEqSet: " + sameEqSet);
|
context.logger().debug(() ->"checkA: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
for (UnifyPair sameEq : sameEqSet) {
|
for (UnifyPair sameEq : sameEqSet) {
|
||||||
if (sameEq.getLhsType() instanceof PlaceholderType) {
|
if (sameEq.getLhsType() instanceof PlaceholderType) {
|
||||||
Set<UnifyPair> localEq = new HashSet<>();
|
Set<UnifyPair> localEq = new HashSet<>();
|
||||||
@@ -1014,7 +1033,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||||
result.addAll(localRes);
|
result.addAll(localRes);
|
||||||
}
|
}
|
||||||
context.logger().debug("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
context.logger().debug(() ->"FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1036,12 +1055,12 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||||
result.addAll(localRes);
|
result.addAll(localRes);
|
||||||
}
|
}
|
||||||
context.logger().debug("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
context.logger().debug(() ->"FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.logger().debug("TRUE: " + aPair + "sameEqSet: " + sameEqSet);
|
context.logger().debug(() ->"TRUE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1127,7 +1146,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
// Through application of the rules, every pair should have one of the above forms.
|
// Through application of the rules, every pair should have one of the above forms.
|
||||||
// Pairs that do not have one of the aboves form are contradictory.
|
// Pairs that do not have one of the aboves form are contradictory.
|
||||||
else {
|
else {
|
||||||
context.logger().debug("Second erase:" + checkPair);
|
context.logger().debug(() ->"Second erase:" + checkPair);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//*/
|
//*/
|
||||||
@@ -1326,7 +1345,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
* (as in case 1 where sigma is added to the innermost set).
|
* (as in case 1 where sigma is added to the innermost set).
|
||||||
*/
|
*/
|
||||||
protected Set<Set<Set<? extends Set<UnifyPair>>>> calculatePairSets(Set<UnifyPair> eq2s, List<Set<Constraint<UnifyPair>>> oderConstraintsInput, IFiniteClosure fc, Set<UnifyPair> undefined, List<Set<Constraint<UnifyPair>>> oderConstraintsOutput) {
|
protected Set<Set<Set<? extends Set<UnifyPair>>>> calculatePairSets(Set<UnifyPair> eq2s, List<Set<Constraint<UnifyPair>>> oderConstraintsInput, IFiniteClosure fc, Set<UnifyPair> undefined, List<Set<Constraint<UnifyPair>>> oderConstraintsOutput) {
|
||||||
context.logger().debug("eq2s: " + eq2s.toString());
|
context.logger().debug(() ->"eq2s: " + eq2s.toString());
|
||||||
oderConstraintsOutput.addAll(oderConstraintsInput);
|
oderConstraintsOutput.addAll(oderConstraintsInput);
|
||||||
List<Set<Set<? extends Set<UnifyPair>>>> result = new ArrayList<>(9);
|
List<Set<Set<? extends Set<UnifyPair>>>> result = new ArrayList<>(9);
|
||||||
|
|
||||||
@@ -1413,10 +1432,12 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.logger().debug("eq2s: " + eq2s);
|
if (context.logger().isLogLevelActive(Logger.LogLevel.DEBUG)) {
|
||||||
context.logger().debug("eq2sAsListFst: " + eq2sAsListFst);
|
context.logger().debug("eq2s: " + eq2s);
|
||||||
context.logger().debug("eq2sAsListSnd: " + eq2sAsListSnd);
|
context.logger().debug("eq2sAsListFst: " + eq2sAsListFst);
|
||||||
context.logger().debug("eq2sAsListBack: " + eq2sAsListBack);
|
context.logger().debug("eq2sAsListSnd: " + eq2sAsListSnd);
|
||||||
|
context.logger().debug("eq2sAsListBack: " + eq2sAsListBack);
|
||||||
|
}
|
||||||
|
|
||||||
eq2sAsList.addAll(eq2sAsListFst);
|
eq2sAsList.addAll(eq2sAsListFst);
|
||||||
eq2sAsList.addAll(eq2sAsListSnd);
|
eq2sAsList.addAll(eq2sAsListSnd);
|
||||||
@@ -1713,7 +1734,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
//}
|
//}
|
||||||
Set<UnifyType> cs = fc.getAllTypesByName(thetaPrime.getName());//cs= [java.util.Vector<NP>, java.util.Vector<java.util.Vector<java.lang.Integer>>, ????java.util.Vector<gen_hv>???]
|
Set<UnifyType> cs = fc.getAllTypesByName(thetaPrime.getName());//cs= [java.util.Vector<NP>, java.util.Vector<java.util.Vector<java.lang.Integer>>, ????java.util.Vector<gen_hv>???]
|
||||||
|
|
||||||
context.logger().debug("cs: " + cs.toString());
|
context.logger().debug(() ->"cs: " + cs.toString());
|
||||||
//PL 18-02-06 entfernt, kommt durch unify wieder rein
|
//PL 18-02-06 entfernt, kommt durch unify wieder rein
|
||||||
//cs.add(thetaPrime);
|
//cs.add(thetaPrime);
|
||||||
//PL 18-02-06 entfernt
|
//PL 18-02-06 entfernt
|
||||||
@@ -1745,7 +1766,8 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
if ((match.match(ml)).isEmpty()) {
|
if ((match.match(ml)).isEmpty()) {
|
||||||
thetaQs.remove(c);
|
thetaQs.remove(c);
|
||||||
}
|
}
|
||||||
context.logger().debug("thetaQs von " + c + ": " + thetaQs.toString());
|
Set<UnifyType> finalThetaQs = thetaQs;
|
||||||
|
context.logger().debug(() ->"thetaQs von " + c + ": " + finalThetaQs.toString());
|
||||||
//Set<UnifyType> thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new));
|
//Set<UnifyType> thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new));
|
||||||
//thetaQs.add(thetaPrime); //PL 18-02-05 wieder geloescht
|
//thetaQs.add(thetaPrime); //PL 18-02-05 wieder geloescht
|
||||||
//PL 2017-10-03: War auskommentiert habe ich wieder einkommentiert,
|
//PL 2017-10-03: War auskommentiert habe ich wieder einkommentiert,
|
||||||
@@ -1769,7 +1791,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
for (TypeParams tp : permuteParams(candidateParams))
|
for (TypeParams tp : permuteParams(candidateParams))
|
||||||
thetaQPrimes.add(c.setTypeParams(tp));
|
thetaQPrimes.add(c.setTypeParams(tp));
|
||||||
}
|
}
|
||||||
context.logger().debug("thetaQPrimes von " + c + ": " + thetaQPrimes.toString());
|
context.logger().debug(() ->"thetaQPrimes von " + c + ": " + thetaQPrimes.toString());
|
||||||
for (UnifyType tqp : thetaQPrimes) {//PL 2020-03-08 umbauen in der Schleife wird nur unifizierbarer Typ gesucht break am Ende
|
for (UnifyType tqp : thetaQPrimes) {//PL 2020-03-08 umbauen in der Schleife wird nur unifizierbarer Typ gesucht break am Ende
|
||||||
Collection<PlaceholderType> tphs = tqp.getInvolvedPlaceholderTypes();
|
Collection<PlaceholderType> tphs = tqp.getInvolvedPlaceholderTypes();
|
||||||
Optional<Unifier> opt = stdUnify.unify(tqp, thetaPrime);
|
Optional<Unifier> opt = stdUnify.unify(tqp, thetaPrime);
|
||||||
@@ -1842,7 +1864,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.logger().debug("result von " + pair + ": " + result);
|
context.logger().debug(() ->"result von " + pair + ": " + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public record UnifyContext(
|
|||||||
// main logger of a unification
|
// main logger of a unification
|
||||||
Logger logger,
|
Logger logger,
|
||||||
// if the unify algorithm should run in parallel
|
// if the unify algorithm should run in parallel
|
||||||
Boolean parallel,
|
boolean parallel,
|
||||||
// the model for storing calculated results
|
// the model for storing calculated results
|
||||||
UnifyResultModel resultModel,
|
UnifyResultModel resultModel,
|
||||||
// the executor used for thread management in parallel execution
|
// the executor used for thread management in parallel execution
|
||||||
@@ -22,7 +22,7 @@ public record UnifyContext(
|
|||||||
|
|
||||||
public UnifyContext(
|
public UnifyContext(
|
||||||
Logger logger,
|
Logger logger,
|
||||||
Boolean parallel,
|
boolean parallel,
|
||||||
UnifyResultModel resultModel,
|
UnifyResultModel resultModel,
|
||||||
UnifyTaskModel usedTasks,
|
UnifyTaskModel usedTasks,
|
||||||
ExecutorService executor,
|
ExecutorService executor,
|
||||||
@@ -33,7 +33,7 @@ public record UnifyContext(
|
|||||||
|
|
||||||
public UnifyContext(
|
public UnifyContext(
|
||||||
Logger logger,
|
Logger logger,
|
||||||
Boolean parallel,
|
boolean parallel,
|
||||||
UnifyResultModel resultModel,
|
UnifyResultModel resultModel,
|
||||||
UnifyTaskModel usedTasks,
|
UnifyTaskModel usedTasks,
|
||||||
PlaceholderRegistry placeholderRegistry
|
PlaceholderRegistry placeholderRegistry
|
||||||
@@ -52,6 +52,7 @@ public record UnifyContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UnifyContext newWithParallel(boolean parallel) {
|
public UnifyContext newWithParallel(boolean parallel) {
|
||||||
|
if (this.parallel == parallel) return this;
|
||||||
return new UnifyContext(logger, parallel, resultModel, executor, placeholderRegistry, usedTasks);
|
return new UnifyContext(logger, parallel, resultModel, executor, placeholderRegistry, usedTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ public class Variance2Case extends VarianceCase {
|
|||||||
}
|
}
|
||||||
/* FORK ENDE */
|
/* FORK ENDE */
|
||||||
|
|
||||||
context.logger().debug("a in " + variance + " " + a);
|
context.logger().debug(() -> "a in " + variance + " " + a);
|
||||||
context.logger().debug("nextSetasListRest: " + nextSetasListRest.toString());
|
context.logger().debug(() -> "nextSetasListRest: " + nextSetasListRest.toString());
|
||||||
|
|
||||||
//Fuer parallele Berechnung der Oder-Contraints wird methodSignature kopiert
|
//Fuer parallele Berechnung der Oder-Contraints wird methodSignature kopiert
|
||||||
//und jeweils die methodSignature von a bzw. nSaL wieder gelöscht, wenn es keine Lösung ist.
|
//und jeweils die methodSignature von a bzw. nSaL wieder gelöscht, wenn es keine Lösung ist.
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ public class VarianceM1Case extends VarianceCase {
|
|||||||
Optional<UnifyPair> optOrigPair
|
Optional<UnifyPair> optOrigPair
|
||||||
) {
|
) {
|
||||||
a = typeUnifyTask.oup.min(nextSetAsList.iterator());
|
a = typeUnifyTask.oup.min(nextSetAsList.iterator());
|
||||||
context.logger().debug("Min: a in " + variance + " " + a);
|
context.logger().debug(() -> "Min: a in " + variance + " " + a);
|
||||||
if (this.isOderConstraint) {
|
if (this.isOderConstraint) {
|
||||||
nextSetasListOderConstraints.add(((Constraint<UnifyPair>) a).getExtendConstraint());
|
nextSetasListOderConstraints.add(((Constraint<UnifyPair>) a).getExtendConstraint());
|
||||||
}
|
}
|
||||||
context.logger().debug("nextSetasListOderConstraints -1: " + nextSetasListOderConstraints);
|
context.logger().debug(() -> "nextSetasListOderConstraints -1: " + nextSetasListOderConstraints);
|
||||||
nextSetAsList.remove(a);
|
nextSetAsList.remove(a);
|
||||||
|
|
||||||
//Alle minimalen Elemente in nextSetasListRest bestimmen
|
//Alle minimalen Elemente in nextSetasListRest bestimmen
|
||||||
@@ -88,13 +88,13 @@ public class VarianceM1Case extends VarianceCase {
|
|||||||
}
|
}
|
||||||
/* FORK ENDE */
|
/* FORK ENDE */
|
||||||
|
|
||||||
context.logger().debug("a in " + variance + " " + a);
|
context.logger().debug(() -> "a in " + variance + " " + a);
|
||||||
context.logger().debug("nextSetasListRest: " + nextSetasListRest.toString());
|
context.logger().debug(() -> "nextSetasListRest: " + nextSetasListRest.toString());
|
||||||
|
|
||||||
while (!nextSetasListRest.isEmpty()) {
|
while (!nextSetasListRest.isEmpty()) {
|
||||||
Set<UnifyPair> nSaL = nextSetasListRest.removeFirst();
|
Set<UnifyPair> nSaL = nextSetasListRest.removeFirst();
|
||||||
nextSetAsList.remove(nSaL);
|
nextSetAsList.remove(nSaL);
|
||||||
context.logger().debug("-1 RM" + nSaL.toString());
|
context.logger().debug(() -> "-1 RM" + nSaL.toString());
|
||||||
|
|
||||||
if (!this.isOderConstraint) {
|
if (!this.isOderConstraint) {
|
||||||
//ueberpruefung ob zu a =. ty \in nSaL in sameEqSet ein Widerspruch besteht
|
//ueberpruefung ob zu a =. ty \in nSaL in sameEqSet ein Widerspruch besteht
|
||||||
@@ -118,8 +118,8 @@ public class VarianceM1Case extends VarianceCase {
|
|||||||
if (typeUnifyTask.myIsCancelled()) {
|
if (typeUnifyTask.myIsCancelled()) {
|
||||||
throw new UnifyCancelException();
|
throw new UnifyCancelException();
|
||||||
}
|
}
|
||||||
context.logger().debug("fork_res: " + fork_res.toString());
|
context.logger().debug(() -> "fork_res: " + fork_res.toString());
|
||||||
context.logger().debug(Boolean.valueOf((typeUnifyTask.isUndefinedPairSetSet(fork_res))).toString());
|
context.logger().debug(() -> Boolean.valueOf((typeUnifyTask.isUndefinedPairSetSet(fork_res))).toString());
|
||||||
prevResults.getSecond().add(fork_res);
|
prevResults.getSecond().add(fork_res);
|
||||||
if (!typeUnifyTask.isUndefinedPairSetSet(fork_res)) {
|
if (!typeUnifyTask.isUndefinedPairSetSet(fork_res)) {
|
||||||
aParDef.add(fork.getNextSetElement());
|
aParDef.add(fork.getNextSetElement());
|
||||||
@@ -148,13 +148,13 @@ public class VarianceM1Case extends VarianceCase {
|
|||||||
) {
|
) {
|
||||||
int resOfCompare = typeUnifyTask.oup.compare(compResult, compRes);
|
int resOfCompare = typeUnifyTask.oup.compare(compResult, compRes);
|
||||||
if (resOfCompare == 1) {
|
if (resOfCompare == 1) {
|
||||||
context.logger().debug("Geloescht result: " + result);
|
context.logger().debug(() -> "Geloescht result: " + result);
|
||||||
result.clear();
|
result.clear();
|
||||||
result.addAll(currentThreadResult);
|
result.addAll(currentThreadResult);
|
||||||
} else if (resOfCompare == 0) {
|
} else if (resOfCompare == 0) {
|
||||||
result.addAll(currentThreadResult);
|
result.addAll(currentThreadResult);
|
||||||
} else if (resOfCompare == -1) {
|
} else if (resOfCompare == -1) {
|
||||||
context.logger().debug("Geloescht currentThreadResult: " + currentThreadResult);
|
context.logger().debug(() -> "Geloescht currentThreadResult: " + currentThreadResult);
|
||||||
//result = result;
|
//result = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,13 +167,13 @@ public class VarianceM1Case extends VarianceCase {
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
// context.logger().info("");
|
// context.logger().info("");
|
||||||
context.logger().debug("a: " + rekTiefe + " variance: " + variance + a.toString());
|
context.logger().debug(() -> "a: " + rekTiefe + " variance: " + variance + a.toString());
|
||||||
context.logger().debug("aParDef: " + aParDef.toString());
|
context.logger().debug(() -> "aParDef: " + aParDef.toString());
|
||||||
aParDef.add(a);
|
aParDef.add(a);
|
||||||
Iterator<Set<UnifyPair>> aParDefIt = aParDef.iterator();
|
Iterator<Set<UnifyPair>> aParDefIt = aParDef.iterator();
|
||||||
if (this.isOderConstraint) {
|
if (this.isOderConstraint) {
|
||||||
nextSetAsList.removeAll(nextSetasListOderConstraints);
|
nextSetAsList.removeAll(nextSetasListOderConstraints);
|
||||||
context.logger().debug("Removed: " + nextSetasListOderConstraints);
|
context.logger().debug(() -> "Removed: " + nextSetasListOderConstraints);
|
||||||
nextSetasListOderConstraints = new ArrayList<>();
|
nextSetasListOderConstraints = new ArrayList<>();
|
||||||
while (aParDefIt.hasNext()) {
|
while (aParDefIt.hasNext()) {
|
||||||
Set<UnifyPair> a_new = aParDefIt.next();
|
Set<UnifyPair> a_new = aParDefIt.next();
|
||||||
@@ -206,9 +206,9 @@ public class VarianceM1Case extends VarianceCase {
|
|||||||
erased.removeAll(notErased);
|
erased.removeAll(notErased);
|
||||||
nextSetAsList.removeAll(erased);
|
nextSetAsList.removeAll(erased);
|
||||||
|
|
||||||
context.logger().debug("Removed: " + erased);
|
context.logger().debug(() -> "Removed: " + erased);
|
||||||
|
|
||||||
context.logger().debug("Not Removed: " + nextSetAsList);
|
context.logger().debug(() -> "Not Removed: " + nextSetAsList);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -219,9 +219,9 @@ public class VarianceM1Case extends VarianceCase {
|
|||||||
|
|
||||||
nextSetAsList.removeAll(erased);
|
nextSetAsList.removeAll(erased);
|
||||||
|
|
||||||
context.logger().debug("Removed: " + erased);
|
context.logger().debug(() -> "Removed: " + erased);
|
||||||
|
|
||||||
context.logger().debug("Not Removed: " + nextSetAsList);
|
context.logger().debug(() -> "Not Removed: " + nextSetAsList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,12 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
|||||||
|
|
||||||
public class distributeVariance extends visitUnifyTypeVisitor<Integer> {
|
public class distributeVariance extends visitUnifyTypeVisitor<Integer> {
|
||||||
|
|
||||||
public static int inverseVariance(int variance) {
|
public static int inverseVariance(int variance) {
|
||||||
Integer ret = 0;
|
return switch (variance) {
|
||||||
if (variance == 1) {
|
case 1 -> -1;
|
||||||
ret = -1;
|
case -1 -> 1;
|
||||||
}
|
default -> 0;
|
||||||
if (variance == -1) {
|
};
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -42,7 +39,7 @@ public class distributeVariance extends visitUnifyTypeVisitor<Integer> {
|
|||||||
List<UnifyType> param = new ArrayList<>(funnty.getTypeParams().get().length);
|
List<UnifyType> param = new ArrayList<>(funnty.getTypeParams().get().length);
|
||||||
param.addAll(Arrays.asList(funnty.getTypeParams().get()));
|
param.addAll(Arrays.asList(funnty.getTypeParams().get()));
|
||||||
UnifyType resultType = param.remove(param.size()-1);
|
UnifyType resultType = param.remove(param.size()-1);
|
||||||
Integer htInverse = inverseVariance(ht);
|
int htInverse = inverseVariance(ht);
|
||||||
param = param.stream()
|
param = param.stream()
|
||||||
.map(x -> x.accept(this, htInverse))
|
.map(x -> x.accept(this, htInverse))
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
|||||||
@@ -693,7 +693,7 @@ public class FiniteClosure implements IFiniteClosure, ISerializableData {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public int compare (UnifyType left, UnifyType right, PairOperator pairop, UnifyContext context) {
|
public int compare (UnifyType left, UnifyType right, PairOperator pairop, UnifyContext context) {
|
||||||
logger.debug("left: "+ left + " right: " + right + " pairop: " + pairop +"\n");
|
logger.debug(() -> "left: "+ left + " right: " + right + " pairop: " + pairop +"\n");
|
||||||
// if (left.getName().equals("Matrix") || right.getName().equals("Matrix"))
|
// if (left.getName().equals("Matrix") || right.getName().equals("Matrix"))
|
||||||
// context.logger().info("");
|
// context.logger().info("");
|
||||||
/*
|
/*
|
||||||
@@ -752,7 +752,7 @@ public class FiniteClosure implements IFiniteClosure, ISerializableData {
|
|||||||
Set<UnifyPair> smallerRes = unifyTask.applyTypeUnificationRules(hs, this);
|
Set<UnifyPair> smallerRes = unifyTask.applyTypeUnificationRules(hs, this);
|
||||||
|
|
||||||
//if (left.getName().equals("Vector") || right.getName().equals("AbstractList"))
|
//if (left.getName().equals("Vector") || right.getName().equals("AbstractList"))
|
||||||
logger.debug("\nsmallerRes: " + smallerRes);//"smallerHash: " + greaterHash.toString());
|
logger.debug(() -> "\nsmallerRes: " + smallerRes);//"smallerHash: " + greaterHash.toString());
|
||||||
|
|
||||||
//Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok.
|
//Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok.
|
||||||
Predicate<UnifyPair> delFun = x -> !((x.getLhsType() instanceof PlaceholderType ||
|
Predicate<UnifyPair> delFun = x -> !((x.getLhsType() instanceof PlaceholderType ||
|
||||||
@@ -761,7 +761,7 @@ public class FiniteClosure implements IFiniteClosure, ISerializableData {
|
|||||||
((WildcardType)x.getLhsType()).getWildcardedType().equals(x.getRhsType()))
|
((WildcardType)x.getLhsType()).getWildcardedType().equals(x.getRhsType()))
|
||||||
);
|
);
|
||||||
long smallerLen = smallerRes.stream().filter(delFun).count();
|
long smallerLen = smallerRes.stream().filter(delFun).count();
|
||||||
logger.debug("\nsmallerLen: " + smallerLen +"\n");
|
logger.debug(() -> "\nsmallerLen: " + smallerLen +"\n");
|
||||||
if (smallerLen == 0) return -1;
|
if (smallerLen == 0) return -1;
|
||||||
else {
|
else {
|
||||||
up = new UnifyPair(right, left, pairop);
|
up = new UnifyPair(right, left, pairop);
|
||||||
@@ -771,7 +771,7 @@ public class FiniteClosure implements IFiniteClosure, ISerializableData {
|
|||||||
Set<UnifyPair> greaterRes = unifyTask.applyTypeUnificationRules(hs, this);
|
Set<UnifyPair> greaterRes = unifyTask.applyTypeUnificationRules(hs, this);
|
||||||
|
|
||||||
//if (left.getName().equals("Vector") || right.getName().equals("AbstractList"))
|
//if (left.getName().equals("Vector") || right.getName().equals("AbstractList"))
|
||||||
logger.debug("\ngreaterRes: " + greaterRes);//"smallerHash: " + greaterHash.toString());
|
logger.debug(() -> "\ngreaterRes: " + greaterRes);//"smallerHash: " + greaterHash.toString());
|
||||||
|
|
||||||
//Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok.
|
//Gleichungen der Form a <./=. Theta oder Theta <./=. a oder a <./=. b sind ok.
|
||||||
long greaterLen = greaterRes.stream().filter(delFun).count();
|
long greaterLen = greaterRes.stream().filter(delFun).count();
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class FunNType extends UnifyType implements ISerializableData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean wrongWildcard() {
|
public boolean wrongWildcard() {
|
||||||
return (new ArrayList<UnifyType>(Arrays.asList(getTypeParams()
|
return (new ArrayList<UnifyType>(Arrays.asList(getTypeParams()
|
||||||
.get())).stream().filter(x -> (x instanceof WildcardType)).findFirst().isPresent());
|
.get())).stream().filter(x -> (x instanceof WildcardType)).findFirst().isPresent());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
return fc.compare(left.getRhsType(), right.getRhsType(), PairOperator.SMALLERDOT, context);
|
return fc.compare(left.getRhsType(), right.getRhsType(), PairOperator.SMALLERDOT, context);
|
||||||
}}
|
}}
|
||||||
catch (ClassCastException e) {
|
catch (ClassCastException e) {
|
||||||
((FiniteClosure)fc).logger.debug("ClassCastException: " + left.toString() + " " + left.getGroundBasePair() + "\n\n");
|
((FiniteClosure)fc).logger.debug(() -> "ClassCastException: " + left.toString() + " " + left.getGroundBasePair() + "\n\n");
|
||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,7 +270,7 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Integer 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();
|
||||||
if ((compareEq = compareEq(lefteqOder.iterator().next().getGroundBasePair(), righteqOder.iterator().next().getGroundBasePair())) == -1) {
|
if ((compareEq = compareEq(lefteqOder.iterator().next().getGroundBasePair(), righteqOder.iterator().next().getGroundBasePair())) == -1) {
|
||||||
@@ -332,27 +332,27 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (lefteq.size() == 1 && lefteq.iterator().next().getRhsType() instanceof ExtendsType && leftle.size() == 1 && righteq.size() == 0 && rightle.size() == 1) {
|
if (lefteq.size() == 1 && lefteq.iterator().next().getRhsType() instanceof ExtendsType && leftle.size() == 1 && righteq.isEmpty() && rightle.size() == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//Fall 2
|
//Fall 2
|
||||||
if (lefteq.size() == 0 && leftle.size() == 1 && righteq.size() == 1 && righteq.iterator().next().getRhsType() instanceof ExtendsType && rightle.size() == 1) {
|
if (lefteq.isEmpty() && leftle.size() == 1 && righteq.size() == 1 && righteq.iterator().next().getRhsType() instanceof ExtendsType && rightle.size() == 1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//Fall 3
|
//Fall 3
|
||||||
if (lefteq.size() == 1 && lefteq.iterator().next().getRhsType() instanceof SuperType && leftle.size() == 1 && righteq.size() == 0 && rightle.size() == 1) {
|
if (lefteq.size() == 1 && lefteq.iterator().next().getRhsType() instanceof SuperType && leftle.size() == 1 && righteq.isEmpty() && rightle.size() == 1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//Fall 3
|
//Fall 3
|
||||||
if (lefteq.size() == 0 && leftle.size() == 1 && righteq.size() == 1 && righteq.iterator().next().getRhsType() instanceof SuperType && rightle.size() == 1) {
|
if (lefteq.isEmpty() && leftle.size() == 1 && righteq.size() == 1 && righteq.iterator().next().getRhsType() instanceof SuperType && rightle.size() == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//Fall 5
|
//Fall 5
|
||||||
if (lefteq.size() == 1 && leftle.size() == 0 && righteq.size() == 1 && rightle.size() == 1) {
|
if (lefteq.size() == 1 && leftle.isEmpty() && righteq.size() == 1 && rightle.size() == 1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//Fall 5
|
//Fall 5
|
||||||
if (lefteq.size() == 1 && leftle.size() == 1 && righteq.size() == 1 && rightle.size() == 0) {
|
if (lefteq.size() == 1 && leftle.size() == 1 && righteq.size() == 1 && rightle.isEmpty()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//Fall 5
|
//Fall 5
|
||||||
@@ -360,7 +360,7 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// Nur Paare a =. Theta
|
// Nur Paare a =. Theta
|
||||||
if (leftle.size() == 0 && rightle.size() == 0 && leftlewc.size() == 0 && rightlewc.size() ==0) {
|
if (leftle.isEmpty() && rightle.isEmpty() && leftlewc.isEmpty() && rightlewc.isEmpty()) {
|
||||||
Stream<UnifyPair> lseq = lefteq.stream(); //left.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT));
|
Stream<UnifyPair> lseq = lefteq.stream(); //left.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT));
|
||||||
Stream<UnifyPair> rseq = righteq.stream(); //right.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT));
|
Stream<UnifyPair> rseq = righteq.stream(); //right.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT));
|
||||||
BinaryOperator<HashMap<UnifyType,UnifyPair>> combiner = (x,y) -> { x.putAll(y); return x;};
|
BinaryOperator<HashMap<UnifyType,UnifyPair>> combiner = (x,y) -> { x.putAll(y); return x;};
|
||||||
@@ -368,11 +368,10 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
lseq = lseq.filter(x -> !(hm.get(x.getLhsType()) == null));//NOCHMALS UEBERPRUEFEN!!!!
|
lseq = lseq.filter(x -> !(hm.get(x.getLhsType()) == null));//NOCHMALS UEBERPRUEFEN!!!!
|
||||||
lseq = lseq.filter(x -> !x.equals(hm.get(x.getLhsType()))); //Elemente die gleich sind muessen nicht verglichen werden
|
lseq = lseq.filter(x -> !x.equals(hm.get(x.getLhsType()))); //Elemente die gleich sind muessen nicht verglichen werden
|
||||||
Optional<Integer> si = lseq.map(x -> compareEq(x, hm.get(x.getLhsType()))).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
Optional<Integer> si = lseq.map(x -> compareEq(x, hm.get(x.getLhsType()))).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
||||||
if (!si.isPresent()) return 0;
|
return si.orElse(0);
|
||||||
else return si.get();
|
|
||||||
}
|
}
|
||||||
//Fall 1 und 4
|
//Fall 1 und 4
|
||||||
if (lefteq.size() >= 1 && righteq.size() >= 1 && (leftlewc.size() > 0 || rightlewc.size() > 0)) {
|
if (!lefteq.isEmpty() && !righteq.isEmpty() && (!leftlewc.isEmpty() || !rightlewc.isEmpty())) {
|
||||||
//Set<PlaceholderType> varsleft = lefteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new));
|
//Set<PlaceholderType> varsleft = lefteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new));
|
||||||
//Set<PlaceholderType> varsright = righteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new));
|
//Set<PlaceholderType> 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
|
//filtern des Paares a = Theta, das durch a <. Thata' generiert wurde (nur im Fall 1 relevant) andere Substitutioen werden rausgefiltert
|
||||||
@@ -395,7 +394,7 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
Unifier uni = new Unifier();
|
Unifier uni = new Unifier();
|
||||||
int_Unifier.getValue().get().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.size() == 0 || rightlewc.size() == 0) return int_Unifier.getKey();
|
|| leftlewc.isEmpty() || rightlewc.isEmpty()) return int_Unifier.getKey();
|
||||||
else {
|
else {
|
||||||
Set <UnifyPair> lsleuni = leftlewc.stream().map(x -> uni.apply(x)).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(x -> uni.apply(x)).collect(Collectors.toCollection(HashSet::new));
|
Set <UnifyPair> rsleuni = rightlewc.stream().map(x -> uni.apply(x)).collect(Collectors.toCollection(HashSet::new));
|
||||||
@@ -415,11 +414,10 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
|
|||||||
Stream<UnifyPair> lslewcstr = lsleuni.stream().filter(x -> !(hm.get(x.getRhsType()) == null));
|
Stream<UnifyPair> lslewcstr = lsleuni.stream().filter(x -> !(hm.get(x.getRhsType()) == null));
|
||||||
si = lslewcstr.map(x -> fc.compare(x.getLhsType(), hm.get(x.getRhsType()).getLhsType(), PairOperator.SMALLERDOTWC, context)).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
si = lslewcstr.map(x -> fc.compare(x.getLhsType(), hm.get(x.getRhsType()).getLhsType(), PairOperator.SMALLERDOTWC, context)).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
||||||
}
|
}
|
||||||
if (!si.isPresent()) return 0;
|
return si.orElse(0);
|
||||||
else return si.get();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (leftlewc.size() > 0) {
|
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) {
|
||||||
|
|||||||
@@ -134,15 +134,15 @@ public final class PlaceholderType extends UnifyType{
|
|||||||
wildcardable = true;
|
wildcardable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWildcardtable(Boolean wildcardable) {
|
public void setWildcardtable(boolean wildcardable) {
|
||||||
this.wildcardable = wildcardable;
|
this.wildcardable = wildcardable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isInnerType() {
|
public boolean isInnerType() {
|
||||||
return innerType;
|
return innerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInnerType(Boolean innerType) {
|
public void setInnerType(boolean innerType) {
|
||||||
this.innerType = innerType;
|
this.innerType = innerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class ReferenceType extends UnifyType implements ISerializableData {
|
|||||||
return visitor.visit(this, ht);
|
return visitor.visit(this, ht);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReferenceType(String name, Boolean genericTypeVar) {
|
public ReferenceType(String name, boolean genericTypeVar) {
|
||||||
super(name, new TypeParams());
|
super(name, new TypeParams());
|
||||||
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
||||||
this.genericTypeVar = genericTypeVar;
|
this.genericTypeVar = genericTypeVar;
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class UnifyPair implements IConstraintElement, ISerializableData {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean wrongWildcard() {
|
public boolean wrongWildcard() {
|
||||||
return lhs.wrongWildcard() || rhs.wrongWildcard();
|
return lhs.wrongWildcard() || rhs.wrongWildcard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public abstract class UnifyType implements ISerializableData {
|
|||||||
return new ArrayList<>(typeParams.getInvolvedPlaceholderTypes());
|
return new ArrayList<>(typeParams.getInvolvedPlaceholderTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean wrongWildcard() {//default
|
public boolean wrongWildcard() {//default
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public abstract class WildcardType extends UnifyType implements ISerializableDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean wrongWildcard () {//This is an error
|
public boolean wrongWildcard () {//This is an error
|
||||||
return (wildcardedType instanceof WildcardType);
|
return (wildcardedType instanceof WildcardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.io.Writer;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.diogonunes.jcolor.Ansi.colorize;
|
import static com.diogonunes.jcolor.Ansi.colorize;
|
||||||
@@ -90,6 +91,10 @@ public class Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLogLevelActive(LogLevel logLevel) {
|
||||||
|
return logLevel.value >= ConsoleInterface.logLevel.value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write text to the attached writer, if there is any
|
* Write text to the attached writer, if there is any
|
||||||
* @param s The string to print
|
* @param s The string to print
|
||||||
@@ -117,11 +122,22 @@ public class Logger {
|
|||||||
* @param logLevel The logLevel on which the text should be logged
|
* @param logLevel The logLevel on which the text should be logged
|
||||||
*/
|
*/
|
||||||
public void log(String s, LogLevel logLevel) {
|
public void log(String s, LogLevel logLevel) {
|
||||||
if (logLevel.value >= ConsoleInterface.logLevel.value) {
|
if (isLogLevelActive(logLevel)) {
|
||||||
this.print(s, logLevel);
|
this.print(s, logLevel);
|
||||||
this.write(s);
|
this.write(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void log(Supplier<String> supp, LogLevel logLevel) {
|
||||||
|
if (isLogLevelActive(logLevel)) {
|
||||||
|
this.log(supp.get(), logLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void log(Object obj, LogLevel logLevel) {
|
||||||
|
if (isLogLevelActive(logLevel)) {
|
||||||
|
this.log(obj.toString(), logLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces the old FileWriter.write() call
|
* Replaces the old FileWriter.write() call
|
||||||
@@ -131,7 +147,10 @@ public class Logger {
|
|||||||
this.log(s, LogLevel.DEBUG);
|
this.log(s, LogLevel.DEBUG);
|
||||||
}
|
}
|
||||||
public void debug(Object o) {
|
public void debug(Object o) {
|
||||||
this.debug(o.toString());
|
this.log(o, LogLevel.DEBUG);
|
||||||
|
}
|
||||||
|
public void debug(Supplier<String> supp) {
|
||||||
|
this.log(supp, LogLevel.DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,7 +161,10 @@ public class Logger {
|
|||||||
this.log(s, LogLevel.INFO);
|
this.log(s, LogLevel.INFO);
|
||||||
}
|
}
|
||||||
public void info(Object o) {
|
public void info(Object o) {
|
||||||
this.info(o.toString());
|
this.log(o, LogLevel.INFO);
|
||||||
|
}
|
||||||
|
public void info(Supplier<String> supp) {
|
||||||
|
this.log(supp, LogLevel.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,7 +175,10 @@ public class Logger {
|
|||||||
this.log(s, LogLevel.WARNING);
|
this.log(s, LogLevel.WARNING);
|
||||||
}
|
}
|
||||||
public void warn(Object o) {
|
public void warn(Object o) {
|
||||||
this.warn(o.toString());
|
this.log(o, LogLevel.WARNING);
|
||||||
|
}
|
||||||
|
public void warn(Supplier<String> supp) {
|
||||||
|
this.log(supp, LogLevel.WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +189,10 @@ public class Logger {
|
|||||||
this.log(s, LogLevel.ERROR);
|
this.log(s, LogLevel.ERROR);
|
||||||
}
|
}
|
||||||
public void error(Object o) {
|
public void error(Object o) {
|
||||||
this.error(o.toString());
|
this.log(o, LogLevel.ERROR);
|
||||||
|
}
|
||||||
|
public void error(Supplier<String> supp) {
|
||||||
|
this.log(supp, LogLevel.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user