Example #1
0
 public AbstractId(string verbName, int version, string abstractOnly, PoundDefines poundDefines = null, string concrete = null)
 {
     this.verbName = verbName;
     this.version = version + MASTER_VERSION;
     this.abstractOnly = abstractOnly;
     this.poundDefines = poundDefines == null ? PoundDefines.empty() : poundDefines;
     this.concrete = concrete;
 }
Example #2
0
        public AbstractId(string verb_name, int version, string abstract_only, PoundDefines poundDefines = null, string concrete = null)
        {
            this.verb_name     = verb_name;
            this.version       = version + MASTER_VERSION;
            this.abstract_only = abstract_only;
            this.poundDefines  = poundDefines == null?PoundDefines.empty() : poundDefines;

            this.concrete = concrete;
        }
Example #3
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));
 }
Example #4
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);
        }
Example #5
0
 public override bool Equals(object obj)
 {
     if (obj is PoundDefines)
     {
         PoundDefines other = (PoundDefines)obj;
         return(_descr == null && other._descr == null ||
                _descr != null && _descr.Equals(other._descr));
     }
     else
     {
         return(false);
     }
 }
        public override bool Equals(object obj)
        {
            PoundDefines other = obj as PoundDefines;

            if (other != null)
            {
                return((this.descr == null && other.descr == null) ||
                       (this.descr != null && this.descr.Equals(other.descr)));
            }
            else
            {
                return(false);
            }
        }
Example #7
0
 public ConcatContextVerb(IEnumerable<IContextGeneratingVerb> parents, PoundDefines poundDefines)
     : base("Cat(" + string.Join(",", parents) + ")", poundDefines)
 {
     this.parents = new List<IContextGeneratingVerb>(parents);
 }
Example #8
0
 public ConcatContextVerb(IContextGeneratingVerb parentA, IContextGeneratingVerb parentB, IContextGeneratingVerb parentC, PoundDefines poundDefines)
     : this(new IContextGeneratingVerb[] { parentA, parentB, parentC }, poundDefines)
 {
 }
 public StaticContextVerb(IIncludePathContext context, string nickname, PoundDefines poundDefines)
     : base(nickname, poundDefines)
 {
     this._context = context;
 }
Example #10
0
 public IContextGeneratingVerb getVerveContextVerb(PoundDefines poundDefines)
 {
     return new StaticContextVerb(this.getVervePathContext(), "Verve", poundDefines);
 }
 /// <param name="nickname">NB nickname will need to be unique over a run; it's used as the verb AbstractIdentifier, and
 /// hence hash identity in caches.</param>
 public ContextGeneratingVerb(string nickname, PoundDefines poundDefines)
 {
     this.nickname     = nickname;
     this.poundDefines = poundDefines;
 }
Example #12
0
 public StaticContextVerb(IIncludePathContext context, string nickname, PoundDefines poundDefines)
     : base(nickname, poundDefines)
 {
     this._context = context;
 }
Example #13
0
 internal static string toAppLabel(PoundDefines poundDefines)
 {
     return(poundDefines == null ? null : poundDefines.ToString());
 }
Example #14
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);
            }
        }
        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);
            }
        }
Example #16
0
 internal static string toAppLabel(PoundDefines poundDefines)
 {
     return poundDefines == null ? null : poundDefines.ToString();
 }
