private void InterpretWhileStmt(WhileStmt stmt, Stack <Dictionary <IVariable, Type> > frame) { //unfold tactics in inv if there is any if (stmt.Invariants != null && stmt.Invariants.Count > 0) { foreach (var inv in stmt.Invariants) { var aps = TacticAppExprFinder.GetTacticAppExpr(_state, inv.E); if (aps != null) { UndfoldTacticCall(stmt, aps, StackToDict(frame)); } } } //unfold tactics in var if there is an if (stmt.Decreases != null && stmt.Decreases.Expressions != null && stmt.Decreases.Expressions.Count > 0) { foreach (var v in stmt.Decreases.Expressions) { var aps = TacticAppExprFinder.GetTacticAppExpr(_state, v); if (aps != null) { UndfoldTacticCall(stmt, aps, StackToDict(frame)); } } } InterpertBlockStmt(stmt.Body, frame); }
private void InterpertBlockStmt(List <Statement> body, Stack <Dictionary <IVariable, Type> > frame) { frame.Push(new Dictionary <IVariable, Type>()); foreach (var stmt in 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; InterpretIfStmt(ifStmt, frame); } else if (stmt is WhileStmt) { var whileStmt = stmt as WhileStmt; InterpretWhileStmt(whileStmt, frame); } else if (stmt is UpdateStmt) { if (_state.IsTacticCall(stmt as UpdateStmt)) { UndfoldTacticCall(stmt, Util.GetTacticAppExpr(stmt as UpdateStmt), StackToDict(frame)); } else { var expr = TacticAppExprFinder.GetTacticAppExpr(_state, stmt); if (expr != null) { UndfoldTacticCall(stmt, expr, StackToDict(frame)); } } } else if (stmt is InlineTacticBlockStmt) { UndfoldTacticCall(stmt, null, StackToDict(frame)); } else if (stmt is MatchStmt) { foreach (var caseStmt in (stmt as MatchStmt).Cases) { InterpretCaseStmt(caseStmt, frame); } } else if (stmt is ForallStmt) { //TODO } else if (stmt is AssertStmt) { if ((stmt as AssertStmt).Proof != null) { InterpretAssertStmt(stmt as AssertStmt, frame); } } else if (stmt is CalcStmt) { } else if (stmt is BlockStmt) { InterpertBlockStmt((stmt as BlockStmt), frame); } else { var expr = TacticAppExprFinder.GetTacticAppExpr(_state, stmt); if (expr != null) { UndfoldTacticCall(stmt, expr, StackToDict(frame)); } } } frame.Pop(); }