/// <summary>
        /// Invokes Dany resolver.
        /// This will find semantic errors.
        /// </summary>
        private bool Resolve()
        {
            var resolver = new Microsoft.Dafny.Resolver(_dafnyProgram);

            resolver.ResolveProgram(_dafnyProgram);

            bool success = _reporter.Count(ErrorLevel.Error) == 0;

            if (success)
            {
                _status = TranslationStatus.Resolved;
            }
            return(success);
        }
예제 #2
0
        /// <summary>
        /// Calls the Dafny parser/resolver/type checker on the contents of the buffer, updates the Error List accordingly.
        /// </summary>
        public void ResolveBuffer(object sender, EventArgs args)
        {
            ITextSnapshot snapshot = _buffer.CurrentSnapshot;

            if (snapshot == Snapshot)
            {
                return; // we've already done this snapshot
            }
            string            filename = _document != null ? _document.FilePath : "<program>";
            var               driver   = new DafnyDriver(_buffer, filename);
            List <DafnyError> newErrors;

            Dafny.Program program;
            try
            {
                program            = driver.ProcessResolution(RunResolver);
                MostRecentResolver = driver.MostRecentResolver;
                newErrors          = driver.Errors;
            }
            catch (Exception e)
            {
                newErrors = new List <DafnyError> {
                    new DafnyError(filename, 0, 0, ErrorCategory.InternalError, "internal Dafny error: " + e.Message, snapshot, false)
                };
                program = null;
            }

            lock (this)
            {
                Snapshot = snapshot;
                Program  = program;
            }

            if (program != null && _document != null)
            {
                ResolverTaggers[_document.TextBuffer] = this;
            }
            else if (_document != null)
            {
                ResolverTaggers.Remove(_document.TextBuffer);
            }

            _resolutionErrors      = newErrors;
            FatalVerificationError = null;

            UpdateErrorList(snapshot);
        }