protected IEnumerable <BoogieVerb> getBoogieVerbs(VerificationRequest verificationRequest)
        {
            if (verificationRequest.verifyMode == VerificationRequest.VerifyMode.NoVerify)
            {
                return(new BoogieVerb[] { });
            }

            BoogieAsmDepBase.BasmModuleAccumulator acc = new BoogieAsmDepBase.BasmModuleAccumulator(context, upstreamObj, includeAllImps());
            List <BuildObject> basmModules             = new List <BuildObject>(acc.basmModules.Where(mod => !mod.isTrusted));

            OrderPreservingSet <BoogieVerb> normal_Boogie  = new OrderPreservingSet <BoogieVerb>();
            OrderPreservingSet <BoogieVerb> SymDiff_Boogie = new OrderPreservingSet <BoogieVerb>();

            foreach (BuildObject basmModule in basmModules)
            {
                if (verificationRequest.verifyMode == VerificationRequest.VerifyMode.SelectiveVerify &&
                    !verificationRequest.selectiveVerifyModuleNames.Contains(basmModule.getFileNameWithoutExtension()))
                {
                    continue;
                }
                normal_Boogie.Add(new BoogieVerb(context, basmModule, symdiff: VerificationRequest.SymDiffMode.NoSymDiff));

                if (verificationRequest.getSymDiffMode() == VerificationRequest.SymDiffMode.UseSymDiff &&
                    BoogieAsmVerifyVerb.needs_symdiff(basmModule))
                {
                    SymDiff_Boogie.Add(new BoogieVerb(context, basmModule, symdiff: VerificationRequest.SymDiffMode.UseSymDiff));
                }
            }

            return(SymDiff_Boogie.Union(normal_Boogie));
        }
        public override IEnumerable <BuildObject> getDependencies(out DependencyDisposition ddisp)
        {
            ddisp = DependencyDisposition.Complete;

            OrderPreservingSet <BuildObject> deps = new OrderPreservingSet <BuildObject>();

            // Things we need to stitch the interface:
            deps.Add(this.genericStitch);
            deps.Add(this.appSpecificStitch);
            deps.AddRange(this.mainBeatVerb.getOutputs());

            // Things we need to stitch the imports into the imp file:
            deps.Add(this.entryImpInput);
            deps.Add(this.context.getContextOutput());
            IIncludePathContext pathContext = this.context.fetchIfAvailable(ref ddisp);

            if (pathContext != null)
            {
                this.dafnyMainIfcInput = pathContext.search("dafny_Main_i", ModPart.Ifc);
                Util.Assert(this.dafnyMainIfcInput != null);
                deps.Add(this.dafnyMainIfcInput);
                this.dafnyMainImpInput = pathContext.search("dafny_Main_i", ModPart.Ifc);
                Util.Assert(this.dafnyMainImpInput != null);
                deps.Add(this.dafnyMainImpInput);
            }

            return(deps);
        }
Beispiel #3
0
        public override IEnumerable <BuildObject> getDependencies(out DependencyDisposition ddisp)
        {
            OrderPreservingSet <BuildObject> deps = BeatExtensions.getBeatFlavoredShallowDependencies(
                this.contextVerb, this.beatobj, out ddisp, BeatIncludes.ImportFilter.ForBeatOrBasm);

            deps.Add(this.getBeatExecutable());
            return(deps);
        }
Beispiel #4
0
        //- The list belongs to the caller to .Add() to as desired.
        public static OrderPreservingSet <BuildObject> getBasmFlavoredTransitiveDependencies(IContextGeneratingVerb context, BuildObject rootObj, out DependencyDisposition ddisp)
        {
            OrderPreservingSet <BuildObject> result = new OrderPreservingSet <BuildObject>();
            TransitiveDepsVerb depsVerb             = getBasmFlavoredTransitiveDepVerb(context, rootObj);

            result.Add(depsVerb.depsObj());
            result.AddRange(depsVerb.getAvailableDeps(out ddisp));
            //- NB add root object at end of list, to keep it in definition-dependency order
            result.Add(rootObj);
            return(result);
        }
