/// <summary> /// Makes a converter from Bek programs to STbs /// </summary> /// <param name="solver">given solver</param> public static IConverter <STbModel> MkBekToSTbConverter(IContext <FuncDecl, Expr, Sort> solver, List <Bek.Frontend.AST.BekLocalFunction> funcs, string name) { //if (solver.Encoding != BitWidth.BV16) //{ // throw new ModelException("Modes other than UTF16 are not supported."); //} var conv = new exprConverter(solver); STBuilderZ3 stb = new STBuilderZ3(solver); foreach (var bekfunc in funcs) { var varInfo = new Dictionary <string, Expr>(); Expr[] vars = new Expr[bekfunc.args.Length]; for (int i = 0; i < bekfunc.args.Length; i++) { var v = solver.MkVar((uint)i, solver.CharSort); varInfo[bekfunc.args[i].name] = solver.MkVar((uint)i, solver.CharSort); vars[i] = v; } Expr body = conv.ConvertToExpr(bekfunc.body, varInfo); solver.Library.DefineFunction(bekfunc.id.name, body, vars); } var charsort = solver.CharSort; var ire = new Converters.Z3.ValueExpr(stb, charsort, funcs); var ie = new Converters.Z3.IterExpr2STb(ire, stb, charsort); var se = new Converters.Z3.StrExpr2STb(ie, stb, charsort); var bp = new Converters.Z3.BekProg2STb(se, stb, charsort, name); return(bp); }
public IterExpr(ValueExpr expr_handler, STBuilderZ3 stb, Sort charsort) : base(expr_handler) { this.stb = stb; this.charsort = charsort; }