mirror of
https://github.com/Z3Prover/z3
synced 2025-05-07 07:45:46 +00:00
[WIP] More TS Binding Features (#6412)
* feat: basic quantfier support * feat: added isQuantifier * feat: expanded functions * wip: (lambda broken) * temp fix to LambdaImpl typing issue * feat: function type inference * formatting with prettier * fix: imported from invalid module * fix isBool bug and dumping to smtlib * substitution and model.updateValue * api to add custom func interps to model * fix: building * properly handling uint32 -> number conversion in z3 TS wrapper * added simplify * remame Add->Sum and Mul->Product * formatting
This commit is contained in:
parent
5e30323b1a
commit
ede9e5ffc2
9 changed files with 1383 additions and 332 deletions
|
@ -76,6 +76,7 @@ function makeTsWrapper() {
|
|||
}
|
||||
|
||||
const isInParam = (p: FuncParam) => p.kind !== undefined && ['in', 'in_array'].includes(p.kind);
|
||||
|
||||
function wrapFunction(fn: Func) {
|
||||
if (CUSTOM_IMPLEMENTATIONS.includes(fn.name)) {
|
||||
return null;
|
||||
|
@ -104,7 +105,7 @@ function makeTsWrapper() {
|
|||
|
||||
let isAsync = asyncFuncs.includes(fn.name);
|
||||
let trivial =
|
||||
!['string', 'boolean'].includes(fn.ret) &&
|
||||
!['string', 'boolean', 'unsigned'].includes(fn.ret) &&
|
||||
!fn.nullableRet &&
|
||||
outParams.length === 0 &&
|
||||
!inParams.some(p => p.type === 'string' || p.isArray || p.nullable);
|
||||
|
@ -234,6 +235,7 @@ function makeTsWrapper() {
|
|||
function setArg() {
|
||||
args[outParam.idx] = memIdx === 0 ? 'outAddress' : `outAddress + ${memIdx * 4}`;
|
||||
}
|
||||
|
||||
let read, type;
|
||||
if (outParam.type === 'string') {
|
||||
read = `Mod.UTF8ToString(getOutUint(${memIdx}))`;
|
||||
|
@ -330,11 +332,15 @@ function makeTsWrapper() {
|
|||
if (ret === 0) {
|
||||
return null;
|
||||
}
|
||||
`.trim();
|
||||
`.trim();
|
||||
} else if (fn.ret === 'unsigned') {
|
||||
infix += `
|
||||
ret = (new Uint32Array([ret]))[0];
|
||||
`.trim();
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
let invocation = `Mod.ccall('${isAsync ? 'async_' : ''}${fn.name}', '${cReturnType}', ${JSON.stringify(ctypes)}, [${args.map(toEm).join(', ')}])`;
|
||||
let invocation = `Mod.ccall('${isAsync ? "async_" : ""}${fn.name}', '${cReturnType}', ${JSON.stringify(ctypes)}, [${args.map(toEm).join(", ")}])`;
|
||||
|
||||
if (isAsync) {
|
||||
invocation = `await Mod.async_call(() => ${invocation})`;
|
||||
|
|
|
@ -45,7 +45,7 @@ const types = {
|
|||
__proto__: null,
|
||||
|
||||
// these are function types I can't be bothered to parse
|
||||
// NSB: They can be extracted automatically from z3_api.h thanks to the use
|
||||
// NSB: They can be extracted automatically from z3_api.h thanks to the use
|
||||
// of a macro.
|
||||
Z3_error_handler: 'Z3_error_handler',
|
||||
Z3_push_eh: 'Z3_push_eh',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue