コード例 #1
0
ファイル: ProgressMargin.cs プロジェクト: mnsamad/dafny-1
        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);

            try
            {
                string filename = _document != null ? _document.FilePath : "<program>";
                var    driver   = new DafnyDriver(_buffer, filename);
                bool   success  = driver.Verify(program, errorListHolder, GetHashCode().ToString(), requestId, errorInfo =>
                {
                    if (!_disposed)
                    {
                        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)
                        {
                            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);
                            }
                        }
                    }
                });
                if (!success)
                {
                    foreach (var error in driver.Errors)
                    {
                        errorListHolder.AddError(error, "$$program$$", requestId);
                    }
                }
            }
            catch (Exception e)
            {
                errorListHolder.AddError(new DafnyError("$$program$$", 0, 0, ErrorCategory.InternalError, "Verification process error: " + e.Message, snapshot, false), "$$program$$", requestId);
            }
            finally
            {
                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);
        }
コード例 #2
0
ファイル: ProgressMargin.cs プロジェクト: ggrov/tacny
        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).ReParse(false);
            //Dafny.Program unresolvedProgram = null;
            // if (!TacnyDriver.GetExistingProgramFromBuffer(snapshot.TextBuffer, out unresolvedProgram))
            //  unresolvedProgram = new TacnyDriver(snapshot.TextBuffer, _document.FilePath).ReParse(false);

            var success = true;

#if !DEBUGTHROW
            try
            {
#endif
            success = DafnyDriver.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;
                }

                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);
                }
            });
            if (!success)
            {
                errorListHolder.AddError(
                    new DafnyError("$$program$$", 0, 0, ErrorCategory.InternalError, "Verification process error", snapshot, false),
                    "$$program$$", requestId);
            }
#if !DEBUGTHROW
        }

        catch (Exception e)
        {
            errorListHolder.FatalVerificationError = new DafnyError("$$program$$", 0, 0,
                                                                    ErrorCategory.InternalError, "Fatal verification error: " + e.Message + "\n" + e.StackTrace, snapshot, false);
        }
        finally
        {
#endif
            ITextSnapshot snap;
            RequestIdToSnapshot.TryGetValue(requestId, out snap);
            var addedErrors = new List <DafnyError>();
            if (tacticsErrorList.Count > 0)
            {
                success = false;
                try {
                    tacticsErrorList.ForEach(errorInfo => new TacticErrorReportingResolver(errorInfo)
                                             .AddTacticErrors(addedErrors, snap, _document.FilePath));
                    addedErrors.ForEach(error => errorListHolder.AddError(error, "$$program_tactics$$", requestId));
                } 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);
#if !DEBUGTHROW
        }
#endif
            lock (this) {
                bufferChangesPreVerificationStart.Clear();
                verificationInProgress = false;
            }

            if (success)
            {
                DafnyClassifier.DafnyMenuPackage.TacnyMenuProxy.UpdateRot(_document.FilePath, snapshot);
            }

            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);
        }