Пример #1
0
        /// <summary>
        /// Gets a list of the include files included in the given Dafny source file.
        /// </summary>
        /// <param name="dfysource">Source file to extract include file names from.</param>
        /// <returns>List of include file BuildObjects.</returns>
        public IEnumerable <BuildObject> getIncludes(BuildObject dfysource)
        {
            List <BuildObject> outlist = new List <BuildObject>();

            using (TextReader tr = BuildEngine.theEngine.Repository.OpenRead(dfysource))
            {
                while (true)
                {
                    string line = tr.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    Match match = this.includeRegex.Match(line);
                    int   count = 0;
                    while (match.Success)
                    {
                        string     includedPath = match.Groups[1].ToString();
                        string     gluedPath    = Path.Combine(dfysource.getDirPath(), includedPath);
                        SourcePath sp           = new SourcePath(gluedPath);
                        outlist.Add(sp);
                        count += 1;
                        match  = match.NextMatch(); // That would be unexpected!
                    }

                    Util.Assert(count <= 1);
                }
            }

            ////Logger.WriteLine(String.Format("{0} includes {1} things", dfysource.getFilesystemPath(), outlist.Count));
            return(outlist);
        }
Пример #2
0
        /// <summary>
        /// Gets a list of the include files included in the given Dafny source file.
        /// </summary>
        /// <param name="dfysource">Source file to extract include file names from.</param>
        /// <returns>List of include file BuildObjects.</returns>
        public IEnumerable<BuildObject> getIncludes(BuildObject dfysource)
        {
            List<BuildObject> outlist = new List<BuildObject>();
            using (TextReader tr = BuildEngine.theEngine.Repository.OpenRead(dfysource))
            {
                while (true)
                {
                    string line = tr.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    Match match = this.includeRegex.Match(line);
                    int count = 0;
                    while (match.Success)
                    {
                        string includedPath = match.Groups[1].ToString();
                        string gluedPath = Path.Combine(dfysource.getDirPath(), includedPath);
                        SourcePath sp = new SourcePath(gluedPath);
                        outlist.Add(sp);
                        count += 1;
                        match = match.NextMatch();  // That would be unexpected!
                    }

                    Util.Assert(count <= 1);
                }
            }

            ////Logger.WriteLine(String.Format("{0} includes {1} things", dfysource.getFilesystemPath(), outlist.Count));
            return outlist;
        }
Пример #3
0
        public BootableAppVerb(SourcePath dfyroot, DafnyCCVerb.FramePointerMode useFramePointer, VerificationRequest verificationRequest)
        {
            this.dfyroot             = dfyroot;
            this.verificationRequest = verificationRequest;
            string concreteId = verificationRequest.ToString() + "," + useFramePointer.ToString();

            this.abstractId = new AbstractId(this.GetType().Name, version, dfyroot.ToString(), concrete: concreteId);

            string targetDirectory = Path.Combine(
                BuildEngine.theEngine.getObjRoot(),
                dfyroot.getDirPath(),
                "bootable-" + verificationRequest.ToString());

            this.bootIniFile = new BuildObject(Path.Combine(targetDirectory, "safeos\\boot.ini"));

            // TODO: Create the bootloader verb.

            this.loaderVerb = new IroncladAppVerb(new SourcePath(LOADER_DFY), IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest);
            this.appVerb    = new IroncladAppVerb(dfyroot, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest);

            this.batchVerb = new BatchVerifyVerb(dfyroot, new HashSet <IObligationsProducer>()
            {
                this.appVerb, this.loaderVerb
            }, BatchVerifyVerb.BatchMode.APP);
            this.batchSummaryVerb = new VerificationResultSummaryVerb(this.batchVerb);

            this.loaderCopy        = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.loaderVerb)));
            this.bootloaderCopy    = new BuildObject(Path.Combine(targetDirectory, this.bootloader.getFileName()));
            this.appExecutableCopy = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.appVerb)));
        }
Пример #4
0
        public BoogieVerb(IContextGeneratingVerb context, BuildObject bplInput, VerificationRequest.SymDiffMode symdiff)
        {
            if (bplInput.getExtension().Equals(BPL_EXTN))
            {
                this.bplInput = bplInput;
                upstreamVerbs = new List<IVerb>();
                // TODO this will probably break, since we don't know where this bplInput came from. Maybe that's okay, since the verb had to already exist to reach this point.
            }
            else if (symdiff == VerificationRequest.SymDiffMode.NoSymDiff)
            {
                IVerb boogieAsmVerb = new BoogieAsmVerifyVerb(context, bplInput, false);
                this.bplInput = boogieAsmVerb.getOutputs().First();
                upstreamVerbs = new IVerb[] { boogieAsmVerb };
            }
            else
            {
                IVerb workerVerb;
                SymDiffEngine.BuildPipeline(context, bplInput, out this.bplInput, out workerVerb);
                upstreamVerbs = new IVerb[] { workerVerb };
            }

            this.abstractId = new AbstractId(
                this.GetType().Name,
                version,
                bplInput.ToString(),
                concrete: symdiff.ToString());
        }
