public void FindAndResolveTacticApplication(Program tacnyProgram, Function fun) { if (IsLeaf()) { var aps = Data as ApplySuffix; if (aps == null) { return; } UpdateStmt us = new UpdateStmt(aps.tok, aps.tok, new List <Expression>(), new List <AssignmentRhs> { new ExprRhs(aps) }); if (tacnyProgram.IsTacticCall(us)) { List <IVariable> variables = new List <IVariable>(); ITactic tac = tacnyProgram.GetTactic(us); tacnyProgram.SetCurrent(tac, fun); variables.AddRange(fun.Formals); // get the resolved variables List <IVariable> resolved = new List <IVariable>(); Console.Out.WriteLine($"Resolving {tac.Name} in {fun.Name}"); resolved.AddRange(fun.Formals); // add input arguments as resolved variables var result = LazyTacny.Atomic.ResolveTactic(us, fun, tacnyProgram, variables, resolved); Data = result.State.DynamicContext.generatedExpressions[0]; tacnyProgram.CurrentDebug.Fin(); Modified = true; } } else { LChild.FindAndResolveTacticApplication(tacnyProgram, fun); RChild?.FindAndResolveTacticApplication(tacnyProgram, fun); } }
private string ScanMemberBody(MemberDecl md) { Contract.Requires(md != null); solution_list.plist.Clear(); Method m = md as Method; if (m == null) { return(null); } if (m.Body == null) { return(null); } List <IVariable> variables = new List <IVariable>(); variables.AddRange(m.Ins); variables.AddRange(m.Outs); SolutionList sol_list = new SolutionList(); sol_list.AddRange(solution_list.plist); if (TacnyOptions.O.ParallelExecution) { Parallel.ForEach(m.Body.Body, st => { // register local variables VarDeclStmt vds = st as VarDeclStmt; if (vds != null) { variables.AddRange(vds.Locals); } UpdateStmt us = st as UpdateStmt; if (us != null) { if (tacnyProgram.IsTacticCall(us)) { try { tacnyProgram.SetCurrent(tacnyProgram.GetTactic(us), md); // get the resolved variables List <IVariable> resolved = tacnyProgram.GetResolvedVariables(md); resolved.AddRange(m.Ins); // add input arguments as resolved variables Atomic.ResolveTactic(tacnyProgram.GetTactic(us), us, md, tacnyProgram, variables, resolved, ref sol_list); tacnyProgram.CurrentDebug.Fin(); } catch (AggregateException e) { foreach (var err in e.Data) { Printer.Error(err.ToString()); } } } } }); } else { foreach (var st in m.Body.Body) { // register local variables VarDeclStmt vds = st as VarDeclStmt; if (vds != null) { variables.AddRange(vds.Locals); } UpdateStmt us = st as UpdateStmt; if (us != null) { if (tacnyProgram.IsTacticCall(us)) { try { tacnyProgram.SetCurrent(tacnyProgram.GetTactic(us), md); // get the resolved variables List <IVariable> resolved = tacnyProgram.GetResolvedVariables(md); resolved.AddRange(m.Ins); // add input arguments as resolved variables Atomic.ResolveTactic(tacnyProgram.GetTactic(us), us, md, tacnyProgram, variables, resolved, ref sol_list); tacnyProgram.CurrentDebug.Fin(); } catch (Exception e) { return(e.Message); } } } } } solution_list.AddRange(sol_list.plist); return(null); }