Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Added ability to cancel the program verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
camrein committed Nov 9, 2020
1 parent aa2829d commit 0d7b55d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Source/DafnyLS/Language/DafnyProgramVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public async Task VerifyAsync(Microsoft.Dafny.Program program, CancellationToken
// It appears that boogie is thread-safe.
foreach(var (_, boogieProgram) in translated) {
cancellationToken.ThrowIfCancellationRequested();
VerifyWithBoogie(boogieProgram, program.reporter);
VerifyWithBoogie(boogieProgram, program.reporter, cancellationToken);
}
}

private void VerifyWithBoogie(Microsoft.Boogie.Program program, ErrorReporter reporter) {
private void VerifyWithBoogie(Microsoft.Boogie.Program program, ErrorReporter reporter, CancellationToken cancellationToken) {
program.Resolve();
program.Typecheck();

Expand All @@ -76,7 +76,14 @@ private void VerifyWithBoogie(Microsoft.Boogie.Program program, ErrorReporter re
// TODO Are the programId and requestId of any relevance?
var uniqueId = Guid.NewGuid().ToString();
// TODO any use of the verification state?
ExecutionEngine.InferAndVerify(program, new PipelineStatistics(), uniqueId, error => CaptureVerificationError(reporter, error), uniqueId);
using(cancellationToken.Register(() => CancelVerification(uniqueId))) {
ExecutionEngine.InferAndVerify(program, new PipelineStatistics(), uniqueId, error => CaptureVerificationError(reporter, error), uniqueId);
}
}

private void CancelVerification(string requestId) {
_logger.LogDebug("requesting verification cancellation of {}", requestId);
ExecutionEngine.CancelRequest(requestId);
}

private void CaptureVerificationError(ErrorReporter reporter, ErrorInformation error) {
Expand Down

0 comments on commit 0d7b55d

Please sign in to comment.