Пример #5
0
        public override IVerbWorker getWorker(WorkingDirectory workingDirectory)
        {
            List <string> args = new List <string>();

            //// args.add(BUILD_DEFS
            //// args.add(boogieasm_flags)
            args.Add(getAction());
            BuildObject captureStdout = null;

            if (outFlagWorks())
            {
                args.Add("-out");
                args.Add(outputFile().getRelativePath());
            }
            else
            {
                captureStdout = outputFile();
            }

            BasmModuleAccumulator acc = new BasmModuleAccumulator(context, upstreamObj, includeAllImps());

            Util.Assert(acc.ddisp == DependencyDisposition.Complete);
            args.AddRange(acc.basmModules.Select(module => module.getRelativePath()));
            args.AddRange(context.getPoundDefines().ToDefArgs());
            extendArgs(args);

            return(new ProcessInvokeAsyncWorker(
                       workingDirectory,
                       this,
                       getBoogieasmExecutable().getRelativePath(),
                       args.ToArray(),
                       ProcessExitCodeHandling.NonzeroIsFailure,
                       getDiagnosticsBase(),
                       captureStdout: captureStdout));
        }
Пример #6
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);
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the IronfleetAppVerb class.
        /// </summary>
        /// <param name="input">Main dafny file for the application.</param>
        public IronfleetAppVerb(SourcePath input, VerificationRequest verificationRequest, bool releaseBuild = false)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            this.abstractId = new AbstractId(GetType().Name, Version, input.ToString() + verificationRequest.ToString());
            this.input = input;
            this.buildVerb = new VSSolutionVerb(new SourcePath(@"src\IronfleetTestDriver\IronfleetTestDriver.sln"), input, releaseBuild);

            if (verificationRequest.verifyMode == VerificationRequest.VerifyMode.NoVerify)
            {
                this.exeOutput = this.input.makeOutputObject(UnverifiedExeExt);
                this.verifyVerb = null;
                this.verbs = new IVerb[] { this.buildVerb };
            }
            else
            {
                this.exeOutput = this.input.makeOutputObject(VerifiedExeExt);
                this.verifyVerb = new VerificationResultSummaryVerb(new DafnyVerifyTreeVerb(input));
                this.verbs = new IVerb[] { this.verifyVerb, this.buildVerb };
            }

            this.otherOutputs = new List<BuildObject>();
            var ohs = this.buildVerb.getOutputs().ToList();
            ohs.RemoveAll(o => o.getExtension() == ".exe");
            foreach (var o in ohs)
            {
                this.otherOutputs.Add(RelocateBuildObjectToExeDirectory(o));
            }
        }
Пример #8
0
        public BatchVerifyVerb(SourcePath batch_file, BatchMode mode, VerificationRequest verificationRequest, DafnyCCVerb.FramePointerMode useFramePointer)
        {
            this.mode = mode;

            this.producers = new HashSet<IObligationsProducer>();
            foreach (string line in File.ReadAllLines(batch_file.getFilesystemPath())) {
                if (line[0] == '#')
                {
                    continue;
                }
                SourcePath src = new SourcePath(line);
                switch (mode) {
                    case BatchMode.DAFNY:
                        if (verificationRequest.verifyMode != VerificationRequest.VerifyMode.Verify)
                        {
                            throw new UserError("BatchVerify DAFNY only supports full verification (but maybe we should add selective?)");
                        }
                        this.producers.Add(new DafnyVerifyTreeVerb(src));
                        break;
                    case BatchMode.APP:
                        this.producers.Add(new IroncladAppVerb(src, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest));
                        break;
                    default:
                        throw new Exception("Unknown batch file type");
                }
            }

            string parameters = mode.ToString() + "," + verificationRequest.ToString();
            outputObject = batch_file.makeLabeledOutputObject(parameters, BATCH_EXTN + VerificationObligationList.VOL_EXTN);
            abstractId = new AbstractId(this.GetType().Name, version, batch_file.ToString(), concrete:parameters);
        }
Пример #9
0
        public BatchVerifyVerb(BuildObject batch_label, HashSet<IObligationsProducer> producers, BatchMode mode) {            
            this.mode = mode;
            this.producers = producers;

            outputObject = batch_label.makeOutputObject(BATCH_EXTN + VerificationObligationList.VOL_EXTN);
            abstractId = new AbstractId(this.GetType().Name, version, batch_label.ToString(), concrete:mode.ToString());            
        }
Пример #10
0
        public IVerb getParent(BuildObject dep)
        {
            IVerb result;

            outputToVerbMap.TryGetValue(dep, out result);
            return(result);
        }
