示例#1
0
        private List <CardHolder> GetCardHolders(PrintModes pm)
        {
            int failcount       = 0;
            int failmax         = 10;
            List <CardHolder> i = null;

tryagain:
            try
            {
                var op = new MinimalOptions()
                {
                    Expansion = newestExpansionToolStripMenuItem.Checked,
                    Flavour   = flavourTextToolStripMenuItem.Checked,
                    Rarity    = newestExpansionRarityToolStripMenuItem.Checked
                };

                i = EnteredCards.Items.Cast <ListViewItem>().Select(s => s.Tag).Cast <CardHolder>().ToList();
                i.AsParallel().ForAll(s => s.GetAndSetImages(pm, op));
                return(i);
            }
            catch (Exception ex)
            {
                if (failcount < failmax)
                {
                    failcount++;
                    Thread.Sleep(100);
                    goto tryagain;
                }
                MessageBox.Show("an error has occured. try again:" + ex);
            }
            return(null);
        }
示例#2
0
文件: Workbook.cs 项目: njmube/lazaro
        public void Print(PrintModes printMode)
        {
            PrintModes FinalPrintMode = printMode;

            if (FinalPrintMode == PrintModes.Automatic)
            {
                if (ExternalPrograms.MsOffice.IsExcelInstalled())
                {
                    FinalPrintMode = PrintModes.MsOffice;
                }
                else if (ExternalPrograms.OpenOffice.IsCalcInstalled())
                {
                    FinalPrintMode = PrintModes.OpenOffice;
                }
            }

            switch (FinalPrintMode)
            {
            case PrintModes.OpenOffice:
                string TempCalcFileName = Lfx.Environment.Folders.TemporaryFolder + System.IO.Path.GetFileName(System.IO.Path.GetRandomFileName()) + ".xml";
                this.SaveTo(TempCalcFileName, SaveFormats.Excel);
                ExternalPrograms.OpenOffice.PrintWithCalc(TempCalcFileName);
                break;

            case PrintModes.MsOffice:
                string TempExcelFileName = Lfx.Environment.Folders.TemporaryFolder + System.IO.Path.GetFileName(System.IO.Path.GetRandomFileName()) + ".xml";
                this.SaveTo(TempExcelFileName, SaveFormats.Excel);
                ExternalPrograms.MsOffice.PrintWithExcel(TempExcelFileName);
                break;

            default:
                throw new NotImplementedException();
            }
        }
示例#3
0
                public void Print(PrintModes printMode)
                {
                        PrintModes FinalPrintMode = printMode;
                        if (FinalPrintMode == PrintModes.Automatic) {
                                if (ExternalPrograms.MsOffice.IsExcelInstalled())
                                        FinalPrintMode = PrintModes.MsOffice;
                                else if (ExternalPrograms.OpenOffice.IsCalcInstalled())
                                        FinalPrintMode = PrintModes.OpenOffice;
                        }

                        switch (FinalPrintMode) {
                                case PrintModes.OpenOffice:
                                        string TempCalcFileName = Lfx.Environment.Folders.TemporaryFolder + System.IO.Path.GetFileName(System.IO.Path.GetRandomFileName()) + ".xml";
                                        this.SaveTo(TempCalcFileName, SaveFormats.ExcelXml);
                                        ExternalPrograms.OpenOffice.PrintWithCalc(TempCalcFileName);
                                        break;
                                case PrintModes.MsOffice:
                                        string TempExcelFileName = Lfx.Environment.Folders.TemporaryFolder + System.IO.Path.GetFileName(System.IO.Path.GetRandomFileName()) + ".xml";
                                        this.SaveTo(TempExcelFileName, SaveFormats.ExcelXml);
                                        ExternalPrograms.MsOffice.PrintWithExcel(TempExcelFileName);
                                        break;
                                default:
                                        throw new NotImplementedException();
                        }
                }
示例#4
0
        private void SetImage(PrintModes pm)
        {
            var fn = GetImageFilename(C, pm);

            using (var i = (Bitmap)Image.FromFile(fn))
            {
                CardImage = new Bitmap(i);
            }
        }
示例#5
0
        private static string GetImageFilename(Card c, PrintModes pm)
        {
            switch (pm)
            {
            case PrintModes.Minimal:
                return(Path.Combine(ImageFolder, c.ID.ToString() + ".min.jpg"));

            case PrintModes.BlackAndWhite:
                return(Path.Combine(ImageFolder, c.ID.ToString() + ".bw.jpg"));

            case PrintModes.Colour:
                return(Path.Combine(ImageFolder, c.ID.ToString() + ".col.jpg"));
            }

            return(null);
        }
示例#6
0
        public void GetAndSetImages(PrintModes pm, MinimalOptions mo)
        {
            //download first if necessary
            //colour
            var pathColour = GetImageFilename(C, PrintModes.Colour);

            if (File.Exists(pathColour) == false)
            {
                NetExtras.DownloadFile(C.ImgURL, pathColour);
            }

            //black and white
            var pathBw = GetImageFilename(C, PrintModes.BlackAndWhite);

            if (File.Exists(pathBw) == false)
            {
                Bitmap bw;
                using (var i = (Bitmap)Image.FromFile(pathColour))
                {
                    bw = BitmapExtras.ApplyGrayscale(new Bitmap(i));
                }

                bw.Save(pathBw);
            }

            //minimal - always generate in case options have changed - todo - do properly
            var minpath = GetImageFilename(C, PrintModes.Minimal);

            if (File.Exists(minpath))
            {
                File.Delete(minpath);
            }

            var m   = MinimalCardControl.Show(C, mo);
            var min = new Bitmap(m.Width, m.Height);

            m.DrawToBitmap(min, new Rectangle(0, 0, m.Width, m.Height));
            min.Save(minpath);

            SetImage(pm);
        }
