Example #1
0
 protected virtual bool ParseOption(string name, CommandLineOptionEngine.CommandLineParseState ps)
 {
     return false;
 }
Example #2
0
        protected override bool ParseOption(string name, CommandLineOptionEngine.CommandLineParseState ps)
        {
            var args = ps.args;  // convenient synonym
              switch (name) {
            case "infer":
              if (ps.ConfirmArgumentCount(1)) {
            foreach (char c in cce.NonNull(args[ps.i])) {
              switch (c) {
                case 't':
                  Ai.J_Trivial = true;
                  UseAbstractInterpretation = true;
                  break;
                case 'j':
                  Ai.J_Intervals = true;
                  UseAbstractInterpretation = true;
                  break;
                case 's':
                  Ai.DebugStatistics = true;
                  UseAbstractInterpretation = true;
                  break;
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                  StepsBeforeWidening = (int)char.GetNumericValue(c);
                  break;
                default:
                  ps.Error("Invalid argument '{0}' to option {1}", c.ToString(), ps.s);
                  break;
              }
            }
              }
              return true;

            case "noinfer":
              if (ps.ConfirmArgumentCount(0)) {
            UseAbstractInterpretation = false;
              }
              return true;

            case "break":
            case "launch":
              if (ps.ConfirmArgumentCount(0)) {
            System.Diagnostics.Debugger.Launch();
              }
              return true;

            case "proc":
              if (this.procsToCheck == null) {
            this.procsToCheck = new List<string/*!*/>();
              }
              if (ps.ConfirmArgumentCount(1)) {
            this.procsToCheck.Add(cce.NonNull(args[ps.i]));
              }
              return true;

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

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

            case "pretty":
              int val = 1;
              if (ps.GetNumericArgument(ref val, 2)) {
            PrettyPrint = val == 1;
              }
              return true;

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

            case "trustLayersUpto":
              if (ps.ConfirmArgumentCount(1))
              {
              ps.GetNumericArgument(ref TrustLayersUpto);
              }
              return true;

            case "trustLayersDownto":
              if (ps.ConfirmArgumentCount(1))
              {
              ps.GetNumericArgument(ref TrustLayersDownto);
              }
              return true;

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

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

              case "logPrefix":
              if (ps.ConfirmArgumentCount(1)) {
            string s = cce.NonNull(args[ps.i]);
            LogPrefix += s.Replace('/', '-').Replace('\\', '-');
              }
              return true;

            case "proverShutdownLimit":
              ps.GetNumericArgument(ref ProverShutdownLimit);
              return true;

            case "errorTrace":
              ps.GetNumericArgument(ref ErrorTrace, 3);
              return true;

            case "proverWarnings": {
            int pw = 0;
            if (ps.GetNumericArgument(ref pw, 3)) {
              switch (pw) {
                case 0:
                  PrintProverWarnings = ProverWarnings.None;
                  break;
                case 1:
                  PrintProverWarnings = ProverWarnings.Stdout;
                  break;
                case 2:
                  PrintProverWarnings = ProverWarnings.Stderr;
                  break;
                default: {
                    Contract.Assert(false);
                    throw new cce.UnreachableException();
                  } // postcondition of GetNumericArgument guarantees that we don't get here
              }
            }
            return true;
              }

            case "env": {
            int e = 0;
            if (ps.GetNumericArgument(ref e, 3)) {
              switch (e) {
                case 0:
                  ShowEnv = ShowEnvironment.Never;
                  break;
                case 1:
                  ShowEnv = ShowEnvironment.DuringPrint;
                  break;
                case 2:
                  ShowEnv = ShowEnvironment.Always;
                  break;
                default: {
                    Contract.Assert(false);
                    throw new cce.UnreachableException();
                  } // postcondition of GetNumericArgument guarantees that we don't get here
              }
            }
            return true;
              }

            case "loopUnroll":
              ps.GetNumericArgument(ref LoopUnrollCount);
              return true;

            case "printModel":
              if (ps.ConfirmArgumentCount(1)) {
            switch (args[ps.i]) {
              case "0":
                PrintErrorModel = 0;
                break;
              case "1":
                PrintErrorModel = 1;
                break;
              case "2":
                PrintErrorModel = 2;
                break;
              case "4":
                PrintErrorModel = 4;
                break;
              default:
                ps.Error("Invalid argument \"{0}\" to option {1}", args[ps.i], ps.s);
                break;
            }
              }
              return true;

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

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

            case "enhancedErrorMessages":
              ps.GetNumericArgument(ref EnhancedErrorMessages, 2);
              return true;

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

            case "inlineDepth":
              ps.GetNumericArgument(ref InlineDepth);
              return true;

            case "subsumption": {
            int s = 0;
            if (ps.GetNumericArgument(ref s, 3)) {
              switch (s) {
                case 0:
                  UseSubsumption = SubsumptionOption.Never;
                  break;
                case 1:
                  UseSubsumption = SubsumptionOption.NotForQuantifiers;
                  break;
                case 2:
                  UseSubsumption = SubsumptionOption.Always;
                  break;
                default: {
                    Contract.Assert(false);
                    throw new cce.UnreachableException();
                  } // postcondition of GetNumericArgument guarantees that we don't get here
              }
            }
            return true;
              }

            case "liveVariableAnalysis": {
            int lva = 0;
            if (ps.GetNumericArgument(ref lva, 3)) {
              LiveVariableAnalysis = lva;
            }
            return true;
              }

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

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

            case "noPruneInfeasibleEdges": {
            if (ps.ConfirmArgumentCount(0)) {
              PruneInfeasibleEdges = false;
            }
            return true;
            }

            case "stagedHoudini": {
            if (ps.ConfirmArgumentCount(1)) {
                if(args[ps.i] == "COARSE" ||
                   args[ps.i] == "FINE" ||
                   args[ps.i] == "BALANCED") {
                    StagedHoudini = args[ps.i];
                } else {
                    ps.Error("Invalid argument \"{0}\" to option {1}", args[ps.i], ps.s);
                }
            }
            return true;
            }

            case "stagedHoudiniThreads": {
            ps.GetNumericArgument(ref StagedHoudiniThreads);
            return true;
            }

            case "stagedHoudiniReachabilityAnalysis": {
            if (ps.ConfirmArgumentCount(0)) {
              StagedHoudiniReachabilityAnalysis = true;
            }
            return true;
              }

            case "stagedHoudiniMergeIgnoredAnnotations": {
            if (ps.ConfirmArgumentCount(0)) {
              StagedHoudiniMergeIgnoredAnnotations = true;
            }
            return true;
              }

            case "debugStagedHoudini": {
            if (ps.ConfirmArgumentCount(0)) {
              DebugStagedHoudini = true;
            }
            return true;
              }

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

            case "abstractHoudini":
            {
                if (ps.ConfirmArgumentCount(1))
                {
                    AbstractHoudini = args[ps.i];
                }
                return true;
            }
            case "vc":
              if (ps.ConfirmArgumentCount(1)) {
            switch (args[ps.i]) {
              case "s":
              case "structured":
                vcVariety = VCVariety.Structured;
                break;
              case "b":
              case "block":
                vcVariety = VCVariety.Block;
                break;
              case "l":
              case "local":
                vcVariety = VCVariety.Local;
                break;
              case "n":
              case "nested":
                vcVariety = VCVariety.BlockNested;
                break;
              case "m":
                vcVariety = VCVariety.BlockNestedReach;
                break;
              case "r":
                vcVariety = VCVariety.BlockReach;
                break;
              case "d":
              case "dag":
                vcVariety = VCVariety.Dag;
                break;
              case "i":
                vcVariety = VCVariety.DagIterative;
                break;
              case "doomed":
                vcVariety = VCVariety.Doomed;
                break;
              default:
                ps.Error("Invalid argument \"{0}\" to option {1}", args[ps.i], ps.s);
                break;
            }
              }
              return true;

            case "prover":
              if (ps.ConfirmArgumentCount(1)) {
            TheProverFactory = ProverFactory.Load(cce.NonNull(args[ps.i]));
            ProverName = cce.NonNull(args[ps.i]).ToUpper();
              }
              return true;

            case "p":
            case "proverOpt":
              if (ps.ConfirmArgumentCount(1)) {
            ProverOptions = ProverOptions.Concat1(cce.NonNull(args[ps.i]));
              }
              return true;

            case "DoomStrategy":
              ps.GetNumericArgument(ref DoomStrategy);
              return true;

            case "DoomRestartTP":
              if (ps.ConfirmArgumentCount(0)) {
            DoomRestartTP = true;
              }
              return true;

            case "extractLoops":
              if (ps.ConfirmArgumentCount(0)) {
            ExtractLoops = true;
              }
              return true;

            case "deterministicExtractLoops":
              if (ps.ConfirmArgumentCount(0)) {
            DeterministicExtractLoops = true;
              }
              return true;

            case "inline":
              if (ps.ConfirmArgumentCount(1)) {
            switch (args[ps.i]) {
              case "none":
                ProcedureInlining = Inlining.None;
                break;
              case "assert":
                ProcedureInlining = Inlining.Assert;
                break;
              case "assume":
                ProcedureInlining = Inlining.Assume;
                break;
              case "spec":
                ProcedureInlining = Inlining.Spec;
                break;
              default:
                ps.Error("Invalid argument \"{0}\" to option {1}", args[ps.i], ps.s);
                break;
            }
              }
              return true;
            case "secure":
              if (ps.ConfirmArgumentCount(1))
              SecureVcGen = args[ps.i];
              return true;
            case "stratifiedInline":
              if (ps.ConfirmArgumentCount(1)) {
            switch (args[ps.i]) {
              case "0":
                StratifiedInlining = 0;
                break;
              case "1":
                StratifiedInlining = 1;
                break;
              default:
                StratifiedInlining = Int32.Parse(cce.NonNull(args[ps.i]));
                //ps.Error("Invalid argument \"{0}\" to option {1}", args[ps.i], ps.s);
                break;
            }
              }
              return true;
            case "fixedPointEngine":
              if (ps.ConfirmArgumentCount(1))
              {
              FixedPointEngine = args[ps.i];
              }
              return true;
            case "fixedPointInfer":
              if (ps.ConfirmArgumentCount(1))
              {
              switch (args[ps.i])
              {
                  case "corral":
                      FixedPointMode = FixedPointInferenceMode.Corral;
                      break;
                  case "oldCorral":
                      FixedPointMode = FixedPointInferenceMode.OldCorral;
                      break;
                  case "flat":
                      FixedPointMode = FixedPointInferenceMode.Flat;
                      break;
                  case "procedure":
                      FixedPointMode = FixedPointInferenceMode.Procedure;
                      break;
                  case "call":
                      FixedPointMode = FixedPointInferenceMode.Call;
                      break;
                  default:
                      ps.Error("Invalid argument \"{0}\" to option {1}", args[ps.i], ps.s);
                      break;
              }
              }
              return true;
            case "printFixedPoint":
              if (ps.ConfirmArgumentCount(1))
              {
              PrintFixedPoint = args[ps.i];
              }
              return true;
            case "printConjectures":
              if (ps.ConfirmArgumentCount(1))
              {
              PrintConjectures = args[ps.i];
              }
              return true;
            case "siVerbose":
              if (ps.ConfirmArgumentCount(1)) {
            StratifiedInliningVerbose = Int32.Parse(cce.NonNull(args[ps.i]));
              }
              return true;
            case "recursionBound":
              if (ps.ConfirmArgumentCount(1)) {
            RecursionBound = Int32.Parse(cce.NonNull(args[ps.i]));
              }
              return true;
            case "stackDepthBound":
              if (ps.ConfirmArgumentCount(1))
              {
              StackDepthBound = Int32.Parse(cce.NonNull(args[ps.i]));
              }
              return true;
            case "stratifiedInlineOption":
              if (ps.ConfirmArgumentCount(1)) {
            StratifiedInliningOption = Int32.Parse(cce.NonNull(args[ps.i]));
              }
              return true;

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

            case "typeEncoding":
              if (ps.ConfirmArgumentCount(1)) {
            switch (args[ps.i]) {
              case "n":
              case "none":
                TypeEncodingMethod = TypeEncoding.None;
                break;
              case "p":
              case "predicates":
                TypeEncodingMethod = TypeEncoding.Predicates;
                break;
              case "a":
              case "arguments":
                TypeEncodingMethod = TypeEncoding.Arguments;
                break;
              case "m":
              case "monomorphic":
                TypeEncodingMethod = TypeEncoding.Monomorphic;
                break;
              default:
                ps.Error("Invalid argument \"{0}\" to option {1}", args[ps.i], ps.s);
                break;
            }
              }
              return true;

            case "instrumentInfer":
              if (ps.ConfirmArgumentCount(1)) {
            switch (args[ps.i]) {
              case "e":
                InstrumentInfer = InstrumentationPlaces.Everywhere;
                break;
              case "h":
                InstrumentInfer = InstrumentationPlaces.LoopHeaders;
                break;
              default:
                ps.Error("Invalid argument \"{0}\" to option {1}", args[ps.i], ps.s);
                break;
            }
              }
              return true;

            case "concurrentHoudini":
              if (ps.ConfirmArgumentCount(0)) {
            ConcurrentHoudini = true;
              }
              return true;

            case "modifyTopologicalSorting":
              if (ps.ConfirmArgumentCount(0)) {
            ModifyTopologicalSorting = true;
              }
              return true;

            case "debugConcurrentHoudini":
              if (ps.ConfirmArgumentCount(0)) {
            DebugConcurrentHoudini = true;
              }
              return true;

            case "vcBrackets":
              ps.GetNumericArgument(ref bracketIdsInVC, 2);
              return true;

            case "proverMemoryLimit": {
            int d = 0;
            if (ps.GetNumericArgument(ref d)) {
              MaxProverMemory = d * Megabyte;
            }
            return true;
              }

            case "vcsMaxCost":
              ps.GetNumericArgument(ref VcsMaxCost);
              return true;

            case "vcsPathJoinMult":
              ps.GetNumericArgument(ref VcsPathJoinMult);
              return true;

            case "vcsPathCostMult":
              ps.GetNumericArgument(ref VcsPathCostMult);
              return true;

            case "vcsAssumeMult":
              ps.GetNumericArgument(ref VcsAssumeMult);
              return true;

            case "vcsPathSplitMult":
              ps.GetNumericArgument(ref VcsPathSplitMult);
              return true;

            case "vcsMaxSplits":
              ps.GetNumericArgument(ref VcsMaxSplits);
              return true;

            case "vcsMaxKeepGoingSplits":
              ps.GetNumericArgument(ref VcsMaxKeepGoingSplits);
              return true;

            case "vcsFinalAssertTimeout":
              ps.GetNumericArgument(ref VcsFinalAssertTimeout);
              return true;

            case "vcsKeepGoingTimeout":
              ps.GetNumericArgument(ref VcsKeepGoingTimeout);
              return true;

            case "vcsCores":
              ps.GetNumericArgument(ref VcsCores, a => 1 <= a);
              return true;

            case "vcsLoad":
              double load = 0.0;
              if (ps.GetNumericArgument(ref load)) {
            if (3.0 <= load) {
              ps.Error("surprisingly high load specified; got {0}, expected nothing above 3.0", load.ToString());
              load = 3.0;
            }
            int p = (int)Math.Round(System.Environment.ProcessorCount * load);
            VcsCores = p < 1 ? 1 : p;
              }
              return true;

            case "simplifyMatchDepth":
              ps.GetNumericArgument(ref SimplifyProverMatchDepth);
              return true;

            case "timeLimit":
              ps.GetNumericArgument(ref ProverKillTime);
              return true;

            case "timeLimitPerAssertionInPercent":
              ps.GetNumericArgument(ref TimeLimitPerAssertionInPercent, a => 0 < a);
              return true;

            case "smokeTimeout":
              ps.GetNumericArgument(ref SmokeTimeout);
              return true;

            case "errorLimit":
              ps.GetNumericArgument(ref ProverCCLimit);
              return true;

            case "verifySnapshots":
              ps.GetNumericArgument(ref VerifySnapshots, 4);
              return true;

            case "traceCaching":
              ps.GetNumericArgument(ref TraceCaching, 4);
              return true;

            case "useSmtOutputFormat": {
              if (ps.ConfirmArgumentCount(0)) {
            UseSmtOutputFormat = true;
              }
              return true;
            }

            case "z3opt":
              if (ps.ConfirmArgumentCount(1)) {
            AddZ3Option(cce.NonNull(args[ps.i]));
              }
              return true;

            case "z3lets":
              ps.GetNumericArgument(ref Z3lets, 4);
              return true;

            case "platform":
              if (ps.ConfirmArgumentCount(1)) {
            StringCollection platformOptions = this.ParseNamedArgumentList(args[ps.i]);
            if (platformOptions != null && platformOptions.Count > 0) {
              try {
                this.TargetPlatform = (PlatformType)cce.NonNull(Enum.Parse(typeof(PlatformType), cce.NonNull(platformOptions[0])));
              } catch {
                ps.Error("Bad /platform type '{0}'", platformOptions[0]);
                break;
              }
              if (platformOptions.Count > 1) {
                this.TargetPlatformLocation = platformOptions[1];
                if (!Directory.Exists(platformOptions[1])) {
                  ps.Error("/platform directory '{0}' does not exist", platformOptions[1]);
                  break;
                }
              }
            }
              }
              return true;

            case "z3exe":
              if (ps.ConfirmArgumentCount(1)) {
            Z3ExecutablePath = args[ps.i];
              }
              return true;
             // This sets name of z3 binary boogie binary directory, not path
            case "z3name":
              if (ps.ConfirmArgumentCount(1))
              {
              Z3ExecutableName = args[ps.i];
              }
              return true;

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

            case "kInductionDepth":
              ps.GetNumericArgument(ref KInductionDepth);
              return true;

            default:
              bool optionValue = false;
              if (ps.CheckBooleanFlag("printUnstructured", ref optionValue)) {
            PrintUnstructured = optionValue ? 1 : 0;
            return true;
              }

              if (ps.CheckBooleanFlag("printDesugared", ref PrintDesugarings) ||
              ps.CheckBooleanFlag("printInstrumented", ref PrintInstrumented) ||
              ps.CheckBooleanFlag("printWithUniqueIds", ref PrintWithUniqueASTIds) ||
              ps.CheckBooleanFlag("wait", ref Wait) ||
              ps.CheckBooleanFlag("trace", ref Trace) ||
              ps.CheckBooleanFlag("traceTimes", ref TraceTimes) ||
              ps.CheckBooleanFlag("tracePOs", ref TraceProofObligations) ||
              ps.CheckBooleanFlag("noResolve", ref NoResolve) ||
              ps.CheckBooleanFlag("noTypecheck", ref NoTypecheck) ||
              ps.CheckBooleanFlag("overlookTypeErrors", ref OverlookBoogieTypeErrors) ||
              ps.CheckBooleanFlag("noVerify", ref Verify, false) ||
              ps.CheckBooleanFlag("traceverify", ref TraceVerify) ||
              ps.CheckBooleanFlag("alwaysAssumeFreeLoopInvariants", ref AlwaysAssumeFreeLoopInvariants, true) ||
              ps.CheckBooleanFlag("nologo", ref DontShowLogo) ||
              ps.CheckBooleanFlag("proverLogAppend", ref SimplifyLogFileAppend) ||
              ps.CheckBooleanFlag("soundLoopUnrolling", ref SoundLoopUnrolling) ||
              ps.CheckBooleanFlag("checkInfer", ref InstrumentWithAsserts) ||
              ps.CheckBooleanFlag("interprocInfer", ref IntraproceduralInfer, false) ||
              ps.CheckBooleanFlag("restartProver", ref RestartProverPerVC) ||
              ps.CheckBooleanFlag("printInlined", ref PrintInlined) ||
              ps.CheckBooleanFlag("smoke", ref SoundnessSmokeTest) ||
              ps.CheckBooleanFlag("vcsDumpSplits", ref VcsDumpSplits) ||
              ps.CheckBooleanFlag("dbgRefuted", ref DebugRefuted) ||
              ps.CheckBooleanFlag("causalImplies", ref CausalImplies) ||
              ps.CheckBooleanFlag("reflectAdd", ref ReflectAdd) ||
              ps.CheckBooleanFlag("z3types", ref Z3types) ||
              ps.CheckBooleanFlag("z3multipleErrors", ref z3AtFlag, false) ||
              ps.CheckBooleanFlag("monomorphize", ref Monomorphize) ||
              ps.CheckBooleanFlag("useArrayTheory", ref UseArrayTheory) ||
              ps.CheckBooleanFlag("weakArrayTheory", ref WeakArrayTheory) ||
              ps.CheckBooleanFlag("doModSetAnalysis", ref DoModSetAnalysis) ||
              ps.CheckBooleanFlag("doNotUseLabels", ref UseLabels, false) ||
              ps.CheckBooleanFlag("runDiagnosticsOnTimeout", ref RunDiagnosticsOnTimeout) ||
              ps.CheckBooleanFlag("traceDiagnosticsOnTimeout", ref TraceDiagnosticsOnTimeout) ||
              ps.CheckBooleanFlag("boolControlVC", ref SIBoolControlVC, true) ||
              ps.CheckBooleanFlag("contractInfer", ref ContractInfer) ||
              ps.CheckBooleanFlag("explainHoudini", ref ExplainHoudini) ||
              ps.CheckBooleanFlag("reverseHoudiniWorklist", ref ReverseHoudiniWorklist) ||
              ps.CheckBooleanFlag("crossDependencies", ref HoudiniUseCrossDependencies) ||
              ps.CheckBooleanFlag("useUnsatCoreForContractInfer", ref UseUnsatCoreForContractInfer) ||
              ps.CheckBooleanFlag("printAssignment", ref PrintAssignment) ||
              ps.CheckBooleanFlag("useProverEvaluate", ref UseProverEvaluate) ||
              ps.CheckBooleanFlag("nonUniformUnfolding", ref NonUniformUnfolding) ||
              ps.CheckBooleanFlag("deterministicExtractLoops", ref DeterministicExtractLoops) ||
              ps.CheckBooleanFlag("verifySeparately", ref VerifySeparately) ||
              ps.CheckBooleanFlag("trustAtomicityTypes", ref TrustAtomicityTypes) ||
              ps.CheckBooleanFlag("trustNonInterference", ref TrustNonInterference) ||
              ps.CheckBooleanFlag("useBaseNameForFileName", ref UseBaseNameForFileName)
              ) {
            // one of the boolean flags matched
            return true;
              }
              break;
              }

              return base.ParseOption(name, ps);  // defer to superclass
        }