mirror of
https://github.com/Z3Prover/z3
synced 2025-05-09 00:35:47 +00:00
Update emscripten (#7473)
* fixes for newer emscripten thread handling behavior * fix return type for async wrapper functions * update prettier * update typescript and fix errors * update emscripten version in CI * update js readme about tests
This commit is contained in:
parent
4fbf54afd0
commit
e5f8327483
17 changed files with 275 additions and 108 deletions
|
@ -1,4 +1,4 @@
|
|||
import { init } from '../../build/node';
|
||||
import { init } from '../../build/node.js';
|
||||
|
||||
import type { Solver, Arith } from '../../build/node';
|
||||
|
||||
|
@ -157,7 +157,9 @@ function parseSudoku(str: string) {
|
|||
|
||||
async function solve(str: string) {
|
||||
let solver = new Z3.Solver();
|
||||
let cells = Array.from({ length: 9 }, (_, col) => Array.from({ length: 9 }, (_, row) => Z3.Int.const(`c_${row}_${col}`)));
|
||||
let cells = Array.from({ length: 9 }, (_, col) =>
|
||||
Array.from({ length: 9 }, (_, row) => Z3.Int.const(`c_${row}_${col}`)),
|
||||
);
|
||||
for (let { row, col, value } of parseSudoku(str)) {
|
||||
solver.add(cells[row][col].eq(value));
|
||||
}
|
||||
|
@ -198,8 +200,6 @@ function parseSudoku(str: string) {
|
|||
.........
|
||||
.........
|
||||
`);
|
||||
|
||||
em.PThread.terminateAllThreads();
|
||||
})().catch(e => {
|
||||
console.error('error', e);
|
||||
process.exit(1);
|
||||
|
|
|
@ -25,12 +25,11 @@ import assert from 'assert';
|
|||
const model = solver.model();
|
||||
let modelStr = model.sexpr();
|
||||
modelStr = modelStr.replace(/\n/g, ' ');
|
||||
console.log("Model: ", modelStr);
|
||||
console.log('Model: ', modelStr);
|
||||
|
||||
const exprs = z3.ast_from_string(modelStr);
|
||||
console.log(exprs);
|
||||
|
||||
})().catch(e => {
|
||||
console.error('error', e);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// @ts-ignore we're not going to bother with types for this
|
||||
import process from 'process';
|
||||
import { init, Z3_error_code } from '../../build/node';
|
||||
import { init, Z3_error_code } from '../../build/node.js';
|
||||
|
||||
// demonstrates use of the raw API
|
||||
|
||||
|
@ -58,10 +58,24 @@ import { init, Z3_error_code } from '../../build/node';
|
|||
}
|
||||
console.log('confirming error messages work:', Z3.get_error_msg(ctx, Z3.get_error_code(ctx)));
|
||||
|
||||
Z3.global_param_set('verbose', '0');
|
||||
let result = await Z3.eval_smtlib2_string(
|
||||
ctx,
|
||||
`
|
||||
(declare-const p Bool)
|
||||
(declare-const q Bool)
|
||||
(declare-const r Bool)
|
||||
(declare-const s Bool)
|
||||
(declare-const t Bool)
|
||||
(assert ((_ pbeq 5 2 1 3 3 2) p q r s t))
|
||||
(check-sat)
|
||||
(get-model)
|
||||
`,
|
||||
);
|
||||
console.log('checking string evaluation', result);
|
||||
|
||||
Z3.dec_ref(ctx, strAst);
|
||||
Z3.del_context(ctx);
|
||||
|
||||
em.PThread.terminateAllThreads();
|
||||
})().catch(e => {
|
||||
console.error('error', e);
|
||||
process.exit(1);
|
||||
|
|
|
@ -20,7 +20,7 @@ import type {
|
|||
Z3_sort,
|
||||
Z3_symbol,
|
||||
} from '../../build/node';
|
||||
import { init, Z3_ast_kind, Z3_lbool, Z3_sort_kind, Z3_symbol_kind } from '../../build/node';
|
||||
import { init, Z3_ast_kind, Z3_lbool, Z3_sort_kind, Z3_symbol_kind } from '../../build/node.js';
|
||||
|
||||
let printf = (str: string, ...args: unknown[]) => console.log(sprintf(str.replace(/\n$/, ''), ...args));
|
||||
|
||||
|
@ -383,9 +383,6 @@ let printf = (str: string, ...args: unknown[]) => console.log(sprintf(str.replac
|
|||
|
||||
await bitvector_example2();
|
||||
await unsat_core_and_proof_example();
|
||||
|
||||
// shut down
|
||||
em.PThread.terminateAllThreads();
|
||||
})().catch(e => {
|
||||
console.error('error', e);
|
||||
process.exit(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue