示例#1
0
        public static Dependencies Analyze(Program prog, Dependencies deps, Implementation impl)
        {
            string origProcName = impl.FindStringAttribute(RefineConsts.checkDepAttribute);
            //get the procedure's guard constants
            var inputGuardConsts = prog.TopLevelDeclarations.OfType <Constant>()
                                   .Where(x => Utils.AttributeUtils.GetAttributeVals(x.Attributes, RefineConsts.readSetGuradAttribute).Exists(p => (p as string) == origProcName))
                                   .ToList();
            var outputGuardConsts = prog.TopLevelDeclarations.OfType <Constant>()
                                    .Where(x => Utils.AttributeUtils.GetAttributeVals(x.Attributes, RefineConsts.modSetGuradAttribute).Exists(p => (p as string) == origProcName))
                                    .ToList();

            //---- generate VC starts ---------
            //following unsatcoreFromFailures.cs/PerformRootcauseWorks or EqualityFixes.cs/PerformRootCause in Rootcause project
            //typecheck the instrumented program
            prog.Resolve();
            prog.Typecheck();

            //Generate VC
            VC.InitializeVCGen(prog);
            VCExpr programVC = VC.GenerateVC(prog, impl);

            //---- generate VC ends ---------

            //Analyze using UNSAT cores for each output
            //Dependencies deps = new Dependencies();
            Console.WriteLine("RefinedDependency[{0}] = [", origProcName);
            outputGuardConsts.Iter(x => AnalyzeDependencyWithUnsatCore(programVC, x, deps, origProcName, inputGuardConsts, outputGuardConsts));
            Console.WriteLine("]");
            VC.FinalizeVCGen(prog);

            return(deps);
        }