3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-11-25 23:19:32 +00:00

Java type generics (#4832)

* Generify, needs some testing and review

* Remove unnecessary change

* Whoops, ? capture that type

* Misread the docs, whoops

* More permissible arithmetic operations

* Implement believed Optimize generics

* Missed a few generics

* More permissible expr for arrays in parameters

* More permissible expr for bitvecs in parameters

* More permissible expr for bools in parameters

* More permissible expr for fps in parameters

* More permissible expr for fprms in parameters

* More permissible expr for ints in parameters

* More permissible expr for reals in parameters

* Undo breaking name conflict due to type erasure; see notes

* Whoops, fix typing of ReExpr

* Sort corrections for Re, Seq

* More permissible expr for regular expressions in parameters

* Fix name conflict between sequences and regular expressions; see notes

* Minor typo, big implications!

* Make Constructor consistent, associate captured types with other unknown capture types for datatype consistency

* More expressive; outputs of multiple datatype definitions are only known to be sort, not capture, and Constructor.of should make a capture

* Be less dumb and just type it a little differently

* Update examples, make sure to type Expr and FuncDecl sort returns

* General fixups

* Downgrade java version, make it only for the generic support, remove var and Expr[]::new construction

* Turns out Java 8 hadn't figured out how to do stream generics yet. Didn't even show up in my IDE, weird
This commit is contained in:
Addison Crump 2020-11-30 12:04:54 -06:00 committed by GitHub
parent bb24b3f2be
commit 3bca1fbcd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 2724 additions and 588 deletions

View file

@ -126,9 +126,9 @@ public class ASTVector extends Z3Object {
/**
* Translates the AST vector into an Expr[]
* */
public Expr[] ToExprArray() {
public Expr<?>[] ToExprArray() {
int n = size();
Expr[] res = new Expr[n];
Expr<?>[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.create(getContext(), get(i).getNativeObject());
return res;
@ -161,36 +161,36 @@ public class ASTVector extends Z3Object {
/**
* Translates the AST vector into an ArithExpr[]
* */
public ArithExpr[] ToArithExprExprArray()
public ArithExpr<?>[] ToArithExprExprArray()
{
int n = size();
ArithExpr[] res = new ArithExpr[n];
ArithExpr<?>[] res = new ArithExpr[n];
for (int i = 0; i < n; i++)
res[i] = (ArithExpr)Expr.create(getContext(), get(i).getNativeObject());
res[i] = (ArithExpr<?>)Expr.create(getContext(), get(i).getNativeObject());
return res;
}
/**
* Translates the AST vector into an ArrayExpr[]
* */
public ArrayExpr[] ToArrayExprArray()
public ArrayExpr<?, ?>[] ToArrayExprArray()
{
int n = size();
ArrayExpr[] res = new ArrayExpr[n];
ArrayExpr<?, ?>[] res = new ArrayExpr[n];
for (int i = 0; i < n; i++)
res[i] = (ArrayExpr)Expr.create(getContext(), get(i).getNativeObject());
res[i] = (ArrayExpr<?, ?>)Expr.create(getContext(), get(i).getNativeObject());
return res;
}
/**
* Translates the AST vector into an DatatypeExpr[]
* */
public DatatypeExpr[] ToDatatypeExprArray()
public DatatypeExpr<?>[] ToDatatypeExprArray()
{
int n = size();
DatatypeExpr[] res = new DatatypeExpr[n];
DatatypeExpr<?>[] res = new DatatypeExpr[n];
for (int i = 0; i < n; i++)
res[i] = (DatatypeExpr)Expr.create(getContext(), get(i).getNativeObject());
res[i] = (DatatypeExpr<?>)Expr.create(getContext(), get(i).getNativeObject());
return res;
}