Ejemplo n.º 1
0
 public static void CloseProver()
 {
     prover.Close();
     CommandLineOptions.Clo.TheProverFactory.Close();
     prover = null;
 }
Ejemplo n.º 2
0
 public override void Close()
 {
   prover.Close();
   base.Close();
 }
Ejemplo n.º 3
0
        public void computeSummaries(ISummaryElement summaryClass)
        {
            this.summaryClass = summaryClass;

            var main = program.TopLevelDeclarations
                       .OfType <Implementation>()
                       .Where(impl => QKeyValue.FindBoolAttribute(impl.Attributes, "entrypoint"))
                       .FirstOrDefault();

            Debug.Assert(main != null);

            program.TopLevelDeclarations
            .OfType <Implementation>()
            .Iter(impl => impl2Summary.Add(impl.Name, summaryClass.GetFlaseSummary(program, impl)));

            // Build call graph
            var Succ = new Dictionary <Implementation, HashSet <Implementation> >();
            var Pred = new Dictionary <Implementation, HashSet <Implementation> >();

            name2Impl.Values.Iter(impl => Succ.Add(impl, new HashSet <Implementation>()));
            name2Impl.Values.Iter(impl => Pred.Add(impl, new HashSet <Implementation>()));

            foreach (var impl in program.TopLevelDeclarations.OfType <Implementation>())
            {
                foreach (var blk in impl.Blocks)
                {
                    foreach (var cmd in blk.Cmds.OfType <CallCmd>())
                    {
                        if (!name2Impl.ContainsKey(cmd.callee))
                        {
                            continue;
                        }
                        Succ[impl].Add(name2Impl[cmd.callee]);
                        Pred[name2Impl[cmd.callee]].Add(impl);
                    }
                }
            }

            // Build SCC
            var sccs = new StronglyConnectedComponents <Implementation>(name2Impl.Values,
                                                                        new Adjacency <Implementation>(n => Succ[n]),
                                                                        new Adjacency <Implementation>(n => Pred[n]));

            sccs.Compute();

            // impl -> priority
            var impl2Priority = new Dictionary <string, int>();
            int p             = 0;

            foreach (var scc in sccs)
            {
                scc.Iter(n => impl2Priority.Add(n.Name, p));
                p++;
            }

            var worklist = new SortedSet <Tuple <int, Implementation> >();

            name2Impl.Values
            .Iter(impl => worklist.Add(Tuple.Create(impl2Priority[impl.Name], impl)));

            while (worklist.Any())
            {
                var impl = worklist.First().Item2;
                worklist.Remove(worklist.First());

                var changed = ProcessImpl(impl);

                if (changed)
                {
                    Pred[impl].Iter(pred => worklist.Add(Tuple.Create(impl2Priority[pred.Name], pred)));
                }
            }

            foreach (var tup in impl2Summary)
            {
                Console.WriteLine("Summary of {0}:", tup.Key);
                Console.WriteLine("{0}", tup.Value);
            }

            prover.Close();
            CommandLineOptions.Clo.TheProverFactory.Close();
        }