123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081(***************************************************************************)(* This file is part of the third-party OCaml library `smtml`. *)(* Copyright (C) 2023-2024 formalsec *)(* *)(* This program is free software: you can redistribute it and/or modify *)(* it under the terms of the GNU General Public License as published by *)(* the Free Software Foundation, either version 3 of the License, or *)(* (at your option) any later version. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU General Public License for more details. *)(* *)(* You should have received a copy of the GNU General Public License *)(* along with this program. If not, see <https://www.gnu.org/licenses/>. *)(***************************************************************************)includeInterpret_intfmoduleMake(Solver:Solver_intf.S)=structopenAsttypesolver=Solver.ttypeexec_state=solverstateletinit_statestmts=letparams=Params.(default()$(Model,false))inletsolver=Solver.create~params()inSolver.pushsolver;{stmts;smap=Hashtbl.create16;solver;pc=[]}letevalstmt(state:exec_state):exec_state=let{solver;pc;_}=stateinletstpc={statewithpc}inmatchstmtwith|Asserte->Solver.addsolver[e];st(e::pc)|Check_sat->(matchSolver.checksolver[]with|`Sat->Format.printf"sat@."|`Unsat->Format.printf"unsat@."|`Unknown->Format.printf"unknown@.");stpc|Push->Solver.pushsolver;stpc|Popn->Solver.popsolvern;stpc|Let_const_x->stpc|Get_model->assert(`Sat=Solver.checksolver[]);letmodel=Solver.modelsolverinFormat.printf"%a@."(Format.pp_print_option(Model.pp~no_values:false))model;stpc|Set_logiclogic->letsolver=Solver.create~logic()inSolver.pushsolver;{statewithsolver}letrecloop(state:exec_state):exec_state=matchstate.stmtswith|[]->state|stmt::stmts->loop(evalstmt{statewithstmts})letstart?state(stmts:Ast.script):exec_state=letst=matchstatewith|None->init_statestmts|Somest->Solver.popst.solver1;Solver.pushst.solver;{stwithstmts;pc=[]}inloopstend