mirror of
https://github.com/Z3Prover/z3
synced 2026-03-17 02:30:01 +00:00
Fix high and medium priority API coherence issues (Go, Java, C++, TypeScript) (#8983)
* Initial plan * Add missing API functions to Go, Java, C++, and TypeScript bindings Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
b8e15f2121
commit
21bfb115ea
9 changed files with 337 additions and 0 deletions
|
|
@ -1024,6 +1024,16 @@ export function createApi(Z3: Z3Core, em?: any): Z3HighLevel {
|
|||
val(value: string): Seq<Name> {
|
||||
return new SeqImpl(check(Z3.mk_string(contextPtr, value)));
|
||||
},
|
||||
|
||||
fromCode(code: Arith<Name> | number | bigint): Seq<Name> {
|
||||
const codeExpr = isArith(code) ? code : Int.val(code);
|
||||
return new SeqImpl(check(Z3.mk_string_from_code(contextPtr, codeExpr.ast)));
|
||||
},
|
||||
|
||||
fromInt(n: Arith<Name> | number | bigint): Seq<Name> {
|
||||
const nExpr = isArith(n) ? n : Int.val(n);
|
||||
return new SeqImpl(check(Z3.mk_int_to_str(contextPtr, nExpr.ast)));
|
||||
},
|
||||
};
|
||||
|
||||
const Seq = {
|
||||
|
|
@ -4384,6 +4394,34 @@ export function createApi(Z3: Z3Core, em?: any): Z3HighLevel {
|
|||
const dstSeq = isSeq(dst) ? dst : String.val(dst);
|
||||
return new SeqImpl<ElemSort>(check(Z3.mk_seq_replace_all(contextPtr, this.ast, srcSeq.ast, dstSeq.ast)));
|
||||
}
|
||||
|
||||
replaceRe(re: Re<Name>, dst: Seq<Name, ElemSort> | string): Seq<Name, ElemSort> {
|
||||
const dstSeq = isSeq(dst) ? dst : String.val(dst);
|
||||
return new SeqImpl<ElemSort>(check(Z3.mk_seq_replace_re(contextPtr, this.ast, re.ast, dstSeq.ast)));
|
||||
}
|
||||
|
||||
replaceReAll(re: Re<Name>, dst: Seq<Name, ElemSort> | string): Seq<Name, ElemSort> {
|
||||
const dstSeq = isSeq(dst) ? dst : String.val(dst);
|
||||
return new SeqImpl<ElemSort>(check(Z3.mk_seq_replace_re_all(contextPtr, this.ast, re.ast, dstSeq.ast)));
|
||||
}
|
||||
|
||||
toInt(): Arith<Name> {
|
||||
return new ArithImpl(check(Z3.mk_str_to_int(contextPtr, this.ast)));
|
||||
}
|
||||
|
||||
toCode(): Arith<Name> {
|
||||
return new ArithImpl(check(Z3.mk_string_to_code(contextPtr, this.ast)));
|
||||
}
|
||||
|
||||
lt(other: Seq<Name, ElemSort> | string): Bool<Name> {
|
||||
const otherSeq = isSeq(other) ? other : String.val(other);
|
||||
return new BoolImpl(check(Z3.mk_str_lt(contextPtr, this.ast, otherSeq.ast)));
|
||||
}
|
||||
|
||||
le(other: Seq<Name, ElemSort> | string): Bool<Name> {
|
||||
const otherSeq = isSeq(other) ? other : String.val(other);
|
||||
return new BoolImpl(check(Z3.mk_str_le(contextPtr, this.ast, otherSeq.ast)));
|
||||
}
|
||||
}
|
||||
|
||||
class ReSortImpl<SeqSortRef extends SeqSort<Name> = SeqSort<Name>> extends SortImpl implements ReSort<Name, SeqSortRef> {
|
||||
|
|
|
|||
|
|
@ -3483,6 +3483,16 @@ export interface StringCreation<Name extends string> {
|
|||
* Create a string value
|
||||
*/
|
||||
val(value: string): Seq<Name>;
|
||||
|
||||
/**
|
||||
* Create a single-character string from a Unicode code point (str.from_code).
|
||||
*/
|
||||
fromCode(code: Arith<Name> | number | bigint): Seq<Name>;
|
||||
|
||||
/**
|
||||
* Convert an integer expression to its string representation (int.to.str).
|
||||
*/
|
||||
fromInt(n: Arith<Name> | number | bigint): Seq<Name>;
|
||||
}
|
||||
|
||||
/** @category String/Sequence */
|
||||
|
|
@ -3557,6 +3567,36 @@ export interface Seq<Name extends string = 'main', ElemSort extends Sort<Name> =
|
|||
|
||||
/** @category Operations */
|
||||
replaceAll(src: Seq<Name, ElemSort> | string, dst: Seq<Name, ElemSort> | string): Seq<Name, ElemSort>;
|
||||
|
||||
/** @category Operations */
|
||||
replaceRe(re: Re<Name>, dst: Seq<Name, ElemSort> | string): Seq<Name, ElemSort>;
|
||||
|
||||
/** @category Operations */
|
||||
replaceReAll(re: Re<Name>, dst: Seq<Name, ElemSort> | string): Seq<Name, ElemSort>;
|
||||
|
||||
/**
|
||||
* Convert a string to its integer value (str.to.int).
|
||||
* @category Operations
|
||||
*/
|
||||
toInt(): Arith<Name>;
|
||||
|
||||
/**
|
||||
* Convert a single-character string to its Unicode code point (str.to_code).
|
||||
* @category Operations
|
||||
*/
|
||||
toCode(): Arith<Name>;
|
||||
|
||||
/**
|
||||
* String less-than comparison (str.lt).
|
||||
* @category Operations
|
||||
*/
|
||||
lt(other: Seq<Name, ElemSort> | string): Bool<Name>;
|
||||
|
||||
/**
|
||||
* String less-than-or-equal comparison (str.le).
|
||||
* @category Operations
|
||||
*/
|
||||
le(other: Seq<Name, ElemSort> | string): Bool<Name>;
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue