// Find tactic application and resolve it private void SearchBlockStmt(BlockStmt body) { Contract.Requires(tcce.NonNull(body)); // TODO Make sure this is an OK Thing to be doing // Currently, if the proof list is not reset, then because it is static across // calls, it will start to build up old information, and the program will go // into a loop trying to figure out new fresh names for 'existing' methods. BaseSearchStrategy.ResetProofList(); _frame.Push(new Dictionary <IVariable, Type>()); foreach (var stmt in body.Body) { if (stmt is VarDeclStmt) { var vds = stmt as VarDeclStmt; // register local variable declarations foreach (var local in vds.Locals) { try { _frame.Peek().Add(local, local.Type); } catch (Exception e) { //TODO: some error handling when target is not resolved Console.Out.WriteLine(e.Message); } } } else if (stmt is IfStmt) { var ifStmt = stmt as IfStmt; SearchIfStmt(ifStmt); } else if (stmt is WhileStmt) { var whileStmt = stmt as WhileStmt; SearchBlockStmt(whileStmt.Body); } else if (stmt is UpdateStmt) { var us = stmt as UpdateStmt; if (_state.IsTacticCall(us)) { var list = StackToDict(_frame); var result = ApplyTactic(_state, list, us); if (result != null) { _resultList.Add(us.Copy(), result.GetGeneratedCode().Copy()); } else { //TODO what should go here? } } } else if (stmt is BlockStmt) { //TODO: } } _frame.Pop(); }
public static void PrepareFrame(BlockStmt body, ProofState state) { Contract.Requires <ArgumentNullException>(body != null, "body"); Contract.Requires <ArgumentNullException>(state != null, "state"); state.AddNewFrame(body); // call the search engine var search = new BaseSearchStrategy(state.TacticInfo.SearchStrategy, true); search.Search(state, _errorReporterDelegate); state.RemoveFrame(); }
public static ProofState ApplyTactic(ProofState state, Dictionary <IVariable, Type> variables, UpdateStmt tacticApplication) { Contract.Requires <ArgumentNullException>(tcce.NonNull(variables)); Contract.Requires <ArgumentNullException>(tcce.NonNull(tacticApplication)); Contract.Requires <ArgumentNullException>(state != null, "state"); state.InitState(tacticApplication, variables); var search = new BaseSearchStrategy(state.TacticInfo.SearchStrategy, true); return(search.Search(state, _errorReporterDelegate).FirstOrDefault()); }
public static IEnumerable <ProofState> ApplyNestedTactic(ProofState state, Dictionary <IVariable, Type> variables, UpdateStmt tacticApplication) { Contract.Requires <ArgumentNullException>(tcce.NonNull(variables)); Contract.Requires <ArgumentNullException>(tcce.NonNull(tacticApplication)); Contract.Requires <ArgumentNullException>(state != null, "state"); state.InitState(tacticApplication, variables); var search = new BaseSearchStrategy(state.TacticInfo.SearchStrategy, false); foreach (var result in search.Search(state, _errorReporterDelegate)) { var c = state.Copy(); c.AddStatementRange(result.GetGeneratedCode()); yield return(c); } }
public static void PrepareFrame(BlockStmt body, ProofState state) { Contract.Requires<ArgumentNullException>(body != null, "body"); Contract.Requires<ArgumentNullException>(state != null, "state"); state.AddNewFrame(body); // call the search engine var search = new BaseSearchStrategy(state.TacticInfo.SearchStrategy, true); search.Search(state, _errorReporterDelegate); state.RemoveFrame(); }
public static IEnumerable<ProofState> ApplyNestedTactic(ProofState state, Dictionary<IVariable, Type> variables, UpdateStmt tacticApplication) { Contract.Requires<ArgumentNullException>(tcce.NonNull(variables)); Contract.Requires<ArgumentNullException>(tcce.NonNull(tacticApplication)); Contract.Requires<ArgumentNullException>(state != null, "state"); state.InitState(tacticApplication, variables); var search = new BaseSearchStrategy(state.TacticInfo.SearchStrategy, false); foreach (var result in search.Search(state, _errorReporterDelegate)) { var c = state.Copy(); c.AddStatementRange(result.GetGeneratedCode()); yield return c; } }
public static ProofState ApplyTactic(ProofState state, Dictionary<IVariable, Type> variables, UpdateStmt tacticApplication) { Contract.Requires<ArgumentNullException>(tcce.NonNull(variables)); Contract.Requires<ArgumentNullException>(tcce.NonNull(tacticApplication)); Contract.Requires<ArgumentNullException>(state != null, "state"); state.InitState(tacticApplication, variables); var search = new BaseSearchStrategy(state.TacticInfo.SearchStrategy, true); return search.Search(state, _errorReporterDelegate).FirstOrDefault(); }