Пример #1
0
        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);
        }
Пример #2
0
        public static List <LabeledInclude> parseLabeledIncludes(IIncludePathContext context, BuildObject beatsrc)
        {
            //-Logger.WriteLine("parseLabeledIncludes " + beatsrc.getRelativePath() + " context " + context.GetHashCode());

            List <LabeledInclude> outlist = new List <LabeledInclude>();
            //-Regex re = new Regex("^\\s*import\\s*([^\\s,]*(,\\s*[^\\s,]*)*)\\s*;");
            //- TODO allow commented-out imports until Beat accepts (ignores) them in ifcs files.
            Regex            import_re   = new Regex("^[\\s/-]*private-import\\s*([^\\s,]*(,\\s*[^\\s,]*)*)\\s*;");
            Regex            basmonly_re = new Regex("^[\\s/-]*private-basmonly-import\\s*([^\\s,]*(,\\s*[^\\s,]*)*)\\s*;");
            FetchModuleCache fmcache     = fetchModuleCaches.get(context);

            using (TextReader tr = BuildEngine.theEngine.getNuObjContents().openRead(beatsrc))
            {
                while (true)
                {
                    string line = tr.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    Match match = import_re.Match(line);
                    if (match.Success)
                    {
                        outlist.Add(new LabeledInclude(ImportFilter.ForBeatOrBasm, fmcache.get(match.Groups[1].ToString())));
                    }
                    match = basmonly_re.Match(line);
                    if (match.Success)
                    {
                        outlist.Add(new LabeledInclude(ImportFilter.ForBasmOnly, fmcache.get(match.Groups[1].ToString())));
                    }
                }
                //-Logger.WriteLine(String.Format("{0} includes {1} things", dfysource.getFilesystemPath(), outlist.Count));
                return(outlist);
            }
        }
Пример #3
0
        public static List<LabeledInclude> parseLabeledIncludes(IIncludePathContext context, BuildObject beatsrc)
        {
            ////Logger.WriteLine("parseLabeledIncludes " + beatsrc.getRelativePath() + " context " + context.GetHashCode());

            List<LabeledInclude> outlist = new List<LabeledInclude>();
            ////Regex re = new Regex("^\\s*import\\s*([^\\s,]*(,\\s*[^\\s,]*)*)\\s*;");
            // TODO allow commented-out imports until Beat accepts (ignores) them in ifcs files.
            Regex import_re = new Regex("^[\\s/-]*private-import\\s*([^\\s,]*(,\\s*[^\\s,]*)*)\\s*;");
            Regex basmonly_re = new Regex("^[\\s/-]*private-basmonly-import\\s*([^\\s,]*(,\\s*[^\\s,]*)*)\\s*;");
            FetchModuleCache fmcache = fetchModuleCaches.get(context);
            using (TextReader tr = BuildEngine.theEngine.Repository.OpenRead(beatsrc))
            {
                while (true)
                {
                    string line = tr.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    Match match = import_re.Match(line);
                    if (match.Success)
                    {
                        outlist.Add(new LabeledInclude(ImportFilter.ForBeatOrBasm, fmcache.get(match.Groups[1].ToString())));
                    }

                    match = basmonly_re.Match(line);
                    if (match.Success)
                    {
                        outlist.Add(new LabeledInclude(ImportFilter.ForBasmOnly, fmcache.get(match.Groups[1].ToString())));
                    }
                }

                ////Logger.WriteLine(string.Format("{0} includes {1} things", dfysource.getFilesystemPath(), outlist.Count));
                return outlist;
            }
        }
Пример #4
0
 public List <BeatIncludes.LabeledInclude> getParsedIncludes(IIncludePathContext context, BuildObject beatsrc)
 {
     return(_parsedIncludesCache.get(new Tuple <IIncludePathContext, BuildObject>(context, beatsrc)));
 }
Пример #5
0
 public BuildObject search(IIncludePathContext context, string modName, ModPart modPart)
 {
     return(_contextResolutionCache.get(new Tuple <IIncludePathContext, string, ModPart>(context, modName, modPart)));
 }
Пример #6
0
 public List<BeatIncludes.LabeledInclude> getParsedIncludes(IIncludePathContext context, BuildObject beatsrc)
 {
     return this.parsedIncludesCache.get(new Tuple<IIncludePathContext, BuildObject>(context, beatsrc));
 }
Пример #7
0
 public BuildObject search(IIncludePathContext context, string modName, ModPart modPart)
 {
     return this.contextResolutionCache.get(new Tuple<IIncludePathContext, string, ModPart>(context, modName, modPart));
 }
Пример #8
0
 public BasmObligationIncludes(IIncludePathContext includePathSearcher)
 {
     this.includePathSearcher = includePathSearcher;
     this.directIncludes      = new BeatIncludes(includePathSearcher);
 }
Пример #9
0
 public BeatIncludes(IIncludePathContext includePathSearcher)
 {
     this.includePathSearcher = includePathSearcher;
 }
Пример #10
0
 public BeatIncludes(IIncludePathContext includePathSearcher)
 {
     this.includePathSearcher = includePathSearcher;
 }
Пример #11
0
 public ContextContents(IIncludePathContext context)
 {
     this.context = context;
 }
Пример #12
0
 public StaticContextVerb(IIncludePathContext context, string nickname, PoundDefines poundDefines)
     : base(nickname, poundDefines)
 {
     this._context = context;
 }
Пример #13
0
 public BasmObligationIncludes(IIncludePathContext includePathSearcher)
 {
     this.includePathSearcher = includePathSearcher;
     this.directIncludes = new BeatIncludes(includePathSearcher);
 }
Пример #14
0
            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));
                    }

                    // REVIEW: The following two variables are unused.  Remove?
                    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)
                ////{
                ////    // oh, we don't even have the context object yet.
                ////    _ddisp = DependencyDisposition.Incomplete;
                ////}
                ////catch (ObjFailedException)
                ////{
                ////    _ddisp = DependencyDisposition.Failed;
                ////}
            }
Пример #15
0
 public ContextContents(IIncludePathContext context)
 {
     this._context = context;
 }
Пример #16
0
 public FetchModuleCache(IIncludePathContext context)
 {
     this.beatIncludes = new BeatIncludes(context);
     this.cache        = new CachedHash <string, BuildObject>(fetchModule);
 }
Пример #17
0
 public StaticContextVerb(IIncludePathContext context, string nickname, PoundDefines poundDefines)
     : base(nickname, poundDefines)
 {
     this._context = context;
 }
Пример #18
0
            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;
                //-}
            }
Пример #19
0
 public FetchModuleCache(IIncludePathContext context)
 {
     this.beatIncludes = new BeatIncludes(context);
     this.cache = new CachedHash<string, BuildObject>(this.fetchModule);
 }