3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-01-12 05:36:16 +00:00
z3/src/api/java/TupleSort.java
Addison Crump 3bca1fbcd8
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
2020-11-30 10:04:54 -08:00

67 lines
1.5 KiB
Java

/**
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
TupleSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
/**
* Tuple sorts.
**/
public class TupleSort extends Sort
{
/**
* The constructor function of the tuple.
* @throws Z3Exception
**/
public FuncDecl<TupleSort> mkDecl()
{
return new FuncDecl<>(getContext(), Native.getTupleSortMkDecl(getContext()
.nCtx(), getNativeObject()));
}
/**
* The number of fields in the tuple.
**/
public int getNumFields()
{
return Native.getTupleSortNumFields(getContext().nCtx(), getNativeObject());
}
/**
* The field declarations.
* @throws Z3Exception
**/
public FuncDecl<?>[] getFieldDecls()
{
int n = getNumFields();
FuncDecl<?>[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl<>(getContext(), Native.getTupleSortFieldDecl(
getContext().nCtx(), getNativeObject(), i));
return res;
}
TupleSort(Context ctx, Symbol name, int numFields, Symbol[] fieldNames,
Sort[] fieldSorts)
{
super(ctx, Native.mkTupleSort(ctx.nCtx(), name.getNativeObject(),
numFields, Symbol.arrayToNative(fieldNames),
AST.arrayToNative(fieldSorts), new Native.LongPtr(),
new long[numFields]));
}
};