Exemple #1
0
        private static void ProcessPrograms(List <Program> dafnyPrograms)
        {
            SimpleVerifier verifier = new SimpleVerifier();
            DareSim        dare     = new DareSim(new StopChecker());

            foreach (var program in dafnyPrograms)
            {
                dare.ProcessProgram(program);
                using (TextWriter writer = File.CreateText(_outputDir + "\\processed-" + program.Name)) {
                    PrintProgram(program, writer);
                }
                if (!verifier.IsProgramValid(program))
                {
                    throw new Exception("Program not valid after process");
                }
                var decls   = program.DefaultModuleDef.TopLevelDecls;
                var members = new List <MemberDecl>();
                foreach (var topLevelDecl in decls)
                {
                    var classDec = topLevelDecl as ClassDecl;
                    if (classDec == null)
                    {
                        continue;
                    }
                    members.AddRange(classDec.Members);
                }
                dare.ProcessMembers(program, members);
            }
        }
Exemple #2
0
        private void ProcessSomeMembersThreaded(object o)
        {
            NotifyStatusbar(DeadAnnotationStatus.Started);
            var prog = ((ThreadParams)o).P;
            var snap = ((ThreadParams)o).S;
            var stop = ((ThreadParams)o).Stop;
            var mds  = ((ThreadParams)o).M;
            var dare = new Dare.Dare(stop);
            List <DareResult> results;

            _lastRunChangeCount = _changesSinceLastSuccessfulRun.Count;
            try {
                results = dare.ProcessMembers(prog, mds);
            } catch (NotValidException) {
                _lastRunFailed = true;
                NotifyStatusbar(DeadAnnotationStatus.DaryFailInvalid);
                Finish();
                return;
            }
            _lastRunFailed = false;
            if (_currentStopper.Stop)
            {
                NotifyStatusbar(DeadAnnotationStatus.UserInterrupt);
                Finish();
                return;
            }
            _changesSinceLastSuccessfulRun.Clear();
            var changed = new List <SnapshotSpan>();

            lock (_deadAnnotations) {
                var toremove = _errList.Tasks.Cast <Task>().Where(task => task.HelpKeyword == DeadAnnotationTag.Help).ToList();
                toremove.ForEach(_errList.Tasks.Remove);
                foreach (var m in mds)
                {
                    var mSpan = new SnapshotSpan(snap, m.BodyStartTok.pos, m.BodyEndTok.pos - m.BodyStartTok.pos);
                    _deadAnnotations.RemoveAll(tag => tag.TrackingReplacementSpan.GetSpan(snap).OverlapsWith(mSpan));
                }
                results.ForEach(x => changed.Add(ProcessValidResult(x).TrackingReplacementSpan.GetSpan(Snapshot)));
            }
            _deadAnnotations.ForEach(t => _errList.Tasks.Add(t.Task));
            var normalizedChanges = new NormalizedSnapshotSpanCollection(changed);

            normalizedChanges.ToList().ForEach(x => TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(x)));
            NotifyStatusbar(DeadAnnotationStatus.Finished);
            Finish();
        }