Пример #11
0
        /// <summary>
        /// Initializes a new instance of the IronfleetAppVerb class.
        /// </summary>
        /// <param name="input">Main dafny file for the application.</param>
        public IronfleetAppVerb(SourcePath input, VerificationRequest verificationRequest, bool releaseBuild = false)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            this.abstractId = new AbstractId(GetType().Name, Version, input.ToString() + verificationRequest.ToString());
            this.input      = input;
            // this.buildVerb = new VSSolutionVerb(new SourcePath(@"src\IronfleetTestDriver\IronfleetTestDriver.sln"), input, releaseBuild);
            this.buildVerb = new VSSolutionVerb(new SourcePath(@"src/IronfleetTestDriver/IronfleetTestDriver.sln"), input, releaseBuild);

            if (verificationRequest.verifyMode == VerificationRequest.VerifyMode.NoVerify)
            {
                this.exeOutput  = this.input.makeOutputObject(UnverifiedExeExt);
                this.verifyVerb = null;
                this.verbs      = new IVerb[] { this.buildVerb };
            }
            else
            {
                this.exeOutput  = this.input.makeOutputObject(VerifiedExeExt);
                this.verifyVerb = new VerificationResultSummaryVerb(new DafnyVerifyTreeVerb(input));
                this.verbs      = new IVerb[] { this.verifyVerb, this.buildVerb };
            }

            this.otherOutputs = new List <BuildObject>();
            var ohs = this.buildVerb.getOutputs().ToList();

            ohs.RemoveAll(o => o.getExtension() == ".exe");
            foreach (var o in ohs)
            {
                this.otherOutputs.Add(RelocateBuildObjectToExeDirectory(o));
            }
        }
Пример #12
0
        public AnnotationScanner(BuildObject inputObject)
        {
            this.inputObject = inputObject;
            this.annotations = new List <string[]>();
            Regex re = new Regex("<NuBuild([^>]*)/>");

            using (TextReader tr = BuildEngine.theEngine.Repository.OpenRead(inputObject))
            {
                while (true)
                {
                    string line = tr.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    Match match = re.Match(line);
                    if (match.Success)
                    {
                        string[] arguments = match.Groups[1].ToString().Split(null).Where(s => s.Length > 0).ToArray();
                        this.annotations.Add(arguments);
                    }
                }
            }

            this.complete = true;
        }
Пример #13
0
        public BoogieVerb(IContextGeneratingVerb context, BuildObject bplInput, VerificationRequest.SymDiffMode symdiff)
        {
            if (bplInput.getExtension().Equals(BPL_EXTN))
            {
                this.bplInput = bplInput;
                upstreamVerbs = new List <IVerb>();
                // TODO this will probably break, since we don't know where this bplInput came from. Maybe that's okay, since the verb had to already exist to reach this point.
            }
            else if (symdiff == VerificationRequest.SymDiffMode.NoSymDiff)
            {
                IVerb boogieAsmVerb = new BoogieAsmVerifyVerb(context, bplInput, false);
                this.bplInput = boogieAsmVerb.getOutputs().First();
                upstreamVerbs = new IVerb[] { boogieAsmVerb };
            }
            else
            {
                IVerb workerVerb;
                SymDiffEngine.BuildPipeline(context, bplInput, out this.bplInput, out workerVerb);
                upstreamVerbs = new IVerb[] { workerVerb };
            }

            this.abstractId = new AbstractId(
                this.GetType().Name,
                version,
                bplInput.ToString(),
                concrete: symdiff.ToString());
        }
Пример #14
0
        public BootableAppVerb(SourcePath dfyroot, DafnyCCVerb.FramePointerMode useFramePointer, VerificationRequest verificationRequest)
        {
            this.dfyroot = dfyroot;
            this.verificationRequest = verificationRequest;
            string concreteId = verificationRequest.ToString() + "," + useFramePointer.ToString();
            this.abstractId = new AbstractId(this.GetType().Name, version, dfyroot.ToString(), concrete: concreteId);

            string targetDirectory = Path.Combine(
                BuildEngine.theEngine.getObjRoot(),
                dfyroot.getDirPath(),
                "bootable-" + verificationRequest.ToString());
            this.bootIniFile = new BuildObject(Path.Combine(targetDirectory, "safeos\\boot.ini"));

            // TODO: Create the bootloader verb.

            this.loaderVerb = new IroncladAppVerb(new SourcePath(LOADER_DFY), IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest);
            this.appVerb = new IroncladAppVerb(dfyroot, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest);

            this.batchVerb = new BatchVerifyVerb(dfyroot, new HashSet<IObligationsProducer>() { this.appVerb, this.loaderVerb }, BatchVerifyVerb.BatchMode.APP);
            this.batchSummaryVerb = new VerificationResultSummaryVerb(this.batchVerb);

            this.loaderCopy = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.loaderVerb)));
            this.bootloaderCopy = new BuildObject(Path.Combine(targetDirectory, this.bootloader.getFileName()));
            this.appExecutableCopy = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.appVerb)));
        }
Пример #15
0
 public BeatVerb(IContextGeneratingVerb contextVerb, BuildObject beatobj, string appLabel)
 {
     this.contextVerb = contextVerb;
     this.beatobj = beatobj;
     this.appLabel = appLabel;
     this.abstractId = new AbstractId(this.GetType().Name, version, beatobj.ToString(), contextVerb.getPoundDefines(), concrete: appLabel);
 }
Пример #16
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;
        }
