-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from ftsrg/xstsenums
Xsts type system rework, custom type serialization bugfix
- v6.11.3
- v6.11.2
- v6.11.1
- v6.11.0
- v6.10.1
- v6.10.0
- v6.9.0
- v6.8.6
- v6.8.5
- v6.8.2
- v6.8.1
- v6.7.2
- v6.7.0
- v6.6.6
- v6.6.5
- v6.6.4
- v6.6.2
- v6.6.1
- v6.6.0
- v6.5.2
- v6.5.1
- v6.5.0
- v6.4.0
- v6.3.4
- v6.3.3
- v6.3.2
- v6.3.1
- v6.3.0
- v6.2.1
- v6.2.0
- v6.1.0
- v6.0.0
- v5.4.0
- v5.3.0
- v5.2.1
- v5.2.0
- v5.1.1
- v5.1.0
- v5.0.6
- v5.0.5
- v5.0.4
- v5.0.3
- v5.0.2
- v5.0.1
- v4.4.4
- v4.4.3
- v4.4.2
- v4.4.1
- v4.4.0
- v4.3.0
- v4.2.5
- v4.2.3
- v4.2.2
- v4.2.1
- v4.2.0
- v4.1.0
- v4.0.3
- v4.0.0
- v3.0.2
- v3.0.1
- v3.0.0
- v2.23.0
- v2.22.3
- v2.22.2
- svcomp25
- svcomp24
- svcomp23
- svcomp22-v1
- svcomp22-qualification4
- svcomp22-qualification3
- svcomp22-qualification2
- svcomp22-qualification
- spin24
- 4.2.3
Showing
19 changed files
with
353 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
subprojects/xsts/xsts/src/main/java/hu/bme/mit/theta/xsts/dsl/XstsCustomLiteralSymbol.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package hu.bme.mit.theta.xsts.dsl; | ||
|
||
import hu.bme.mit.theta.common.dsl.Symbol; | ||
import hu.bme.mit.theta.core.type.Expr; | ||
import hu.bme.mit.theta.xsts.type.XstsCustomType; | ||
|
||
import java.math.BigInteger; | ||
|
||
import static hu.bme.mit.theta.core.type.inttype.IntExprs.Int; | ||
|
||
public class XstsCustomLiteralSymbol implements Symbol { | ||
|
||
private final XstsCustomType.XstsCustomLiteral literal; | ||
|
||
private static int counter = 0; | ||
|
||
public XstsCustomLiteralSymbol(String name) { | ||
this.literal = XstsCustomType.XstsCustomLiteral.of(name, BigInteger.valueOf(counter++)); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return literal.getName(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return literal.toString(); | ||
} | ||
|
||
public Expr instantiate(){ | ||
return Int(literal.getIntValue()); | ||
} | ||
|
||
public XstsCustomType.XstsCustomLiteral getLiteral() { | ||
return literal; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
subprojects/xsts/xsts/src/main/java/hu/bme/mit/theta/xsts/dsl/XstsCustomTypeSymbol.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package hu.bme.mit.theta.xsts.dsl; | ||
|
||
import hu.bme.mit.theta.common.dsl.Symbol; | ||
import hu.bme.mit.theta.core.type.Type; | ||
import hu.bme.mit.theta.xsts.type.XstsCustomType; | ||
|
||
import java.util.Objects; | ||
|
||
public final class XstsCustomTypeSymbol implements Symbol { | ||
|
||
private XstsCustomType xstsType; | ||
|
||
private XstsCustomTypeSymbol(final XstsCustomType xstsType) { | ||
this.xstsType =xstsType; | ||
} | ||
|
||
public static XstsCustomTypeSymbol of(final XstsCustomType xstsType) { | ||
return new XstsCustomTypeSymbol(xstsType); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(xstsType); | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} else if (obj instanceof XstsCustomTypeSymbol) { | ||
final XstsCustomTypeSymbol that = (XstsCustomTypeSymbol) obj; | ||
return this.xstsType.equals(that.xstsType); | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return xstsType.toString(); | ||
} | ||
|
||
public XstsCustomType getXstsType(){ | ||
return xstsType; | ||
} | ||
|
||
@Override | ||
public String getName() { return xstsType.getName(); } | ||
|
||
public Type instantiate() { | ||
return xstsType.getType(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
subprojects/xsts/xsts/src/main/java/hu/bme/mit/theta/xsts/dsl/XstsTypeDeclSymbol.java
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
subprojects/xsts/xsts/src/main/java/hu/bme/mit/theta/xsts/dsl/XstsTypeLiteralSymbol.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
subprojects/xsts/xsts/src/main/java/hu/bme/mit/theta/xsts/type/XstsArrayType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package hu.bme.mit.theta.xsts.type; | ||
|
||
import com.google.common.base.Preconditions; | ||
import hu.bme.mit.theta.common.Utils; | ||
import hu.bme.mit.theta.core.decl.VarDecl; | ||
import hu.bme.mit.theta.core.type.Expr; | ||
import hu.bme.mit.theta.core.type.LitExpr; | ||
import hu.bme.mit.theta.core.type.Type; | ||
import hu.bme.mit.theta.core.type.arraytype.ArrayLitExpr; | ||
import hu.bme.mit.theta.core.type.arraytype.ArrayType; | ||
import hu.bme.mit.theta.core.type.booltype.BoolType; | ||
|
||
import static hu.bme.mit.theta.core.type.arraytype.ArrayExprs.Array; | ||
import static hu.bme.mit.theta.core.type.booltype.BoolExprs.True; | ||
|
||
public final class XstsArrayType<IndexType extends Type, ElemType extends Type> implements XstsType<ArrayType<IndexType, ElemType>> { | ||
private final XstsType<IndexType> indexType; | ||
private final XstsType<ElemType> elemType; | ||
private ArrayType<IndexType,ElemType> type; | ||
|
||
private XstsArrayType(XstsType<IndexType> indexType, XstsType<ElemType> elemType) { | ||
this.indexType = indexType; | ||
this.elemType = elemType; | ||
this.type = Array(indexType.getType(), elemType.getType()); | ||
} | ||
|
||
public static <IndexType extends Type, ElemType extends Type> XstsArrayType<IndexType, ElemType> of(XstsType<IndexType> indexType, XstsType<ElemType> elemType) { | ||
return new XstsArrayType<>(indexType, elemType); | ||
} | ||
|
||
public ArrayType<IndexType, ElemType> getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public Expr<BoolType> createBoundExpr(VarDecl<ArrayType<IndexType, ElemType>> decl) { | ||
return True(); | ||
} | ||
|
||
@Override | ||
public String serializeLiteral(LitExpr<ArrayType<IndexType, ElemType>> literal) { | ||
Preconditions.checkArgument(literal.getType().equals(type)); | ||
final ArrayLitExpr<IndexType,ElemType> arrayLitExpr = (ArrayLitExpr<IndexType,ElemType>) literal; | ||
return Utils.lispStringBuilder("array") | ||
.addAll(arrayLitExpr.getElements().stream().map(elem -> String.format("(%s %s)", indexType.serializeLiteral(elem.get1()), elemType.serializeLiteral(elem.get2())))) | ||
.add((String.format("(default %s)", elemType.serializeLiteral(arrayLitExpr.getElseElem())))) | ||
.toString(); | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
subprojects/xsts/xsts/src/main/java/hu/bme/mit/theta/xsts/type/XstsCustomType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package hu.bme.mit.theta.xsts.type; | ||
|
||
import com.google.common.base.Preconditions; | ||
import hu.bme.mit.theta.core.decl.VarDecl; | ||
import hu.bme.mit.theta.core.type.Expr; | ||
import hu.bme.mit.theta.core.type.LitExpr; | ||
import hu.bme.mit.theta.core.type.booltype.BoolType; | ||
import hu.bme.mit.theta.core.type.inttype.IntLitExpr; | ||
import hu.bme.mit.theta.core.type.inttype.IntType; | ||
|
||
import java.math.BigInteger; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static hu.bme.mit.theta.core.type.abstracttype.AbstractExprs.Eq; | ||
import static hu.bme.mit.theta.core.type.booltype.BoolExprs.Or; | ||
import static hu.bme.mit.theta.core.type.inttype.IntExprs.Int; | ||
|
||
public final class XstsCustomType implements XstsType<IntType> { | ||
private final String name; | ||
private final List<XstsCustomLiteral> literals; | ||
|
||
private XstsCustomType(final String name, final List<XstsCustomLiteral> literals) { | ||
this.name = name; | ||
this.literals = literals; | ||
} | ||
|
||
public static XstsCustomType of(final String name, final List<XstsCustomLiteral> literals) { | ||
return new XstsCustomType(name, literals); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public List<XstsCustomLiteral> getLiterals() { | ||
return literals; | ||
} | ||
|
||
public static final class XstsCustomLiteral { | ||
private final BigInteger intValue; | ||
private final String name; | ||
|
||
private XstsCustomLiteral(String name, BigInteger intValue) { | ||
this.name = name; | ||
this.intValue = intValue; | ||
} | ||
|
||
public static XstsCustomLiteral of(String name, BigInteger intValue) { | ||
return new XstsCustomLiteral(name, intValue); | ||
} | ||
|
||
public BigInteger getIntValue() { | ||
return intValue; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} | ||
|
||
public IntType getType() { | ||
return Int(); | ||
} | ||
|
||
@Override | ||
public Expr<BoolType> createBoundExpr(VarDecl<IntType> decl) { | ||
return Or(literals.stream() | ||
.map(lit -> Eq(decl.getRef(), Int(lit.getIntValue()))) | ||
.collect(Collectors.toList())); | ||
} | ||
|
||
@Override | ||
public String serializeLiteral(LitExpr<IntType> literal) { | ||
final IntLitExpr intLitExpr = (IntLitExpr) literal; | ||
final var customLiteral = literals.stream().filter(lit -> lit.getIntValue().equals(intLitExpr.getValue())).findFirst(); | ||
Preconditions.checkArgument(customLiteral.isPresent(), "Literal %s not found", intLitExpr.getValue()); | ||
return customLiteral.get().getName(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
subprojects/xsts/xsts/src/main/java/hu/bme/mit/theta/xsts/type/XstsPrimitiveType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package hu.bme.mit.theta.xsts.type; | ||
|
||
import com.google.common.base.Preconditions; | ||
import hu.bme.mit.theta.core.decl.VarDecl; | ||
import hu.bme.mit.theta.core.type.Expr; | ||
import hu.bme.mit.theta.core.type.LitExpr; | ||
import hu.bme.mit.theta.core.type.Type; | ||
import hu.bme.mit.theta.core.type.booltype.BoolType; | ||
|
||
import static hu.bme.mit.theta.core.type.booltype.BoolExprs.True; | ||
|
||
public final class XstsPrimitiveType<T extends Type> implements XstsType<T> { | ||
private final T type; | ||
|
||
private XstsPrimitiveType(T type) { | ||
this.type = type; | ||
} | ||
|
||
public static <T extends Type> XstsPrimitiveType<T> of(T type) { | ||
return new XstsPrimitiveType<>(type); | ||
} | ||
|
||
@Override | ||
public T getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public Expr<BoolType> createBoundExpr(VarDecl<T> decl) { | ||
return True(); | ||
} | ||
|
||
@Override | ||
public String serializeLiteral(LitExpr<T> literal) { | ||
Preconditions.checkArgument(literal.getType().equals(type)); | ||
return literal.toString(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
subprojects/xsts/xsts/src/main/java/hu/bme/mit/theta/xsts/type/XstsType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package hu.bme.mit.theta.xsts.type; | ||
|
||
import hu.bme.mit.theta.core.decl.VarDecl; | ||
import hu.bme.mit.theta.core.type.Expr; | ||
import hu.bme.mit.theta.core.type.LitExpr; | ||
import hu.bme.mit.theta.core.type.Type; | ||
import hu.bme.mit.theta.core.type.booltype.BoolType; | ||
|
||
public interface XstsType<T extends Type> { | ||
|
||
T getType(); | ||
|
||
Expr<BoolType> createBoundExpr(final VarDecl<T> decl); | ||
|
||
String serializeLiteral(final LitExpr<T> literal); | ||
|
||
} |