Beispiel #5
0
        public IEnumerable <BuildObject> getIncludes(BuildObject beatsrc)
        {
            IHasher hasher = BuildEngine.theEngine.getHasher();
            OrderPreservingSet <BuildObject> includes = new OrderPreservingSet <BuildObject>();

            BuildObject ifcFile = hasher.search(this.includePathSearcher, beatsrc.getFileNameWithoutExtension(), ModPart.Ifc);
            BuildObject impFile = hasher.search(this.includePathSearcher, beatsrc.getFileNameWithoutExtension(), ModPart.Imp);

            Util.Assert(ifcFile.Equals(beatsrc) || impFile.Equals(beatsrc));
            includes.AddRange(this.directIncludes.getBasmIncludes(ifcFile));
            includes.AddRange(this.directIncludes.getBasmIncludes(impFile));
            return(includes);
        }
Beispiel #6
0
        private static IEnumerable <BeatIncludes.LabeledInclude> getBeatFlavoredShallowIncludesLabeled(
            IContextGeneratingVerb contextVerb, BuildObject rootObj)
        {
            ContextContents context = (ContextContents)
                                      BuildEngine.theEngine.getNuObjContents().openVirtual(contextVerb.getContextOutput());
            BeatIncludes includes = new BeatIncludes(context.context);
            OrderPreservingSet <BeatIncludes.LabeledInclude> result = new OrderPreservingSet <BeatIncludes.LabeledInclude>(
                includes.getLabeledIncludes(rootObj));

            if (BeatExtensions.whichPart(rootObj) == ModPart.Imp)
            {
                BuildObject rootIfc = context.context.search(rootObj.getFileNameWithoutExtension(), ModPart.Ifc);
                result.Add(new BeatIncludes.LabeledInclude(BeatIncludes.ImportFilter.ForBeatOrBasm, rootIfc));
            }
            return(result);
        }
        IEnumerable <SourcePath> getTrustedBoogieAxioms()
        {
            OrderPreservingSet <SourcePath> result = new OrderPreservingSet <SourcePath>();
            AnnotationScanner anns = new AnnotationScanner(basmInput);

            foreach (string[] annotation in anns.getAnnotations(AddBoogieAxiomAnnotation))
            {
                string     module      = annotation[1];
                SourcePath trustedPath = new SourcePath(Path.Combine(
                                                            BuildEngine.theEngine.getSrcRoot(),
                                                            BuildEngine.VerveTrustedSpecDir,
                                                            module + BoogieVerb.BPL_EXTN));
                result.Add(trustedPath);
            }
            return(result);
        }
Beispiel #8
0
        protected override IEnumerable <SourcePath> getRootArgs()
        {
            OrderPreservingSet <SourcePath> specFiles = new OrderPreservingSet <SourcePath>();

            specFiles.Add(this.getDafnyPrelude());
            specFiles.Add(this.getSeqSpec());
            DependencyDisposition ddisp;

            foreach (SourcePath src in this.getAllDafnyModules(out ddisp))
            {
                if (this.transformFilterAccepts(src))
                {
                    specFiles.Add(src);
                }
            }

            return(specFiles);
        }
        public override IVerbWorker getWorker()
        {
            OrderPreservingSet <BuildObject> shallowDeps    = new OrderPreservingSet <BuildObject>();
            OrderPreservingSet <BuildObject> transitiveDeps = new OrderPreservingSet <BuildObject>();

            IEnumerable <BuildObject> includes = getIncludeFactory().getIncludes(obj);

            foreach (BuildObject child in includes)
            {
                shallowDeps.Add(child);
                transitiveDeps.AddRange(factory(child).getTransitiveIncludes());
                transitiveDeps.Add(child);
            }
            VirtualContents contents = new TransitiveDepsContents(shallowDeps, transitiveDeps);

            BuildEngine.theEngine.getNuObjContents().storeVirtual(depsObj(), new Fresh(), contents);
            return(new VerbSyncWorker(new Fresh()));
        }
Beispiel #10
0
        //- This used to use a BeatTransitiveDepsVerb, but we're going with shallow dependencies at the moment.
        //- We may want to restore that behavior later, if we can get some sane transitive dep tree worked out for
        //- Verve code.
        //- The returned list belongs to the caller to .Add() to as desired.
        //- TODO this really needs to be factored to supply the actual Beat-flavored references separately
        //- from the auxiliary deps (transitive dep objects and context dep objects), so we don't have
        //- client code trying to filter back out the part it wants. Brittle.
        public static OrderPreservingSet <BuildObject> getBeatFlavoredShallowDependencies(
            IContextGeneratingVerb contextVerb, BuildObject rootObj, out DependencyDisposition ddisp, BeatIncludes.ImportFilter filter)
        {
            OrderPreservingSet <BuildObject> result = new OrderPreservingSet <BuildObject>();

            result.Add(contextVerb.getContextOutput());
            try
            {
                result.AddRange(getBeatFlavoredShallowIncludes(contextVerb, rootObj, filter));
                ddisp = DependencyDisposition.Complete;
            }
            catch (ObjNotReadyException)
            {
                ddisp = DependencyDisposition.Incomplete;
            }
            catch (ObjFailedException)
            {
                ddisp = DependencyDisposition.Failed;
            }
            result.Add(rootObj);    //- root really needs to go at the end of the list.
            return(result);
        }
            public BasmModuleAccumulator(IContextGeneratingVerb contextGenVerb, BuildObject upstreamObj, bool linkMode)
            {
                this._contextGenVerb = contextGenVerb;
                this._mutableVerbSet = new HashSet <IVerb>();
                //- NB preserve module definition-dependency order
                this._basmModules   = new OrderPreservingSet <BuildObject>();
                this._auxiliaryDeps = new HashSet <BuildObject>();
                _ddisp = DependencyDisposition.Complete;

                //-try
                //-{
                _mutableVerbSet.Add(contextGenVerb);
                _auxiliaryDeps.UnionWith(contextGenVerb.getOutputs());

                context = contextGenVerb.fetchIfAvailable(ref _ddisp);

                if (context != null)
                {
                    OrderPreservingSet <BuildObject> deps;
                    if (!linkMode)
                    {
                        deps = BeatExtensions.getBeatFlavoredShallowDependencies(
                            contextGenVerb, upstreamObj, out _ddisp, BeatIncludes.ImportFilter.ForBasmOnly);
                    }
                    else
                    {
                        deps = BeatExtensions.getBasmFlavoredTransitiveDependencies(contextGenVerb, upstreamObj, out _ddisp);
                        _mutableVerbSet.Add(BeatExtensions.getBasmFlavoredTransitiveDepVerb(_contextGenVerb, upstreamObj));
                    }
                    string  targetModName = upstreamObj.getFileNameWithoutExtension();
                    ModPart targetModPart = BeatExtensions.whichPart(upstreamObj);

                    //- NB security policy note: When verifying X.imp, we must be sure to supply X.ifc
                    //- to BoogieAsm, so that we know that we're actually verifying the promises
                    //- that other modules are relying on when they say "X" (which is how X got on
                    //- the verification obligation list). That property happens automatically here,
                    //- because we make a list of modules (ignoring ifc/imp part), such as {A,B,X},
                    //- and include *every* .ifc. If we're verifying X.imp, a conditional test
                    //- includes it at the time we consider module X.

                    foreach (BuildObject dep in deps)
                    {
                        string depExtn = dep.getExtension();
                        if (depExtn == null ||
                            depExtn.EndsWith(TransitiveDepsVerb.TDEP_EXTN) ||
                            depExtn.EndsWith(ContextGeneratingVerb.CONTEXT_EXTN))
                        {
                            _auxiliaryDeps.Add(dep);
                        }
                        else
                        {
                            Util.Assert(depExtn.Equals(BeatExtensions.BEATIFC_EXTN) ||
                                        depExtn.Equals(BeatExtensions.BEATIMP_EXTN) ||
                                        depExtn.Equals(BASMIFC_EXTN) ||
                                        depExtn.Equals(BASMIMP_EXTN)); //- Burned too many times by this silly filter-out strategy.
                            string  modName = dep.getFileNameWithoutExtension();
                            ModPart modPart = BeatExtensions.whichPart(dep);
                            getBasmModule(modName, ModPart.Ifc);
                            if ((dep.Equals(upstreamObj) && modPart == ModPart.Imp) || linkMode)
                            {
                                getBasmModule(modName, ModPart.Imp);
                            }
                        }
                    }
                }
                //-}
                //-catch (ObjNotReadyException)
                //-{
                //-
                //-    _ddisp = DependencyDisposition.Incomplete;
                //-}
                //-catch (ObjFailedException)
                //-{
                //-    _ddisp = DependencyDisposition.Failed;
                //-}
            }
 public TransitiveDepsContents(OrderPreservingSet <BuildObject> shallowDeps, OrderPreservingSet <BuildObject> transitiveDeps)
 {
     _shallowDeps    = shallowDeps;
     _transitiveDeps = transitiveDeps;
 }