Пример #17
0
        //- Remove any verb with obj in its dependency set.
        internal IEnumerable <IVerb> awaken(BuildObject obj)
        {
            Say("awaken " + obj);
            HashSet <WaitRecord> wokenRecords;
            HashSet <IVerb>      result = new HashSet <IVerb>();

            if (fwdDeps.ContainsKey(obj))
            {
                wokenRecords = fwdDeps[obj];
                fwdDeps.Remove(obj);

                //- Remove all the other index pointers for each removed verb
                foreach (WaitRecord waitRecord in wokenRecords)
                {
                    foreach (BuildObject dep in waitRecord.knownDeps)
                    {
                        if (fwdDeps.ContainsKey(dep))
                        {
                            fwdDeps[dep].Remove(waitRecord);
                        }
                    }
                    result.Add(waitRecord.verb);
                    waitingVerbs.Remove(waitRecord.verb);
                    Say("  wakes " + waitRecord.verb);
                }
            }
            else
            {
                result = new HashSet <IVerb>();
            }
            return(result);
        }
Пример #18
0
        public static void propagatePrivateImports(
            WorkingDirectory workingDirectory,
            IContextGeneratingVerb contextVerb,
            BuildObject srcobj,
            BuildObject dstobj)
        {
            // Rewrite basm output to propagate any import statements from the beat file.
            // TODO this step really should be a beat function, not part of the build system.
            IEnumerable <BeatIncludes.LabeledInclude> beatImports =
                getBeatFlavoredShallowIncludesLabeled(contextVerb, srcobj);
            StringBuilder sb = new StringBuilder();

            foreach (BeatIncludes.LabeledInclude li in beatImports)
            {
                sb.Append("//-");
                sb.Append(li.importFilter == BeatIncludes.ImportFilter.ForBasmOnly
                    ? "private-basmonly-import" : "private-import");
                sb.Append(" ");
                sb.Append(li.buildObject.getFileNameWithoutExtension());
                sb.AppendLine(";");
            }

            // REVIEW: Improve upon this round-about way of prepending to a file?
            string beatOutput = File.ReadAllText(workingDirectory.PathTo(dstobj));

            File.Delete(workingDirectory.PathTo(dstobj));
            File.WriteAllText(workingDirectory.PathTo(dstobj), sb.ToString() + beatOutput);
        }
Пример #19
0
        public BatchVerifyVerb(SourcePath batch_file, BatchMode mode, VerificationRequest verificationRequest, DafnyCCVerb.FramePointerMode useFramePointer)
        {
            this.mode = mode;

            this.producers = new HashSet<IObligationsProducer>();
            foreach (string line in File.ReadAllLines(IronRootDirectory.PathTo(batch_file)))
            {
                if (line.Equals("") || line[0] == '#')
                {
                    continue;
                }

                SourcePath src = new SourcePath(line);
                switch (mode)
                {
                    case BatchMode.DAFNY:
                        if (verificationRequest.verifyMode != VerificationRequest.VerifyMode.Verify)
                        {
                            throw new UserError("BatchVerify DAFNY only supports full verification (but maybe we should add selective?)");
                        }

                        this.producers.Add(new DafnyVerifyTreeVerb(src));
                        break;
                    case BatchMode.APP:
                        this.producers.Add(new IroncladAppVerb(src, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest));
                        break;
                    default:
                        throw new Exception("Unknown batch file type");
                }
            }

            string parameters = mode.ToString() + "," + verificationRequest.ToString();
            this.outputObject = batch_file.makeLabeledOutputObject(parameters, BATCH_EXTN + VerificationObligationList.VOL_EXTN);
            this.abstractId = new AbstractId(this.GetType().Name, version, batch_file.ToString(), concrete: parameters);
        }
Пример #20
0
        public string getKnownObjectHash(BuildObject obj)
        {
            string hash;
            bool   present = knownObjectHash.TryGetValue(obj, out hash);

            if (!present)
            {
                NuObjValue value = nuObjectContents.getValue(obj);
                if (value != null)
                {
                    if (value.disp is Failed)
                    {
                        return(null);
                    }
                    else if (obj is VirtualBuildObject)
                    {
                        hash = "virtual";
                    }
                    else
                    {
                        hash = hasher.hash(obj.getFilesystemPath());
                    }
                    knownObjectHash[obj] = hash;
                }
            }
            return(hash);
        }
        public override IEnumerable <BuildObject> getDependencies(out DependencyDisposition ddisp)
        {
            BuildObject           obligations = producer.getObligationSet();
            HashSet <BuildObject> deps        = new HashSet <BuildObject>();

            deps.Add(obligations);

            try
            {
                VerificationObligationList vol = VerificationObligationList.fetch(obligations);
                this.verification_results = vol.getVerificationObligations();
                deps.UnionWith(this.verification_results);
                ddisp = DependencyDisposition.Complete;
            }
            catch (ObjNotReadyException)
            {
                ddisp = DependencyDisposition.Incomplete;
            }
            catch (ObjFailedException)
            {
                ddisp = DependencyDisposition.Failed;
            }

            return(deps);
        }
Пример #22
0
 public BeatVerb(IContextGeneratingVerb contextVerb, BuildObject beatobj, string appLabel)
 {
     this.contextVerb = contextVerb;
     this.beatobj     = beatobj;
     this.appLabel    = appLabel;
     this.abstractId  = new AbstractId(this.GetType().Name, version, beatobj.ToString(), contextVerb.getPoundDefines(), concrete: appLabel);
 }