Example #17
0
        void parseArgs(string[] args)
        {
            this.args = args;
            argi      = 0;
            while (argi < args.Count())
            {
                string next = takeArg("option or verb");    // Should always succeed due to while condition.
                if (next.StartsWith("-"))
                {
                    if (next.Equals("--ironRoot"))
                    {
                        if (this.ironRoot != null)
                        {
                            usage("ironRoot set after use");
                        }

                        this.ironRoot = takeArg("value for ironRoot");
                    }
                    else if (next.Equals("-j") || next.Equals("--jobs"))
                    {
                        this.jobParallelism = Int32.Parse(takeArg("value for jobs"));
                    }
                    else if (next.Equals("--localcache"))
                    {
                        BuildEngine.theEngine.setLocalCache(takeArg("path for localcache"));
                    }
                    else if (next.ToLower().Equals("--cloudcache"))
                    {
                        this.useCloudCache = true;
                    }
                    else if (next.ToLower().Equals("--no-cloudcache"))
                    {
                        this.useCloudCache = false;
                    }
                    else if (next.Equals("--cloudexecution"))
                    {
                        this.useCloudExecution = true;
                    }
                    else if (next.ToLower().Equals("--verify"))
                    {
                        this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.Verify;
                    }
                    else if (next.ToLower().Equals("--no-verify"))
                    {
                        this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.NoVerify;
                    }
                    else if (next.ToLower().Equals("--no-symdiff"))
                    {
                        this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.NoSymDiff;
                    }
                    else if (next.ToLower().Equals("--verify-select"))
                    {
                        this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.SelectiveVerify;
                        this.verificationRequest.selectiveVerifyModuleNames.Add(takeArg("filename for selective-verify"));
                    }
                    else if (next.ToLower().Equals("--html"))
                    {
                        this.html_output = takeArg("filename for html report");
                    }
                    else if (next.ToLower().Equals("--windows"))
                    {
                        this.target_platform = IroncladAppVerb.TARGET.WINDOWS;
                    }
                    else if (next.ToLower().Equals("--useframepointer"))
                    {
                        this.useFramePointer = DafnyCCVerb.FramePointerMode.UseFramePointer;
                    }
                    else if (next.ToLower().Equals("--debug"))
                    {
                        this.releaseBuild = false;
                    }
                    else
                    {
                        usage("unrecognized option " + next);
                    }
                }
                else
                {
                    string verb   = next;
                    string target = takeArg("verb-target");

                    fixIronRoot();
                    if (verb.Equals("DafnyVerifyTree"))
                    {
                        verbs.Add(new VerificationResultSummaryVerb(new DafnyVerifyTreeVerb(conditionSourcePath(target))));
                    }
                    else if (verb.Equals("BatchDafny"))
                    {
                        if (!target.EndsWith(".batch"))
                        {
                            usage("Batching expects a .batch file containing a list of .dfy files");
                        }

                        verbs.Add(new VerificationResultSummaryVerb(new BatchVerifyVerb(conditionSourcePath(target), BatchVerifyVerb.BatchMode.DAFNY, this.verificationRequest, useFramePointer)));
                    }
                    else if (verb.Equals("BatchApps"))
                    {
                        if (!target.EndsWith(".batch"))
                        {
                            usage("Batching expects a .batch file containing a list of .dfy files");
                        }

                        verbs.Add(new VerificationResultSummaryVerb(new BatchVerifyVerb(conditionSourcePath(target), BatchVerifyVerb.BatchMode.APP, this.verificationRequest, useFramePointer)));
                    }
                    else if (verb.Equals("Beat"))
                    {
                        verbs.Add(new BeatVerb(BuildEngine.theEngine.getVerveContextVerb(PoundDefines.empty()), conditionSourcePath(target), appLabel: null));
                    }
                    else if (verb.Equals("Boogie"))
                    {
                        verbs.Add(new BoogieVerb(BuildEngine.theEngine.getVerveContextVerb(PoundDefines.empty()), conditionSourcePath(target), symdiff: this.verificationRequest.getSymDiffMode()));
                    }
                    else if (verb.Equals("IroncladApp"))
                    {
                        verbs.Add(new IroncladAppVerb(conditionSourcePath(target), target_platform, this.useFramePointer, this.verificationRequest));
                    }
                    else if (verb.Equals("IronfleetApp"))
                    {
                        verbs.Add(new IronfleetAppVerb(conditionSourcePath(target), this.verificationRequest, this.releaseBuild));
                    }
                    else if (verb.Equals("DafnyCompileOne"))
                    {
                        verbs.Add(new DafnyCompileOneVerb(conditionSourcePath(target)));
                    }
                    else if (verb.Equals("VSSolution"))
                    {
                        verbs.Add(new VSSolutionVerb(new SourcePath(target, SourcePath.SourceType.Tools)));
                    }
                    else if (verb.Equals("nmake"))
                    {
                        verbs.Add(new NmakeVerb(new SourcePath(target, SourcePath.SourceType.Tools)));
                    }
                    else if (verb.Equals("BootableApp"))
                    {
                        verbs.Add(new BootableAppVerb(conditionSourcePath(target), this.useFramePointer, this.verificationRequest));
                    }
                    else
                    {
                        usage("Unknown verb " + verb);
                    }
                }
            }

            fixIronRoot();
        }
 public ConcatContextVerb(IContextGeneratingVerb parentA, IContextGeneratingVerb parentB, IContextGeneratingVerb parentC, PoundDefines poundDefines)
     : this(new IContextGeneratingVerb[] { parentA, parentB, parentC }, poundDefines)
 {
 }
 public ConcatContextVerb(IEnumerable <IContextGeneratingVerb> parents, PoundDefines poundDefines)
     : base("Cat(" + String.Join(",", parents) + ")", poundDefines)
 {
     _parents = new List <IContextGeneratingVerb>(parents);
 }
Example #20
0
 public IContextGeneratingVerb getVerveContextVerb(PoundDefines poundDefines)
 {
     return(new StaticContextVerb(getVervePathContext(), "Verve", poundDefines));
 }
 /// <param name="nickname">NB nickname will need to be unique over a run; it's used as the verb AbstractIdentifier, and
 /// hence hash identity in caches.</param>
 public ContextGeneratingVerb(string nickname, PoundDefines poundDefines)
 {
     this.nickname = nickname;
     this.poundDefines = poundDefines;
 }