public bool ToggleTacticEvaluation() { return(TacnyDriver.ToggleTacticEvaluation()); }
protected void ParseTacticAttributes(Attributes attr) { if (attr == null) { return; } Expression arg; LiteralExpr literalExpr; switch (attr.Name) { case "enabled": enabled = true; arg = attr.Args.FirstOrDefault(); if (arg != null && arg is LiteralExpr && ((LiteralExpr)arg).Value is bool && ((bool)(arg as LiteralExpr).Value) == false) { enabled = false; } break; case "disabled": enabled = false; break; case "partial": IsPartial = true; break; case "verify": arg = attr.Args.FirstOrDefault(); if (arg != null) { try { literalExpr = arg as LiteralExpr; if (literalExpr != null) { var input = Int32.Parse(literalExpr.Value.ToString()); if (input > 1) { VerifyN = input; } } } catch (Exception) {} } break; case "backtrack": arg = attr.Args.FirstOrDefault(); if (arg == null) { Backtrack = Backtrack + 1; } else { try{ literalExpr = arg as LiteralExpr; if (literalExpr != null) { var input = literalExpr.Value.ToString(); Backtrack = Backtrack + Int32.Parse(input); } } catch (Exception) { Backtrack = Backtrack + 1; } } break; case "timeout": int timeout = 0; arg = attr.Args.FirstOrDefault(); if (arg == null) { timeout = 10; } else { try{ literalExpr = arg as LiteralExpr; if (literalExpr != null) { var input = literalExpr.Value.ToString(); timeout = Int32.Parse(input); } } catch (Exception) { timeout = 0; } } if (timeout != 0) { TimeStamp = TacnyDriver.GetTimer().Elapsed.Seconds + timeout; } break; default: //_reporter.Warning(MessageSource.Tactic, ((MemberDecl)ActiveTactic).tok, $"Unrecognized attribute {attr.Name}"); break; } if (attr.Prev != null) { ParseTacticAttributes(attr.Prev); } }
public static Program GetNewProgram(ITextBuffer tb) { string file; LoadAndCheckDocument(tb, out file); var driver = new TacnyDriver(tb, file); return driver.ReParse(false); }
private void RunVerifier(Dafny.Program program, ITextSnapshot snapshot, string requestId, ResolverTagger errorListHolder, bool diagnoseTimeouts) { Contract.Requires(program != null); Contract.Requires(snapshot != null); Contract.Requires(requestId != null); Contract.Requires(errorListHolder != null); if (_logSnapshots) { var logDirName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(program.FullName), "logs"); Directory.CreateDirectory(logDirName); var logFileName = System.IO.Path.Combine(logDirName, System.IO.Path.GetFileName(System.IO.Path.ChangeExtension(program.FullName, string.Format("{0}.v{1}{2}", _created.Ticks, _version, System.IO.Path.GetExtension(program.FullName))))); using (var writer = new StreamWriter(logFileName)) { snapshot.Write(writer); } _version++; } DafnyDriver.SetDiagnoseTimeouts(diagnoseTimeouts); errorListHolder.FatalVerificationError = null; var tacticsErrorList = new List <Tacny.CompoundErrorInformation>(); var unresolvedProgram = new TacnyDriver(snapshot.TextBuffer, _document.FilePath).ParseAndTypeCheck(false); var foundNonTacticError = false; try { bool success = TacnyDriver.Verify(program, errorListHolder, GetHashCode().ToString(), requestId, errorInfo => { if (_disposed) { return; } var tacticErrorInfo = errorInfo as Tacny.CompoundErrorInformation; if (tacticErrorInfo != null) { tacticsErrorList.Add(tacticErrorInfo); return; } errorInfo.BoogieErrorCode = null; var isRecycled = false; ITextSnapshot s = null; if (errorInfo.OriginalRequestId != null) { isRecycled = errorInfo.OriginalRequestId != requestId; RequestIdToSnapshot.TryGetValue(errorInfo.OriginalRequestId, out s); } if (s == null && errorInfo.RequestId != null) { RequestIdToSnapshot.TryGetValue(errorInfo.RequestId, out s); } if (s == null) { return; } foundNonTacticError = true; errorListHolder.AddError( new DafnyError(errorInfo.Tok.filename, errorInfo.Tok.line - 1, errorInfo.Tok.col - 1, ErrorCategory.VerificationError, errorInfo.FullMsg, s, isRecycled, errorInfo.Model.ToString(), System.IO.Path.GetFullPath(_document.FilePath) == errorInfo.Tok.filename), errorInfo.ImplementationName, requestId); foreach (var aux in errorInfo.Aux) { errorListHolder.AddError( new DafnyError(aux.Tok.filename, aux.Tok.line - 1, aux.Tok.col - 1, ErrorCategory.AuxInformation, aux.FullMsg, s, isRecycled, null, System.IO.Path.GetFullPath(_document.FilePath) == aux.Tok.filename), errorInfo.ImplementationName, requestId); } }, unresolvedProgram); if (!success) { errorListHolder.AddError( new DafnyError("$$program$$", 0, 0, ErrorCategory.InternalError, "Verification process error", snapshot, false), "$$program$$", requestId); } } catch (Exception e) { errorListHolder.FatalVerificationError = new DafnyError("$$program$$", 0, 0, ErrorCategory.InternalError, "Fatal verification error: " + e.Message + "\n" + e.StackTrace, snapshot, false); } finally { ITextSnapshot s; RequestIdToSnapshot.TryGetValue(requestId, out s); if (/*!foundNonTacticError*/ true) { try { tacticsErrorList.ForEach(errorInfo => new TacticErrorReportingResolver(errorInfo) .AddTacticErrors(errorListHolder, s, requestId, _document.FilePath)); } catch (TacticErrorResolutionException e) { errorListHolder.AddError( new DafnyError("$$program_tactics$$", 0, 0, ErrorCategory.InternalError, "Error resolving tactics error " + e.Message + "\n" + e.StackTrace, snapshot, false), "$$program_tactics$$", requestId); } } DafnyDriver.SetDiagnoseTimeouts(!diagnoseTimeouts); } lock (this) { bufferChangesPreVerificationStart.Clear(); verificationInProgress = false; } errorListHolder.UpdateErrorList(snapshot); // Notify to-whom-it-may-concern about the cleared pre-verification changes NotifyAboutChangedTags(snapshot); // If new changes took place since we started the verification, we may need to kick off another verification // immediately. UponIdle(null, null); }