Пример #23
0
        /// <summary>
        /// Gets the verb that created the given object.
        /// </summary>
        /// <remarks>
        /// Would like to rename this to "GetCreator" or "GetCreatorVerb"
        /// as it seems strange to call something a parent when it is a
        /// completely different object type, but the terminology seems
        /// to be widely used in the system.
        /// </remarks>
        /// <param name="obj">The object in question.</param>
        /// <returns>The verb that creates the given object.</returns>
        internal IVerb getParent(BuildObject obj)
        {
            IVerb result;

            this.outputToVerbMap.TryGetValue(obj, out result);
            return(result);
        }
Пример #24
0
 public BuildObject getMutualSummary()
 {
     // SymDiff files need to go into their own directory.
     BuildObject normalName = BeatExtensions.makeOutputObject(basmInput, MUTUAL_SUMMARY_EXTN);
     BuildObject dirExtendedName = new BuildObject(Path.Combine(normalName.getDirPath(), dirName, normalName.getFileName()));
     return dirExtendedName;
 }
Пример #25
0
        public AnnotationScanner(BuildObject inputObject)
        {
            this.inputObject = inputObject;
            this.annotations = new List<string[]>();
            Regex re = new Regex("<NuBuild([^>]*)/>");
            using (TextReader tr = BuildEngine.theEngine.Repository.OpenRead(inputObject))
            {
                while (true)
                {
                    string line = tr.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    Match match = re.Match(line);
                    if (match.Success)
                    {
                        string[] arguments = match.Groups[1].ToString().Split(null).Where(s => s.Length > 0).ToArray();
                        this.annotations.Add(arguments);
                    }
                }
            }

            this.complete = true;
        }
Пример #26
0
        public MasmVerb(IAsmProducer asmVerb)
        {
            this.asmVerb = asmVerb;
            this.asmFile = asmVerb.getAsmFile();

            this.abstractId   = new AbstractId(this.GetType().Name, version, this.asmFile.ToString());
            this.outputObject = this.asmFile.makeOutputObject(OBJ_EXTN);
        }
Пример #27
0
 //- Fetch an object from the cache and store it in the local
 //- nuobj tree.
 //-
 //- NB BuildObjectValuePointers get stored in untrusted places, so we never
 //- actually use their RelativePath values in filesystem calls.
 //- Instead, we require the caller to supply a local BuildObject where
 //- he expects the ptr to point, and we test for equality, and then
 //- use the obj value for filesystem operations.
 void fetchObject(BuildObjectValuePointer ptr, BuildObject obj)
 {
     //-Console.WriteLine("ResultCache.fetchObject " + obj);
     Util.Assert(obj.getRelativePath().Equals(ptr.relativePath));
     File.Delete(obj.getFilesystemPath());
     this.itemCache.FetchItemToFile(ItemCacheContainer.Objects, ptr.objectHash, obj.getFilesystemPath());
     this.knownObjectHash[obj] = ptr.objectHash;
 }
Пример #28
0
        /// <summary>
        /// Reads a build object from the local filesystem and stores it in the
        /// cache.
        /// </summary>
        /// <param name="workingDirectory">
        /// Private directory for verb execution.
        /// </param>
        /// <param name="obj">The build object to store in the cache.</param>
        /// <param name="disposition">
        /// Disposition of verb which created this object (if known).
        /// </param>
        /// <returns>A BuildObjectValuePointer describing the object.</returns>
        public BuildObjectValuePointer Store(WorkingDirectory workingDirectory, BuildObject obj, Disposition disposition)
        {
            string contentHash = Util.hashFilesystemPath(workingDirectory.PathTo(obj));
            this.itemCache.StoreItemFromFile(ItemCacheContainer.Objects, contentHash, workingDirectory.PathTo(obj));
            this.Add(obj, disposition, contentHash, null);

            return new BuildObjectValuePointer(contentHash, obj.getRelativePath());
        }
Пример #29
0
        public MasmVerb(IAsmProducer asmVerb)
        {
            this.asmVerb = asmVerb;
            this.asmFile = asmVerb.getAsmFile();

            this.abstractId = new AbstractId(this.GetType().Name, version, this.asmFile.ToString());
            this.outputObject = this.asmFile.makeOutputObject(OBJ_EXTN);
        }
Пример #30
0
 public static IEnumerable <BuildObject> getBeatFlavoredShallowIncludes(
     IContextGeneratingVerb contextVerb, BuildObject rootObj, BeatIncludes.ImportFilter importFilter)
 {
     return(getBeatFlavoredShallowIncludesLabeled(contextVerb, rootObj)
            .Where(li => importFilter == BeatIncludes.ImportFilter.ForBasmOnly ||
                   li.importFilter == BeatIncludes.ImportFilter.ForBeatOrBasm)
            .Select(li => li.buildObject));
 }
Пример #31
0
        public SymDiffExtractVerb(BoogieAsmVerifyVerb basmVerb, Mode mode)
        {
            this.basmVerb = basmVerb;
            this.basmIn = basmVerb.outputFile();
            this.mode = mode;

            this.abstractId = new AbstractId(this.GetType().Name, version, this.basmIn.ToString(), concrete: mode.ToString());
        }
Пример #32
0
        internal void injectAnnotations(BuildObject dest, string commentToken)
        {
            string annotations = emit(commentToken);
            string destStr     = File.ReadAllText(dest.getFilesystemPath());

            File.Delete(dest.getFilesystemPath());
            File.WriteAllText(dest.getFilesystemPath(), annotations + destStr);
        }
        public BuildObject getMutualSummary()
        {
            //- SymDiff files need to go into their own directory
            BuildObject normalName      = BeatExtensions.makeOutputObject(basmInput, MUTUAL_SUMMARY_EXTN);
            BuildObject dirExtendedName = new BuildObject(Path.Combine(normalName.getDirPath(), Util.mungeClean(getAbstractIdentifier().ToString()), normalName.getFileName()));

            return(dirExtendedName);
        }
        public BuildObject getMutualSummary()
        {
            // SymDiff files need to go into their own directory.
            BuildObject normalName      = BeatExtensions.makeOutputObject(basmInput, MUTUAL_SUMMARY_EXTN);
            BuildObject dirExtendedName = new BuildObject(Path.Combine(normalName.getDirPath(), dirName, normalName.getFileName()));

            return(dirExtendedName);
        }
 public VerificationResultSummaryVerb(IObligationsProducer producer)
 {
     this.producer = producer;
     BuildObject id = producer.getObligationSet(); ////producer.getIdentifier();
     this.outputObject = id.makeOutputObject(id.getExtension() + SUMMARY_EXTN);
     this.abstractId = new AbstractId(this.GetType().Name, version, id.ToString());
     this.verificationResults = null;
 }
Пример #36
0
        public BatchVerifyVerb(BuildObject batch_label, HashSet<IObligationsProducer> producers, BatchMode mode)
        {
            this.mode = mode;
            this.producers = producers;

            this.outputObject = batch_label.makeOutputObject(BATCH_EXTN + VerificationObligationList.VOL_EXTN);
            this.abstractId = new AbstractId(this.GetType().Name, version, batch_label.ToString(), concrete: mode.ToString());
        }
        public SymDiffExtractVerb(BoogieAsmVerifyVerb basmVerb, Mode mode)
        {
            this.basmVerb = basmVerb;
            this.basmIn   = basmVerb.outputFile();
            this.mode     = mode;

            abstractId = new AbstractId(this.GetType().Name, version, basmIn.ToString(), concrete: mode.ToString());
        }
        public VerificationResultSummaryVerb(IObligationsProducer producer)
        {
            this.producer = producer;
            BuildObject id = producer.getObligationSet(); //-producer.getIdentifier();

            outputObject         = id.makeOutputObject(id.getExtension() + SUMMARY_EXTN);
            abstractId           = new AbstractId(this.GetType().Name, version, id.ToString());
            verification_results = null;
        }
Пример #39
0
        public SymDiffMergeVerb(BoogieAsmVerifyVerb basmVerb, SymDiffCombineVerb combiner)
        {
            this.basmVerb = basmVerb;
            this.mutualSummary = basmVerb.getMutualSummary();
            this.combiner = combiner;

            this.abstractId = new AbstractId(this.GetType().Name, version, this.combiner.getOutputFile().ToString()); // String.Format("{0},{1}", One should suffice for uniqueness: mutualSummary, combiner.getOutputFile()));
            this.output = this.basmVerb.outputFile().makeOutputObject(MERGED_EXTN + BoogieVerb.BPL_EXTN);
        }
Пример #40
0
        //- Read an output object from the nuobj tree and store it in the cache.
        public BuildObjectValuePointer storeObject(BuildObject obj)
        {
            string contentHash = hasher.hash(obj.getFilesystemPath());

            this.itemCache.StoreItemFromFile(ItemCacheContainer.Objects, contentHash, obj.getFilesystemPath());
            this.knownObjectHash[obj] = contentHash;

            return(new BuildObjectValuePointer(contentHash, obj.getRelativePath()));
        }
Пример #41
0
 // This is merely an assert double-check that we didn't let a spec generated
 // by DafnyCC slip through to be used in the BoogieAsmVerify step.
 internal static void AssertSmellsImplementy(BuildObject obj)
 {
     string fn = obj.getFileNameWithoutExtension();
     Util.Assert(fn.EndsWith("_" + DafnyTransformBaseVerb.DAFNY_I_SUFFIX)
         || fn.EndsWith("_" + DafnyTransformBaseVerb.DAFNY_C_SUFFIX)
         || fn.Equals("Checked")
         || fn.Equals("Heap")
         || fn.Equals("Seq"));
 }
Пример #42
0
        /// <summary>
        /// Reads a build object from the local filesystem and stores it in the
        /// cache.
        /// </summary>
        /// <param name="workingDirectory">
        /// Private directory for verb execution.
        /// </param>
        /// <param name="obj">The build object to store in the cache.</param>
        /// <param name="disposition">
        /// Disposition of verb which created this object (if known).
        /// </param>
        /// <returns>A BuildObjectValuePointer describing the object.</returns>
        public BuildObjectValuePointer Store(WorkingDirectory workingDirectory, BuildObject obj, Disposition disposition)
        {
            string contentHash = Util.hashFilesystemPath(workingDirectory.PathTo(obj));

            this.itemCache.StoreItemFromFile(ItemCacheContainer.Objects, contentHash, workingDirectory.PathTo(obj));
            this.Add(obj, disposition, contentHash, null);

            return(new BuildObjectValuePointer(contentHash, obj.getRelativePath()));
        }
Пример #43
0
        public AsmRewriterVerb(BoogieAsmLinkVerb asmVerb)
        {
            this.asmVerb    = asmVerb;
            this.asmFileIn  = asmVerb.getAsmFile();
            this.asmFileOut = this.asmFileIn.makeOutputObject(WASM_EXTN);

            this.abstractId   = new AbstractId(this.GetType().Name, version, this.asmFileOut.ToString());
            this.pythonScript = new SourcePath("tools\\scripts\\build-standalone-asm.py", SourcePath.SourceType.Tools);
        }
Пример #44
0
        public SymDiffMergeVerb(BoogieAsmVerifyVerb basmVerb, SymDiffCombineVerb combiner)
        {
            this.basmVerb      = basmVerb;
            this.mutualSummary = basmVerb.getMutualSummary();
            this.combiner      = combiner;

            this.abstractId = new AbstractId(this.GetType().Name, version, this.combiner.getOutputFile().ToString()); // String.Format("{0},{1}", One should suffice for uniqueness: mutualSummary, combiner.getOutputFile()));
            this.output     = this.basmVerb.outputFile().makeOutputObject(MERGED_EXTN + BoogieVerb.BPL_EXTN);
        }
Пример #45
0
        public AsmRewriterVerb(BoogieAsmLinkVerb asmVerb)
        {
            this.asmVerb = asmVerb;
            this.asmFileIn = asmVerb.getAsmFile();
            this.asmFileOut = this.asmFileIn.makeOutputObject(WASM_EXTN);

            this.abstractId = new AbstractId(this.GetType().Name, version, this.asmFileOut.ToString());
            this.pythonScript = new SourcePath("tools\\scripts\\build-standalone-asm.py", SourcePath.SourceType.Tools);
        }
Пример #46
0
        public BuildObject getContextOutput()
        {
            if (this.outputObj == null)
            {
                this.outputObj = new VirtualBuildObject(
                    Path.Combine(BuildEngine.theEngine.getVirtualRoot(), Util.mungeClean(this.getAbstractIdentifier().ToString()) + CONTEXT_EXTN));
            }

            return this.outputObj;
        }
        public SymDiffMergeConfigVerb(BoogieAsmVerifyVerb basmVerb, SymDiffInferVerb inferVerb)
        {
            this.basmVerb       = basmVerb;
            this.mutualSummary  = basmVerb.getMutualSummary();
            this.inferVerb      = inferVerb;
            this.inferredConfig = inferVerb.getOutputFile();

            abstractId = new AbstractId(this.GetType().Name, version, inferredConfig.ToString());  //- One should suffice for uniqueness: String.Format("{0},{1}", mutualSummary,inferredConfig));
            output     = this.basmVerb.outputFile().makeOutputObject(CONFIG_EXTN);
        }
Пример #48
0
        // REVIEW: Make this private?
        internal void injectAnnotations(WorkingDirectory workingDirectory, BuildObject dest, string commentToken)
        {
            string annotations = this.emit(commentToken);

            // REVIEW: Improve upon this round-about way of prepending to a file?
            string destStr = File.ReadAllText(workingDirectory.PathTo(dest));

            File.Delete(workingDirectory.PathTo(dest));
            File.WriteAllText(workingDirectory.PathTo(dest), annotations + destStr);
        }
Пример #49
0
        public SymDiffMergeConfigVerb(BoogieAsmVerifyVerb basmVerb, SymDiffInferVerb inferVerb)
        {
            this.basmVerb = basmVerb;
            this.mutualSummary = basmVerb.getMutualSummary();
            this.inferVerb = inferVerb;
            this.inferredConfig = inferVerb.getOutputFile();

            this.abstractId = new AbstractId(this.GetType().Name, version, this.inferredConfig.ToString());  // One should suffice for uniqueness: String.Format("{0},{1}", mutualSummary,inferredConfig));
            this.output = this.basmVerb.outputFile().makeOutputObject(CONFIG_EXTN);
        }
Пример #50
0
        public static BuildObject computeBasmInput(PoundDefines poundDefines, BuildObject upstreamObj)
        {
            if (BoogieAsmDepBase.isBasm(upstreamObj))
            {
                // We'll be reading upstreamObj directly. Don't makeOutputObject,
                // because it may well be a source file.
                return upstreamObj;
            }

            return BeatExtensions.makeLabeledOutputObject(upstreamObj, poundDefines.ToString(), BASM_EXTN);
        }
Пример #51
0
 protected override bool transformFilterAccepts(BuildObject dfysource)
 {
     string fn = dfysource.getFileNameWithoutExtension();
     if (fn.EndsWith("." + DafnyTransformBaseVerb.DAFNY_S_SUFFIX))
     {
         return true;
     }
     else
     {
         Util.Assert(fn.EndsWith("." + DafnyTransformBaseVerb.DAFNY_I_SUFFIX) || fn.EndsWith("." + DafnyTransformBaseVerb.DAFNY_C_SUFFIX) || dfysource.Equals(this.getDafnyPrelude()));
         return false;
     }
 }
Пример #52
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;
        }
Пример #53
0
        public static void BuildPipeline(IContextGeneratingVerb context, BuildObject input, out BuildObject bplFile, out IVerb workerVerb)
        {
            BoogieAsmVerifyVerb basmVerb = new BoogieAsmVerifyVerb(context, input, true);
            SymDiffExtractVerb left = new SymDiffExtractVerb(basmVerb, SymDiffExtractVerb.Mode.LEFT);
            SymDiffExtractVerb right = new SymDiffExtractVerb(basmVerb, SymDiffExtractVerb.Mode.RIGHT);
            SymDiffInferVerb infer = new SymDiffInferVerb(left, right);
            SymDiffMergeConfigVerb mergeConfig = new SymDiffMergeConfigVerb(basmVerb, infer);
            SymDiffCombineVerb combiner = new SymDiffCombineVerb(left, right, mergeConfig);
            SymDiffMergeVerb merger = new SymDiffMergeVerb(basmVerb, combiner);

            bplFile = merger.getOutputFile();
            workerVerb = merger;
        }
Пример #54
0
        public DafnyCompileOneVerb(SourcePath input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            this.abstractId = new AbstractId(GetType().Name, Version, input.ToString());
            this.input = input;
            this.output = input.makeOutputObject(CSharpExt);
            this.transitiveDepsVerb = new DafnyTransitiveDepsVerb(input);
            this.verbs = new IVerb[] { this.transitiveDepsVerb };
        }
Пример #55
0
 internal static BuildObject makeLabeledOutputObject(BuildObject input, string appLabel, string typeExtn)
 {
     ModPart part = whichPart(input);
     if (part == ModPart.Unknown)
     {
         // Input must be a raw boogie file.
         Util.Assert(input.getExtension().EndsWith(BoogieVerb.BPL_EXTN));
         return input.makeLabeledOutputObject(appLabel, typeExtn);
     }
     else
     {
         return input.makeLabeledOutputObject(appLabel, part.ExtnStr() + typeExtn);
     }
 }
Пример #56
0
        public override BuildObject outputFile()
        {
            if (buildSymDiffMutualSummary)
            {
                // SymDiff files need to go into their own directory
                BuildObject normalName = BeatExtensions.makeOutputObject(basmInput, SYMDIFF_EXTN);
                dirName = normalName.getFileName() + SYMDIFF_DIR_EXTN;
                BuildObject dirExtendedName = new BuildObject(Path.Combine(normalName.getDirPath(), dirName, normalName.getFileName()));

                return dirExtendedName;
            }
            else
            {
                return BeatExtensions.makeOutputObject(basmInput, BoogieVerb.BPL_EXTN);
            }
        }
Пример #57
0
        public SymDiffCombineVerb(SymDiffExtractVerb left, SymDiffExtractVerb right, SymDiffMergeConfigVerb merger)
        {
            this.left = left;
            this.right = right;
            this.merger = merger;

            // Naming one of the files should be sufficient to uniquely identify the combiner.
            this.abstractId = new AbstractId(this.GetType().Name, version, left.getOutputFile().ToString());
            ////abstractId = String.Format("{0}(#{1},{2},{3},{4})",
            ////    this.GetType().Name,
            ////    version,
            ////    left.getOutputFile(),
            ////    right.getOutputFile(),
            ////    merger.getOutputFile());
            this.outputFile = this.mkOutputFile();
        }
        public static VerificationObligationList fetch(BuildObject obj)
        {
            VerificationObligationList vol = new VerificationObligationList();
            using (TextReader sr = BuildEngine.theEngine.Repository.OpenRead(obj))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    Util.Assert(!line.StartsWith(BuildEngine.theEngine.getSrcRoot()));   // unimplemented
                    Util.Assert(!line.StartsWith(BuildEngine.theEngine.getVirtualRoot()));   // nonsense
                    vol.Add(new BuildObject(line));
                }
            }

            vol.complete = true;
            return vol;
        }
Пример #59
0
        private static IEnumerable<BeatIncludes.LabeledInclude> getBeatFlavoredShallowIncludesLabeled(
            IContextGeneratingVerb contextVerb, BuildObject rootObj)
        {
            ContextContents context = (ContextContents)
                BuildEngine.theEngine.Repository.FetchVirtual(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;
        }
Пример #60
0
        public static bool needs_symdiff(BuildObject basm)
        {
            AnnotationScanner annotations = new AnnotationScanner(basm);
            bool symdiff = false;
            foreach (string[] ann in annotations.getAnnotations(BasmEnableSymdiffAnnotation))
            {
                if (ann.Length != 2
                    || !ann[1].Equals("true"))
                {
                    throw new SourceConfigurationError("Expected " + BasmEnableSymdiffAnnotation + " to have argument 'true'.");
                }

                symdiff = true;
            }

            return symdiff;
        }