示例#7
0
        protected override bool ParseOption(string name, Bpl.CommandLineOptionEngine.CommandLineParseState ps)
        {
            var args = ps.args; // convenient synonym

            switch (name)
            {
            case "dprelude":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrelude = args[ps.i];
                }
                return(true);

            case "dprint":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintFile = args[ps.i];
                }
                return(true);

            case "printMode":
                if (ps.ConfirmArgumentCount(1))
                {
                    if (args[ps.i].Equals("Everything"))
                    {
                        PrintMode = PrintModes.Everything;
                    }
                    else if (args[ps.i].Equals("NoIncludes"))
                    {
                        PrintMode = PrintModes.NoIncludes;
                    }
                    else if (args[ps.i].Equals("NoGhost"))
                    {
                        PrintMode = PrintModes.NoGhost;
                    }
                    else if (args[ps.i].Equals("DllEmbed"))
                    {
                        PrintMode = PrintModes.DllEmbed;
                    }
                    else
                    {
                        throw new Exception("Invalid value for printMode");
                    }
                }
                return(true);

            case "rprint":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintResolvedFile = args[ps.i];
                }
                return(true);

            case "view":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintExportedViews = args[ps.i].Split(',').ToList();
                }
                return(true);

            case "compile": {
                int compile = 0;
                if (ps.GetNumericArgument(ref compile, 5))
                {
                    // convert option to two booleans
                    Compile         = compile != 0;
                    ForceCompile    = compile == 2 || compile == 4;
                    RunAfterCompile = compile == 3 || compile == 4;
                }
                return(true);
            }

            case "compileTarget":
                if (ps.ConfirmArgumentCount(1))
                {
                    if (args[ps.i].Equals("cs"))
                    {
                        CompileTarget = CompilationTarget.Csharp;
                    }
                    else if (args[ps.i].Equals("js"))
                    {
                        CompileTarget = CompilationTarget.JavaScript;
                    }
                    else if (args[ps.i].Equals("go"))
                    {
                        CompileTarget = CompilationTarget.Go;
                    }
                    else if (args[ps.i].Equals("java"))
                    {
                        CompileTarget = CompilationTarget.Java;
                    }
                    else if (args[ps.i].Equals("php"))
                    {
                        CompileTarget = CompilationTarget.Php;
                    }
                    else
                    {
                        throw new Exception("Invalid value for compileTarget");
                    }
                }
                return(true);

            case "compileVerbose": {
                int verbosity = 0;
                if (ps.GetNumericArgument(ref verbosity, 2))
                {
                    CompileVerbose = verbosity == 1;
                }
                return(true);
            }

            case "dafnyVerify":
            {
                int verify = 0;
                if (ps.GetNumericArgument(ref verify, 2))
                {
                    DafnyVerify = verify != 0; // convert to boolean
                }
                return(true);
            }

            case "spillTargetCode": {
                int spill = 0;
                if (ps.GetNumericArgument(ref spill, 4))
                {
                    SpillTargetCode = spill;
                }
                return(true);
            }

            case "out": {
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintCompiledFile = args[ps.i];
                }
                return(true);
            }

            case "coverage": {
                if (ps.ConfirmArgumentCount(1))
                {
                    CoverageLegendFile = args[ps.i];
                }
                return(true);
            }

            case "dafnycc":
                Dafnycc   = true;
                Induction = 0;
                Compile   = false;
                UseAbstractInterpretation = false; // /noinfer
                return(true);

            case "noCheating": {
                int cheat = 0; // 0 is default, allows cheating
                if (ps.GetNumericArgument(ref cheat, 2))
                {
                    DisallowSoundnessCheating = cheat == 1;
                }
                return(true);
            }

            case "pmtrace":
                MatchCompilerDebug = true;
                return(true);

            case "titrace":
                TypeInferenceDebug = true;
                return(true);

            case "induction":
                ps.GetNumericArgument(ref Induction, 4);
                return(true);

            case "inductionHeuristic":
                ps.GetNumericArgument(ref InductionHeuristic, 7);
                return(true);

            case "noIncludes":
                DisallowIncludes = true;
                return(true);

            case "noExterns":
                DisallowExterns = true;
                return(true);

            case "noNLarith":
                DisableNLarith = true;
                return(true);

            case "arith": {
                int a = 0;
                if (ps.GetNumericArgument(ref a, 11))
                {
                    ArithMode = a;
                }
                return(true);
            }

            case "autoReqPrint":
                if (ps.ConfirmArgumentCount(1))
                {
                    AutoReqPrintFile = args[ps.i];
                }
                return(true);

            case "noAutoReq":
                ignoreAutoReq = true;
                return(true);

            case "allowGlobals":
                AllowGlobals = true;
                return(true);

            case "stats":
                PrintStats = true;
                return(true);

            case "funcCallGraph":
                PrintFunctionCallGraph = true;
                return(true);

            case "warnShadowing":
                WarnShadowing = true;
                return(true);

            case "verifyAllModules":
                VerifyAllModules = true;
                return(true);

            case "separateModuleOutput":
                SeparateModuleOutput = true;
                return(true);

            case "deprecation": {
                int d = 1;
                if (ps.GetNumericArgument(ref d, 3))
                {
                    DeprecationNoise = d;
                }
                return(true);
            }

            case "countVerificationErrors": {
                int countErrors = 1; // defaults to reporting verification errors
                if (ps.GetNumericArgument(ref countErrors, 2))
                {
                    CountVerificationErrors = countErrors == 1;
                }
                return(true);
            }

            case "printTooltips":
                PrintTooltips = true;
                return(true);

            case "autoTriggers": {
                int autoTriggers = 0;
                if (ps.GetNumericArgument(ref autoTriggers, 2))
                {
                    AutoTriggers = autoTriggers == 1;
                }
                return(true);
            }

            case "rewriteFocalPredicates": {
                int rewriteFocalPredicates = 0;
                if (ps.GetNumericArgument(ref rewriteFocalPredicates, 2))
                {
                    RewriteFocalPredicates = rewriteFocalPredicates == 1;
                }
                return(true);
            }

            case "optimize": {
                Optimize = true;
                return(true);
            }

            case "allocated": {
                ps.GetNumericArgument(ref Allocated, 5);
                return(true);
            }

            case "noIronDafny": {
                IronDafny = false;
                return(true);
            }

            case "ironDafny": {
                IronDafny = true;
                return(true);
            }

            case "optimizeResolution": {
                int d = 2;
                if (ps.GetNumericArgument(ref d, 3))
                {
                    OptimizeResolution = d;
                }
                return(true);
            }

            case "definiteAssignment": {
                int da = 0;
                if (ps.GetNumericArgument(ref da, 4))
                {
                    DefiniteAssignmentLevel = da;
                }
                return(true);
            }

            case "useRuntimeLib": {
                UseRuntimeLib = true;
                return(true);
            }

            case "disableScopes": {
                DisableScopes = true;
                return(true);
            }

            case "printIncludes":
                if (ps.ConfirmArgumentCount(1))
                {
                    if (args[ps.i].Equals("None"))
                    {
                        PrintIncludesMode = IncludesModes.None;
                    }
                    else if (args[ps.i].Equals("Immediate"))
                    {
                        PrintIncludesMode = IncludesModes.Immediate;
                    }
                    else if (args[ps.i].Equals("Transitive"))
                    {
                        PrintIncludesMode = IncludesModes.Transitive;
                    }
                    else
                    {
                        throw new Exception("Invalid value for includesMode");
                    }

                    if (PrintIncludesMode == IncludesModes.Immediate || PrintIncludesMode == IncludesModes.Transitive)
                    {
                        Compile      = false;
                        DontShowLogo = true;
                        DafnyVerify  = false;
                    }
                }
                return(true);

            default:
                break;
            }
            // not a Dafny-specific option, so defer to superclass
            return(base.ParseOption(name, ps));
        }
示例#8
0
        protected override bool ParseOption(string name, Bpl.CommandLineOptionEngine.CommandLineParseState ps)
        {
            var args = ps.args; // convenient synonym

            switch (name)
            {
            case "dprelude":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrelude = args[ps.i];
                }
                return(true);

            case "dprint":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintFile = args[ps.i];
                }
                return(true);

            case "printMode":
                if (ps.ConfirmArgumentCount(1))
                {
                    if (args[ps.i].Equals("Everything"))
                    {
                        PrintMode = PrintModes.Everything;
                    }
                    else if (args[ps.i].Equals("NoIncludes"))
                    {
                        PrintMode = PrintModes.NoIncludes;
                    }
                    else if (args[ps.i].Equals("NoGhost"))
                    {
                        PrintMode = PrintModes.NoGhost;
                    }
                    else if (args[ps.i].Equals("DllEmbed"))
                    {
                        PrintMode = PrintModes.DllEmbed;
                    }
                    else
                    {
                        throw new Exception("Invalid value for printMode");
                    }
                }
                return(true);

            case "rprint":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintResolvedFile = args[ps.i];
                }
                return(true);

            case "view":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintExportedViews = args[ps.i].Split(',').ToList();
                }
                return(true);

            case "compile": {
                int compile = 0;
                if (ps.GetNumericArgument(ref compile, 4))
                {
                    // convert option to two booleans
                    Compile         = compile != 0;
                    ForceCompile    = compile == 2;
                    RunAfterCompile = compile == 3;
                }
                return(true);
            }

            case "dafnyVerify":
            {
                int verify = 0;
                if (ps.GetNumericArgument(ref verify, 2))
                {
                    DafnyVerify = verify != 0; // convert to boolean
                }
                return(true);
            }

            case "spillTargetCode": {
                int spill = 0;
                if (ps.GetNumericArgument(ref spill, 2))
                {
                    SpillTargetCode = spill != 0; // convert to a boolean
                }
                return(true);
            }

            case "out": {
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintCompiledFile = args[ps.i];
                }
                return(true);
            }

            case "dafnycc":
                Dafnycc   = true;
                Induction = 0;
                Compile   = false;
                UseAbstractInterpretation = false; // /noinfer
                return(true);

            case "noCheating": {
                int cheat = 0; // 0 is default, allows cheating
                if (ps.GetNumericArgument(ref cheat, 2))
                {
                    DisallowSoundnessCheating = cheat == 1;
                }
                return(true);
            }

            case "induction":
                ps.GetNumericArgument(ref Induction, 4);
                return(true);

            case "inductionHeuristic":
                ps.GetNumericArgument(ref InductionHeuristic, 7);
                return(true);

            case "noIncludes":
                DisallowIncludes = true;
                return(true);

            case "noNLarith":
                DisableNLarith = true;
                this.AddZ3Option("smt.arith.nl=false");
                return(true);

            case "autoReqPrint":
                if (ps.ConfirmArgumentCount(1))
                {
                    AutoReqPrintFile = args[ps.i];
                }
                return(true);

            case "noAutoReq":
                ignoreAutoReq = true;
                return(true);

            case "allowGlobals":
                AllowGlobals = true;
                return(true);

            case "stats":
                PrintStats = true;
                return(true);

            case "funcCallGraph":
                PrintFunctionCallGraph = true;
                return(true);

            case "warnShadowing":
                WarnShadowing = true;
                return(true);

            case "verifyAllModules":
                VerifyAllModules = true;
                return(true);

            case "separateModuleOutput":
                SeparateModuleOutput = true;
                return(true);

            case "deprecation": {
                int d = 1;
                if (ps.GetNumericArgument(ref d, 3))
                {
                    DeprecationNoise = d;
                }
                return(true);
            }

            case "allocatedAll": {
                Allocated = 5;
                return(true);
            }

            case "allocated": {
                ps.GetNumericArgument(ref Allocated, 6);
                if (Allocated == 3 || Allocated == 4)
                {
                    Allocated = 1;
                    throw new Exception("/allocated:3 and /allocated:4 are not yet implemented");
                }
                return(true);
            }

            case "countVerificationErrors": {
                int countErrors = 1; // defaults to reporting verification errors
                if (ps.GetNumericArgument(ref countErrors, 2))
                {
                    CountVerificationErrors = countErrors == 1;
                }
                return(true);
            }

            case "printTooltips":
                PrintTooltips = true;
                return(true);

            case "autoTriggers": {
                int autoTriggers = 0;
                if (ps.GetNumericArgument(ref autoTriggers, 2))
                {
                    AutoTriggers = autoTriggers == 1;
                }
                return(true);
            }

            case "rewriteFocalPredicates": {
                int rewriteFocalPredicates = 0;
                if (ps.GetNumericArgument(ref rewriteFocalPredicates, 2))
                {
                    RewriteFocalPredicates = rewriteFocalPredicates == 1;
                }
                return(true);
            }

            case "optimize": {
                Optimize = true;
                return(true);
            }

            case "kremlin": {
                Kremlin = true;
                return(true);
            }

            case "noIronDafny": {
                IronDafny = false;
                return(true);
            }

            case "ironDafny": {
                IronDafny = true;
                return(true);
            }

            case "optimizeResolution": {
                int d = 2;
                if (ps.GetNumericArgument(ref d, 3))
                {
                    OptimizeResolution = d;
                }
                return(true);
            }

            case "useRuntimeLib": {
                UseRuntimeLib = true;
                return(true);
            }

            case "disableScopes": {
                DisableScopes = true;
                return(true);
            }

            case "printIncludes":
                if (ps.ConfirmArgumentCount(1))
                {
                    if (args[ps.i].Equals("None"))
                    {
                        PrintIncludesMode = IncludesModes.None;
                    }
                    else if (args[ps.i].Equals("Immediate"))
                    {
                        PrintIncludesMode = IncludesModes.Immediate;
                    }
                    else if (args[ps.i].Equals("Transitive"))
                    {
                        PrintIncludesMode = IncludesModes.Transitive;
                    }
                    else
                    {
                        throw new Exception("Invalid value for includesMode");
                    }

                    if (PrintIncludesMode == IncludesModes.Immediate || PrintIncludesMode == IncludesModes.Transitive)
                    {
                        Compile      = false;
                        DontShowLogo = true;
                        DafnyVerify  = false;
                    }
                }
                return(true);

            default:
                break;
            }
            // not a Dafny-specific option, so defer to superclass
            return(base.ParseOption(name, ps));
        }
示例#9
0
    protected override bool ParseOption(string name, Bpl.CommandLineOptionEngine.CommandLineParseState ps) {
      var args = ps.args;  // convenient synonym

      switch (name) {
        case "dprelude":
          if (ps.ConfirmArgumentCount(1)) {
            DafnyPrelude = args[ps.i];
          }
          return true;

        case "dprint":
          if (ps.ConfirmArgumentCount(1)) {
            DafnyPrintFile = args[ps.i];
          }
          return true;

        case "printMode":
          if (ps.ConfirmArgumentCount(1)) {
            if (args[ps.i].Equals("Everything")) {
              PrintMode = PrintModes.Everything;
            }
            else if (args[ps.i].Equals("NoIncludes"))
            {
                PrintMode = PrintModes.NoIncludes;
            }
            else if (args[ps.i].Equals("NoGhost"))
            {
                PrintMode = PrintModes.NoGhost;
            }
            else
            {
                throw new Exception("Invalid value for printMode");
            }
          }
          return true;

        case "rprint":
          if (ps.ConfirmArgumentCount(1)) {
            DafnyPrintResolvedFile = args[ps.i];
          }
          return true;
        case "view":
          if (ps.ConfirmArgumentCount(1)) {
            DafnyPrintExportedViews = args[ps.i].Split(',').ToList();
          }
          return true;

        case "compile": {
            int compile = 0;
            if (ps.GetNumericArgument(ref compile, 4)) {
              // convert option to two booleans
              Compile = compile != 0;
              ForceCompile = compile == 2;
              RunAfterCompile = compile == 3;
            }
            return true;
          }

        case "dafnyVerify":
            {
                int verify = 0;
                if (ps.GetNumericArgument(ref verify, 2)) {
                    DafnyVerify = verify != 0; // convert to boolean
                }
                return true;
            }

        case "spillTargetCode": {
            int spill = 0;
            if (ps.GetNumericArgument(ref spill, 2)) {
              SpillTargetCode = spill != 0;  // convert to a boolean
            }
            return true;
          }
        case "out": {
            if (ps.ConfirmArgumentCount(1)) {
              DafnyPrintCompiledFile = args[ps.i];
            }
            return true;
          }

        case "dafnycc":
          Dafnycc = true;
          Induction = 0;
          Compile = false;
          UseAbstractInterpretation = false; // /noinfer
          return true;

        case "noCheating": {
            int cheat = 0; // 0 is default, allows cheating
            if (ps.GetNumericArgument(ref cheat, 2)) {
              DisallowSoundnessCheating = cheat == 1;
            }
            return true;
          }

        case "induction":
          ps.GetNumericArgument(ref Induction, 4);
          return true;

        case "inductionHeuristic":
          ps.GetNumericArgument(ref InductionHeuristic, 7);
          return true;

        case "noIncludes":
          DisallowIncludes = true;
          return true;

        case "noNLarith":
          DisableNLarith = true;
          this.AddZ3Option("smt.arith.nl=false");
          return true;

        case "autoReqPrint":
          if (ps.ConfirmArgumentCount(1)) {
              AutoReqPrintFile = args[ps.i];
          }
          return true;

        case "noAutoReq":
          ignoreAutoReq = true;
          return true;

        case "allowGlobals":
          AllowGlobals = true;
          return true;
        
        case "stats":
          PrintStats = true;
          return true;

        case "funcCallGraph":
          PrintFunctionCallGraph = true;
          return true;

        case "warnShadowing":
          WarnShadowing = true;
          return true;

        case "countVerificationErrors": {
          int countErrors = 1; // defaults to reporting verification errors
          if (ps.GetNumericArgument(ref countErrors, 2)) {
            CountVerificationErrors = countErrors == 1;
          }
          return true;
        }

        case "printTooltips":
          PrintTooltips = true;
          return true;

        case "autoTriggers": {
            int autoTriggers = 0;
            if (ps.GetNumericArgument(ref autoTriggers, 2)) {
              AutoTriggers = autoTriggers == 1;
            }
            return true;
          }

        case "rewriteFocalPredicates": {
            int rewriteFocalPredicates = 0;
            if (ps.GetNumericArgument(ref rewriteFocalPredicates, 2)) {
              RewriteFocalPredicates = rewriteFocalPredicates == 1;
            }
            return true;
          }

        case "optimize": {
            Optimize = true;
            return true;
        }

        case "noIronDafny": {
            IronDafny = false;
            return true;
        }

        case "ironDafny": {
            IronDafny = true;
            return true;
        }

        default:
          break;
      }
      // not a Dafny-specific option, so defer to superclass
      return base.ParseOption(name, ps);
    }
示例#10
0
        protected override bool ParseOption(string name, Bpl.CommandLineOptionEngine.CommandLineParseState ps)
        {
            var args = ps.args; // convenient synonym

            switch (name)
            {
            case "dprelude":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrelude = args[ps.i];
                }
                return(true);

            case "dprint":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintFile = args[ps.i];
                }
                return(true);

            case "printMode":
                if (ps.ConfirmArgumentCount(1))
                {
                    if (args[ps.i].Equals("Everything"))
                    {
                        PrintMode = PrintModes.Everything;
                    }
                    else if (args[ps.i].Equals("NoIncludes"))
                    {
                        PrintMode = PrintModes.NoIncludes;
                    }
                    else if (args[ps.i].Equals("NoGhost"))
                    {
                        PrintMode = PrintModes.NoGhost;
                    }
                    else
                    {
                        throw new Exception("Invalid value for printMode");
                    }
                }
                return(true);

            case "rprint":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintResolvedFile = args[ps.i];
                }
                return(true);

            case "view":
                if (ps.ConfirmArgumentCount(1))
                {
                    DafnyPrintExportedViews = args[ps.i].Split(',').ToList();
                }
                return(true);

            case "compile": {
                int compile = 0;
                if (ps.GetNumericArgument(ref compile, 4))
                {
                    // convert option to two booleans
                    Compile         = compile != 0;
                    ForceCompile    = compile == 2;
                    RunAfterCompile = compile == 3;
                }
                return(true);
            }

            case "dafnyVerify":
            {
                int verify = 0;
                if (ps.GetNumericArgument(ref verify, 2))
                {
                    DafnyVerify = verify != 0; // convert to boolean
                }
                return(true);
            }

            case "spillTargetCode": {
                int spill = 0;
                if (ps.GetNumericArgument(ref spill, 2))
                {
                    SpillTargetCode = spill != 0; // convert to a boolean
                }
                return(true);
            }

            case "dafnycc":
                Dafnycc   = true;
                Induction = 0;
                Compile   = false;
                UseAbstractInterpretation = false; // /noinfer
                return(true);

            case "noCheating": {
                int cheat = 0; // 0 is default, allows cheating
                if (ps.GetNumericArgument(ref cheat, 2))
                {
                    DisallowSoundnessCheating = cheat == 1;
                }
                return(true);
            }

            case "induction":
                ps.GetNumericArgument(ref Induction, 4);
                return(true);

            case "inductionHeuristic":
                ps.GetNumericArgument(ref InductionHeuristic, 7);
                return(true);

            case "noIncludes":
                DisallowIncludes = true;
                return(true);

            case "noNLarith":
                DisableNLarith = true;
                this.AddZ3Option("smt.arith.nl=false");
                return(true);

            case "autoReqPrint":
                if (ps.ConfirmArgumentCount(1))
                {
                    AutoReqPrintFile = args[ps.i];
                }
                return(true);

            case "noAutoReq":
                ignoreAutoReq = true;
                return(true);

            case "allowGlobals":
                AllowGlobals = true;
                return(true);

            case "stats":
                PrintStats = true;
                return(true);

            case "funcCallGraph":
                PrintFunctionCallGraph = true;
                return(true);

            case "warnShadowing":
                WarnShadowing = true;
                return(true);

            case "countVerificationErrors": {
                int countErrors = 1; // defaults to reporting verification errors
                if (ps.GetNumericArgument(ref countErrors, 2))
                {
                    CountVerificationErrors = countErrors == 1;
                }
                return(true);
            }

            case "printTooltips":
                PrintTooltips = true;
                return(true);

            case "autoTriggers": {
                int autoTriggers = 0;
                if (ps.GetNumericArgument(ref autoTriggers, 2))
                {
                    AutoTriggers = autoTriggers == 1;
                }
                return(true);
            }

            case "rewriteFocalPredicates": {
                int rewriteFocalPredicates = 0;
                if (ps.GetNumericArgument(ref rewriteFocalPredicates, 2))
                {
                    RewriteFocalPredicates = rewriteFocalPredicates == 1;
                }
                return(true);
            }

            case "optimize": {
                Optimize = true;
                return(true);
            }

            case "noIronDafny": {
                IronDafny = false;
                return(true);
            }

            case "ironDafny": {
                IronDafny = true;
                return(true);
            }

            default:
                break;
            }
            // not a Dafny-specific option, so defer to superclass
            return(base.ParseOption(name, ps));
        }