示例#1
0
 public DafnyCCVerb(SourcePath dfyroot, string appLabel, FramePointerMode useFramePointer)
     : base(dfyroot, appLabel)
 {
     this.useFramePointer = useFramePointer;
     this.abstractId = new AbstractId(this.GetType().Name, this.getVersion() + version, dfyroot.ToString(), concrete: useFramePointer.ToString());
     this.dafnyCCBuildExecutableVerb = new VSSolutionVerb(new SourcePath("tools\\DafnyCC\\DafnyCC.sln", SourcePath.SourceType.Tools));
 }
示例#2
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);
        }
        /// <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));
            }
        }
示例#4
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);
        }
        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)));
        }
示例#6
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));
            }
        }
示例#7
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)));
        }
示例#8
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 };
        }
示例#9
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 };
        }
示例#10
0
        public NmakeVerb(SourcePath makefile)
        {
            _makefile   = makefile;
            _abstractId = new AbstractId(this.GetType().Name, version, _makefile.ToString());

            //- Generate output path
            _outputPath = ".";
            int depth = _makefile.getDirPath().Split(@"\/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length;

            for (int i = 0; i < depth; i++)
            {
                _outputPath = Path.Combine(_outputPath, "..");
            }

            _outputPathSuffix = Path.Combine(BuildEngine.theEngine.getObjRoot(), _makefile.getDirPath());
            _outputPath       = Path.Combine(_outputPath, _outputPathSuffix);
            _customManifest   = new CustomManifestParser(makefile);
        }
示例#11
0
        public VSSolutionVerb(SourcePath solutionFile)
        {
            _solutionFile = solutionFile;
            _abstractId   = new AbstractId(this.GetType().Name, version, _solutionFile.ToString());

            //- Parse the solution file
            _solutionParser = new VSSolutionParser(_solutionFile);

            //- Generate output path
            _outputPath = ".";
            int depth = _solutionFile.getDirPath().Split(@"\/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length;

            for (int i = 0; i < depth; i++)
            {
                _outputPath = Path.Combine(_outputPath, "..");
            }

            _outputPathSuffix = Path.Combine(BuildEngine.theEngine.getObjRoot(), _solutionFile.getDirPath());
            _outputPath       = Path.Combine(_outputPath, _outputPathSuffix);
        }
示例#12
0
 public DafnyVerifyOneVerb(SourcePath dfysource)
 {
     this.dfysource  = dfysource;
     this.abstractId = new AbstractId(this.GetType().Name, version, dfysource.ToString());
 }
        public IroncladAppVerb(SourcePath dfyroot, TARGET target, DafnyCCVerb.FramePointerMode framePointerMode, VerificationRequest verificationRequest)
        {
            this.dfyroot = dfyroot;

            // TODO this is the only #define we support just yet, so I'm stuffing it in here.
            // We'll need to plumb more carefully when we want to add x64.
            if (dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last().Equals("AppLoader"))
            {
                this.poundDefines = new PoundDefines(new string[] { "AppLoader" });
            }
            else
            {
                this.poundDefines = PoundDefines.empty();
            }

            this.verificationRequest = verificationRequest;
            this.abstractId          = new AbstractId(
                this.GetType().Name,
                version,
                dfyroot.ToString(),
                this.poundDefines,
                concrete: string.Format(
                    "{0},{1},{2}",
                    target,
                    framePointerMode.ToString(),
                    verificationRequest.ToString()));
            this.appLabel      = dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last();
            this.dafnyspecVerb = new DafnySpecVerb(dfyroot, this.appLabel);
            this.dafnyccVerb   = new DafnyCCVerb(dfyroot, this.appLabel, framePointerMode);

            bool isLoader = dfyroot.getRelativePath().Equals(BootableAppVerb.LOADER_DFY);

            // NB we keep dafnyccVerb as the lowest-priority context, so that our hand-written
            // beat impls will override its output.
            IContextGeneratingVerb contextWithDafny = new ConcatContextVerb(
                BuildEngine.theEngine.getVerveContextVerb(this.poundDefines),
                new VerbOutputsContextVerb(this.dafnyspecVerb, false),
                new VerbOutputsContextVerb(this.dafnyccVerb, true),
                this.poundDefines);

            this.stitcherVerb = new EntryStitcherVerb(contextWithDafny, this.appLabel);
            IContextGeneratingVerb contextWithDafnyAndEntry = new ConcatContextVerb(
                new VerbOutputsContextVerb(this.stitcherVerb, false),
                contextWithDafny,
                this.poundDefines);

            BuildObject       entryImpObj = this.stitcherVerb.getEntryImpOutput();
            BoogieAsmLinkVerb entryVerb   = new BoogieAsmLinkVerb(contextWithDafnyAndEntry, entryImpObj);

            if (target == TARGET.BARE_METAL)
            {
                MasmVerb masmVerb = new MasmVerb(entryVerb);
                this.linkerVerb = new LinkerVerb(masmVerb, isLoader);
            }
            else if (target == TARGET.WINDOWS)
            {     // Rewrite the asm that comes out of entryVerb before linking it
                AsmRewriterVerb rewriter = new AsmRewriterVerb(entryVerb);
                MasmVerb        masmVerb = new MasmVerb(rewriter);
                this.linkerVerb = new WinLinkerVerb(masmVerb, isLoader);
            }

            BoogieAsmVerificationObligationListVerb bavolVerb =
                new BoogieAsmVerificationObligationListVerb(contextWithDafnyAndEntry, entryImpObj, verificationRequest);

            this.verifyResultsVerb = new VerificationResultSummaryVerb(bavolVerb);

            this.srcObject = this.linkerVerb.getUntrustedExe();
            if (verificationRequest.isComplete())
            {
                this.exeObject    = dfyroot.makeOutputObject(TRUSTED_EXE_EXTN);
                this.outputObject = this.exeObject;
            }
            else
            {
                this.exeObject    = this.srcObject;
                this.outputObject = dfyroot.makeVirtualObject(UNVERIFIED_SENTINEL_EXTENSION);
            }
        }
示例#14
0
 public DafnySpecVerb(SourcePath dfyroot, string appLabel)
     : base(dfyroot, appLabel)
 {
     this.abstractId = new AbstractId(this.GetType().Name, this.getVersion() + version, dfyroot.ToString());
     this.dafnySpecBuildExecutableVerb = new VSSolutionVerb(new SourcePath("tools\\DafnySpec\\DafnySpec.sln", SourcePath.SourceType.Tools));
 }
示例#15
0
 public DafnySpecVerb(SourcePath dfyroot, string appLabel)
     : base(dfyroot, appLabel)
 {
     abstractId = new AbstractId(this.GetType().Name, getVersion() + version, dfyroot.ToString());
 }
示例#16
0
        public IroncladAppVerb(SourcePath dfyroot, TARGET target, DafnyCCVerb.FramePointerMode framePointerMode, VerificationRequest verificationRequest)
        {
            this.dfyroot = dfyroot;

            // TODO this is the only #define we support just yet, so I'm stuffing it in here.
            // We'll need to plumb more carefully when we want to add x64.
            if (dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last().Equals("AppLoader"))
            {
                this.poundDefines = new PoundDefines(new string[] { "AppLoader" });
            }
            else
            {
                this.poundDefines = PoundDefines.empty();
            }

            this.verificationRequest = verificationRequest;
            this.abstractId = new AbstractId(
                this.GetType().Name,
                version,
                dfyroot.ToString(),
                this.poundDefines,
                concrete: string.Format(
                    "{0},{1},{2}",
                    target,
                    framePointerMode.ToString(),
                    verificationRequest.ToString()));
            this.appLabel = dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last();
            this.dafnyspecVerb = new DafnySpecVerb(dfyroot, this.appLabel);
            this.dafnyccVerb = new DafnyCCVerb(dfyroot, this.appLabel, framePointerMode);

            bool isLoader = dfyroot.getRelativePath().Equals(BootableAppVerb.LOADER_DFY);

            // NB we keep dafnyccVerb as the lowest-priority context, so that our hand-written
            // beat impls will override its output.
            IContextGeneratingVerb contextWithDafny = new ConcatContextVerb(
                BuildEngine.theEngine.getVerveContextVerb(this.poundDefines),
                new VerbOutputsContextVerb(this.dafnyspecVerb, false),
                new VerbOutputsContextVerb(this.dafnyccVerb, true),
                this.poundDefines);
            this.stitcherVerb = new EntryStitcherVerb(contextWithDafny, this.appLabel);
            IContextGeneratingVerb contextWithDafnyAndEntry = new ConcatContextVerb(
                new VerbOutputsContextVerb(this.stitcherVerb, false),
                contextWithDafny,
                this.poundDefines);

            BuildObject entryImpObj = this.stitcherVerb.getEntryImpOutput();
            BoogieAsmLinkVerb entryVerb = new BoogieAsmLinkVerb(contextWithDafnyAndEntry, entryImpObj);
            if (target == TARGET.BARE_METAL)
            {
                MasmVerb masmVerb = new MasmVerb(entryVerb);
                this.linkerVerb = new LinkerVerb(masmVerb, isLoader);
            }
            else if (target == TARGET.WINDOWS)
            {     // Rewrite the asm that comes out of entryVerb before linking it
                AsmRewriterVerb rewriter = new AsmRewriterVerb(entryVerb);
                MasmVerb masmVerb = new MasmVerb(rewriter);
                this.linkerVerb = new WinLinkerVerb(masmVerb, isLoader);
            }

            BoogieAsmVerificationObligationListVerb bavolVerb =
                new BoogieAsmVerificationObligationListVerb(contextWithDafnyAndEntry, entryImpObj, verificationRequest);

            this.verifyResultsVerb = new VerificationResultSummaryVerb(bavolVerb);

            this.srcObject = this.linkerVerb.getUntrustedExe();
            if (verificationRequest.isComplete())
            {
                this.exeObject = dfyroot.makeOutputObject(TRUSTED_EXE_EXTN);
                this.outputObject = this.exeObject;
            }
            else
            {
                this.exeObject = this.srcObject;
                this.outputObject = dfyroot.makeVirtualObject(UNVERIFIED_SENTINEL_EXTENSION);
            }
        }
示例#17
0
 public DafnyCCVerb(SourcePath dfyroot, string appLabel, FramePointerMode useFramePointer)
     : base(dfyroot, appLabel)
 {
     this.useFramePointer            = useFramePointer;
     this.abstractId                 = new AbstractId(this.GetType().Name, this.getVersion() + version, dfyroot.ToString(), concrete: useFramePointer.ToString());
     this.dafnyCCBuildExecutableVerb = new VSSolutionVerb(new SourcePath("tools\\DafnyCC\\DafnyCC.sln", SourcePath.SourceType.Tools));
 }
示例#18
0
 public DafnyVerifyOneVerb(SourcePath dfysource)
 {
     this.dfysource = dfysource;
     this.abstractId = new AbstractId(this.GetType().Name, version, dfysource.ToString());                
 }
示例#19
0
 public DafnyVerifyTreeVerb(SourcePath root)
 {
     this.displayRoot = root;
     this.obligations = root.makeOutputObject(DFYTREE_EXTN + VerificationObligationList.VOL_EXTN);
     this.abstractId = new AbstractId(this.GetType().Name, version, root.ToString());
 }
示例#20
0
 public DafnySpecVerb(SourcePath dfyroot, string appLabel)
     : base(dfyroot, appLabel)
 {
     this.abstractId = new AbstractId(this.GetType().Name, this.getVersion() + version, dfyroot.ToString());
     this.dafnySpecBuildExecutableVerb = new VSSolutionVerb(new SourcePath("tools\\DafnySpec\\DafnySpec.sln", SourcePath.SourceType.Tools));
 }
示例#21
0
 public DafnyVerifyTreeVerb(SourcePath root)
 {
     this.displayRoot = root;
     obligations      = root.makeOutputObject(DFYTREE_EXTN + VerificationObligationList.VOL_EXTN);
     abstractId       = new AbstractId(this.GetType().Name, version, root.ToString());
 }
示例#22
0
 public DafnyCCVerb(SourcePath dfyroot, string appLabel, FramePointerMode useFramePointer)
     : base(dfyroot, appLabel)
 {
     this.useFramePointer = useFramePointer;
     abstractId           = new AbstractId(this.GetType().Name, getVersion() + version, dfyroot.ToString(), concrete: useFramePointer.ToString());
 }
示例#23
0
 public override AbstractId getAbstractIdentifier()
 {
     return(new AbstractId(this.GetType().Name, version, genericStitch.ToString(), concrete: appLabel));
 }