public TacticReplaceStatus ExpandTacticByMember(out string expandedTactic) { expandedTactic = ""; var l = Microsoft.Dafny.Tacny.TacnyDriver.GetTacticResultList(); var x = _member as Method; if (x == null) { return(TacticReplaceStatus.NoTactic); } var sr = new StringWriter(); var printer = new Printer(sr); var hasTactic = false; foreach (var stmt in x.Body.SubStatements) { var result = l.FirstOrDefault(pair => RefactoringUtil.TokenEquals(pair.Key, stmt.Tok)); if (result.Key == null) { printer.PrintStatement(stmt, 0); } else { hasTactic = true; result.Value.ForEach(foundStmt => printer.PrintStatement(foundStmt, 0)); } sr.Write("\n"); } expandedTactic = hasTactic ? sr.ToString() : ""; return(TacticReplaceStatus.Success); }
public static string StatementToString(Statement stmt) { Contract.Requires(stmt != null); using (var wr = new System.IO.StringWriter()) { var pr = new Printer(wr); pr.PrintStatement(stmt, 0); return ToStringWithoutNewline(wr); } }
private TacticReplaceStatus ExpandSingleTacticCall(UpdateStmt us, out string expanded) { expanded = ""; var l = Interpreter.GetTacnyResultList(); var result = l.FirstOrDefault(pair => RefactoringUtil.TokenEquals(pair.Key, us.Tok)); if (result.Value == null) { return(TacticReplaceStatus.NoTactic); } var sr = new StringWriter(); var printer = new Printer(sr); result.Value.ForEach(stmt => printer.PrintStatement(stmt, 4)); expanded = sr.ToString(); return(!string.IsNullOrEmpty(expanded) ? TacticReplaceStatus.Success : TacticReplaceStatus.NoTactic); }
private TacticReplaceStatus ExpandSingleTacticCall(Statement us, out string expanded) { expanded = ""; var l = Microsoft.Dafny.Tacny.TacnyDriver.GetTacticResultList(); var result = l.FirstOrDefault(pair => RefactoringUtil.TokenEquals(pair.Key, us.Tok)); if (result.Value == null) { return(TacticReplaceStatus.NoTactic); } var sr = new StringWriter(); var printer = new Printer(sr); foreach (var stmt in result.Value) { printer.PrintStatement(stmt, 4); sr.Write("\n"); } expanded = sr.ToString(); return(!string.IsNullOrEmpty(expanded) ? TacticReplaceStatus.Success : TacticReplaceStatus.NoTactic); }
public TacticReplaceStatus ExpandTacticByMember(out string expandedTactic) { expandedTactic = ""; var l = Interpreter.GetTacnyResultList(); var x = _member as Method; if (x == null) return TacticReplaceStatus.NoTactic; var sr = new StringWriter(); var printer = new Printer(sr); var hasTactic = false; foreach (var stmt in x.Body.SubStatements) { var result = l.FirstOrDefault(pair => RefactoringUtil.TokenEquals(pair.Key, stmt.Tok)); if (result.Key==null) { printer.PrintStatement(stmt,0); } else { hasTactic = true; result.Value.ForEach(foundStmt => printer.PrintStatement(foundStmt, 0)); } sr.Write("\n"); } expandedTactic = hasTactic ? sr.ToString() : ""; return TacticReplaceStatus.Success; }
private TacticReplaceStatus ExpandSingleTacticCall(UpdateStmt us, out string expanded) { expanded = ""; var l = Interpreter.GetTacnyResultList(); var result = l.FirstOrDefault(pair => RefactoringUtil.TokenEquals(pair.Key,us.Tok)); if (result.Value == null) return TacticReplaceStatus.NoTactic; var sr = new StringWriter(); var printer = new Printer(sr); result.Value.ForEach(stmt => printer.PrintStatement(stmt, 4)); expanded = sr.ToString(); return !string.IsNullOrEmpty(expanded) ? TacticReplaceStatus.Success : TacticReplaceStatus.NoTactic; }
private TacticReplaceStatus ExpandSingleTacticCall(UpdateStmt us, out string expanded) { expanded = ""; var status = TacticReplaceStatus.Success; var newStmts = Tacny.Interpreter.FindSingleTactic(_program, _member, us, errorInfo => { status = TacticReplaceStatus.TranslatorFail; }, _unresolvedProgram); if (status != TacticReplaceStatus.Success) return status; if (newStmts == null) return TacticReplaceStatus.NoTactic; var sr = new StringWriter(); var pr = new Printer(sr); for(var i = 0; i < newStmts.Count-1; i++) { pr.PrintStatement(newStmts[i], 4); sr.WriteLine(); } pr.PrintStatement(newStmts[newStmts.Count-1], 4); expanded += sr; return TacticReplaceStatus.Success; }
public static bool SameStatement(Statement a, Statement b) { if (a == null || b == null) return false; var sr = new StringWriter(); var printer = new Printer(sr); printer.PrintStatement(a, 0); var sa = sr.ToString(); sr.Flush(); printer.PrintStatement(b, 0); var sb = sr.ToString(); return sa == sb; }