Skip to content
Snippets Groups Projects
Commit bd10bf5b authored by Jan Gruteser's avatar Jan Gruteser
Browse files

minor simplifications in TLATypes

parent 0a920dfc
Branches
Tags
No related merge requests found
Pipeline #144886 passed
package de.tla2b.types;
import de.be4.classicalb.core.parser.node.AMultOrCartExpression;
import de.be4.classicalb.core.parser.node.PExpression;
import de.tla2b.exceptions.UnificationException;
......@@ -107,33 +106,22 @@ public class PairType extends AbstractHasFollowers {
@Override
public PairType cloneTLAType() {
return new PairType(this.first.cloneTLAType(),
this.second.cloneTLAType());
return new PairType(this.first.cloneTLAType(), this.second.cloneTLAType());
}
@Override
public boolean contains(TLAType o) {
return first.equals(o) || first.contains(o) || second.equals(o)
|| second.contains(o);
return first.equals(o) || first.contains(o) || second.equals(o) || second.contains(o);
}
@Override
public String toString() {
String res = first + "*";
if (second instanceof PairType) {
res += "(" + second + ")";
} else
res += second;
return res;
return first + "*" + (second instanceof PairType ? "(" + second + ")" : second);
}
@Override
public PExpression getBNode() {
AMultOrCartExpression card = new AMultOrCartExpression();
card.setLeft(first.getBNode());
card.setRight(second.getBNode());
return card;
return new AMultOrCartExpression(first.getBNode(), second.getBNode());
}
public void apply(TypeVisitorInterface visitor) {
......
......@@ -25,7 +25,6 @@ public class StringType extends TLAType {
return o.compare(this);
} else
return false;
}
@Override
......@@ -38,22 +37,15 @@ public class StringType extends TLAType {
if (!this.compare(o)) {
throw new UnificationException();
}
if (o.getKind() == STRING) {
return this;
} else if (o instanceof UntypedType) {
if (o instanceof UntypedType) {
((UntypedType) o).setFollowersTo(this);
((UntypedType) o).deleteFollowers();
return this;
} else if (o instanceof FunctionType) {
// function
if (o instanceof AbstractHasFollowers) {
((AbstractHasFollowers) o).setFollowersTo(this);
((AbstractHasFollowers) o).deleteFollowers();
((FunctionType) o).setFollowersTo(this);
((FunctionType) o).deleteFollowers();
}
return this;
} else {
throw new UnificationException();
}
}
@Override
......
......@@ -155,8 +155,7 @@ public class StructOrFunctionType extends AbstractHasFollowers {
this.types.put(field, type);
}
}
TLAType res = testRecord();
return res;
return testRecord();
}
return this;
}
......
......@@ -104,8 +104,8 @@ public class StructType extends AbstractHasFollowers {
if (o instanceof StructType) {
StructType otherStruct = (StructType) o;
boolean extendStruct = false;
boolean extendStruct;
if (this.incompleteStruct && otherStruct.incompleteStruct) {
extendStruct = false;
} else if (this.incompleteStruct) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment