forked from boogie-org/boogie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandLineOptions.cs
1907 lines (1702 loc) · 69.8 KB
/
CommandLineOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//-----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All Rights Reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Diagnostics.Contracts;
namespace Microsoft.Boogie {
public class CommandLineOptionEngine
{
public readonly string ToolName;
public readonly string DescriptiveToolName;
[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(ToolName != null);
Contract.Invariant(DescriptiveToolName != null);
Contract.Invariant(Environment != null);
Contract.Invariant(cce.NonNullElements(Files));
}
public string/*!*/ Environment = "";
public List<string/*!*/>/*!*/ Files = new List<string/*!*/>();
public bool HelpRequested = false;
public bool AttrHelpRequested = false;
public CommandLineOptionEngine(string toolName, string descriptiveName) {
Contract.Requires(toolName != null);
Contract.Requires(descriptiveName != null);
ToolName = toolName;
DescriptiveToolName = descriptiveName;
}
public virtual string/*!*/ VersionNumber {
get {
Contract.Ensures(Contract.Result<string>() != null);
return cce.NonNull(cce.NonNull(System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location)).FileVersion);
}
}
public virtual string/*!*/ VersionSuffix {
get {
Contract.Ensures(Contract.Result<string>() != null);
return " version " + VersionNumber + ", Copyright (c) 2003-2013, Microsoft.";
}
}
public virtual string/*!*/ Version {
get {
Contract.Ensures(Contract.Result<string>() != null);
return DescriptiveToolName + VersionSuffix;
}
}
public string/*!*/ FileTimestamp = cce.NonNull(DateTime.Now.ToString("o")).Replace(':', '.');
public void ExpandFilename(ref string pattern, string logPrefix, string fileTimestamp) {
if (pattern != null) {
pattern = pattern.Replace("@PREFIX@", logPrefix).Replace("@TIME@", fileTimestamp);
string fn = Files.Count == 0 ? "" : Files[Files.Count - 1];
fn = fn.Replace('/', '-').Replace('\\', '-');
pattern = pattern.Replace("@FILE@", fn);
}
}
/// <summary>
/// Process the option and modify "ps" accordingly.
/// Return true if the option is one that is recognized.
/// </summary>
protected virtual bool ParseOption(string name, CommandLineParseState ps) {
Contract.Requires(name != null);
Contract.Requires(ps != null);
switch (name) {
case "help":
case "?":
if (ps.ConfirmArgumentCount(0)) {
HelpRequested = true;
}
return true;
case "attrHelp":
if (ps.ConfirmArgumentCount(0)) {
AttrHelpRequested = true;
}
return true;
default:
break;
}
return false; // unrecognized option
}
protected class CommandLineParseState
{
public string s;
public bool hasColonArgument;
public readonly string[]/*!*/ args;
public int i;
public int nextIndex;
public bool EncounteredErrors;
public readonly string ToolName;
[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(args != null);
Contract.Invariant(0 <= i && i <= args.Length);
Contract.Invariant(0 <= nextIndex && nextIndex <= args.Length);
}
public CommandLineParseState(string[] args, string toolName) {
Contract.Requires(args != null);
Contract.Requires(Contract.ForAll(0, args.Length, i => args[i] != null));
Contract.Requires(toolName != null);
Contract.Ensures(this.args == args);
this.ToolName = toolName;
this.s = null; // set later by client
this.hasColonArgument = false; // set later by client
this.args = args;
this.i = 0;
this.nextIndex = 0; // set later by client
this.EncounteredErrors = false;
}
public bool CheckBooleanFlag(string flagName, ref bool flag, bool valueWhenPresent) {
Contract.Requires(flagName != null);
//modifies nextIndex, encounteredErrors, Console.Error.*;
bool flagPresent = false;
if ((s == "/" + flagName || s == "-" + flagName) && ConfirmArgumentCount(0)) {
flag = valueWhenPresent;
flagPresent = true;
}
return flagPresent;
}
public bool CheckBooleanFlag(string flagName, ref bool flag) {
Contract.Requires(flagName != null);
//modifies nextIndex, encounteredErrors, Console.Error.*;
return CheckBooleanFlag(flagName, ref flag, true);
}
/// <summary>
/// If there is one argument and it is a non-negative integer, then set "arg" to that number and return "true".
/// Otherwise, emit error message, leave "arg" unchanged, and return "false".
/// </summary>
public bool GetNumericArgument(ref int arg) {
//modifies nextIndex, encounteredErrors, Console.Error.*;
if (this.ConfirmArgumentCount(1)) {
try {
Contract.Assume(args[i] != null);
Contract.Assert(args[i] is string); // needed to prove args[i].IsPeerConsistent
int d = Convert.ToInt32(this.args[this.i]);
if (0 <= d) {
arg = d;
return true;
}
} catch (System.FormatException) {
} catch (System.OverflowException) {
}
} else {
return false;
}
Error("Invalid argument \"{0}\" to option {1}", args[this.i], this.s);
return false;
}
/// <summary>
/// If there is one argument and it is a non-negative integer less than "limit",
/// then set "arg" to that number and return "true".
/// Otherwise, emit error message, leave "arg" unchanged, and return "false".
/// </summary>
public bool GetNumericArgument(ref int arg, int limit) {
Contract.Requires(this.i < args.Length);
//modifies nextIndex, encounteredErrors, Console.Error.*;
int a = arg;
if (!GetNumericArgument(ref a)) {
return false;
} else if (a < limit) {
arg = a;
return true;
} else {
Error("Invalid argument \"{0}\" to option {1}", args[this.i], this.s);
return false;
}
}
/// <summary>
/// If there is one argument and it is a non-negative real, then set "arg" to that number and return "true".
/// Otherwise, emit an error message, leave "arg" unchanged, and return "false".
/// </summary>
public bool GetNumericArgument(ref double arg) {
//modifies nextIndex, encounteredErrors, Console.Error.*;
if (this.ConfirmArgumentCount(1)) {
try {
Contract.Assume(args[i] != null);
Contract.Assert(args[i] is string); // needed to prove args[i].IsPeerConsistent
double d = Convert.ToDouble(this.args[this.i]);
if (0 <= d) {
arg = d;
return true;
}
} catch (System.FormatException) {
} catch (System.OverflowException) {
}
} else {
return false;
}
Error("Invalid argument \"{0}\" to option {1}", args[this.i], this.s);
return false;
}
public bool ConfirmArgumentCount(int argCount) {
Contract.Requires(0 <= argCount);
//modifies nextIndex, encounteredErrors, Console.Error.*;
Contract.Ensures(Contract.Result<bool>() == (!(hasColonArgument && argCount != 1) && !(args.Length < i + argCount)));
if (hasColonArgument && argCount != 1) {
Error("\"{0}\" cannot take a colon argument", s);
nextIndex = args.Length;
return false;
} else if (args.Length < i + argCount) {
Error("\"{0}\" expects {1} argument{2}", s, argCount.ToString(), (string)(argCount == 1 ? "" : "s"));
nextIndex = args.Length;
return false;
} else {
nextIndex = i + argCount;
return true;
}
}
public void Error(string message, params string[] args) {
Contract.Requires(args != null);
Contract.Requires(message != null);
//modifies encounteredErrors, Console.Error.*;
Console.Error.WriteLine("{0}: Error: {1}", ToolName, String.Format(message, args));
EncounteredErrors = true;
}
}
public virtual void Usage() {
Console.WriteLine("{0}: usage: {0} [ option ... ] [ filename ... ]", ToolName);
Console.WriteLine(@" where <option> is one of
---- General options -------------------------------------------------------
/help this message
/attrHelp print a message about declaration attributes supported by
this implementation");
}
public virtual void AttributeUsage() {
}
/// <summary>
/// This method is called after all parsing is done, if no parse errors were encountered.
/// </summary>
public virtual void ApplyDefaultOptions() {
}
/// <summary>
/// Parses the command-line arguments "args" into the global flag variables. Returns true
/// if there were no errors.
/// </summary>
/// <param name="args">Consumed ("captured" and possibly modified) by the method.</param>
public bool Parse([Captured] string[]/*!*/ args) {
Contract.Requires(cce.NonNullElements(args));
// save the command line options for the log files
Environment += "Command Line Options: " + args.Concat(" ");
args = cce.NonNull((string[])args.Clone()); // the operations performed may mutate the array, so make a copy
var ps = new CommandLineParseState(args, ToolName);
while (ps.i < args.Length) {
cce.LoopInvariant(ps.args == args);
string arg = args[ps.i];
Contract.Assert(arg != null);
ps.s = arg.Trim();
bool isOption = ps.s.StartsWith("-") || ps.s.StartsWith("/");
int colonIndex = ps.s.IndexOf(':');
if (0 <= colonIndex && isOption) {
ps.hasColonArgument = true;
args[ps.i] = ps.s.Substring(colonIndex + 1);
ps.s = ps.s.Substring(0, colonIndex);
} else {
ps.i++;
ps.hasColonArgument = false;
}
ps.nextIndex = ps.i;
if (isOption) {
if (!ParseOption(ps.s.Substring(1), ps)) {
if (Path.DirectorySeparatorChar == '/' && ps.s.StartsWith("/"))
Files.Add(arg);
else
ps.Error("unknown switch: {0}", ps.s);
}
} else {
Files.Add(arg);
}
ps.i = ps.nextIndex;
}
if (HelpRequested) {
Usage();
} else if (AttrHelpRequested) {
AttributeUsage();
} else if (ps.EncounteredErrors) {
Console.WriteLine("Use /help for available options");
}
if (ps.EncounteredErrors) {
return false;
} else {
this.ApplyDefaultOptions();
return true;
}
}
}
/// <summary>
/// Boogie command-line options (other tools can subclass this class in order to support a
/// superset of Boogie's options.
/// </summary>
public class CommandLineOptions : CommandLineOptionEngine {
[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(FileTimestamp != null);
}
public CommandLineOptions()
: base("Boogie", "Boogie program verifier") {
}
protected CommandLineOptions(string toolName, string descriptiveName)
: base(toolName, descriptiveName) {
Contract.Requires(toolName != null);
Contract.Requires(descriptiveName != null);
}
private static CommandLineOptions clo;
public static CommandLineOptions/*!*/ Clo
{
get { return clo; }
}
public static void Install(CommandLineOptions options) {
Contract.Requires(options != null);
clo = options;
}
public const long Megabyte = 1048576;
// Flags and arguments
public bool RunningBoogieFromCommandLine = false; // "false" means running Boogie from the plug-in
[ContractInvariantMethod]
void ObjectInvariant2() {
Contract.Invariant(LogPrefix != null);
Contract.Invariant(0 <= PrintUnstructured && PrintUnstructured < 3); // 0 = print only structured, 1 = both structured and unstructured, 2 = only unstructured
}
public bool VerifySnapshots;
public bool VerifySeparately;
public string PrintFile = null;
public int PrintUnstructured = 0;
public int DoomStrategy = -1;
public bool DoomRestartTP = false;
public bool PrintDesugarings = false;
public string SimplifyLogFilePath = null;
public string/*!*/ LogPrefix = "";
public bool PrintInstrumented = false;
public bool InstrumentWithAsserts = false;
public enum InstrumentationPlaces {
LoopHeaders,
Everywhere
}
public InstrumentationPlaces InstrumentInfer = InstrumentationPlaces.LoopHeaders;
public bool PrintWithUniqueASTIds = false;
private string XmlSinkFilename = null;
[Peer]
public XmlSink XmlSink = null;
public bool Wait = false;
public bool Trace = false;
public bool TraceTimes = false;
public bool TraceProofObligations = false;
public bool NoResolve = false;
public bool NoTypecheck = false;
public bool OverlookBoogieTypeErrors = false;
public bool Verify = true;
public bool TraceVerify = false;
public int /*(0:3)*/ ErrorTrace = 1;
public bool IntraproceduralInfer = true;
public bool ContractInfer = false;
public bool ExplainHoudini = false;
public bool HoudiniOutputRefutedCandidates = false;
public bool DisableLoopInvMaintainedAssert = false;
public bool DebugParallelHoudini = false;
public bool HoudiniUseCrossDependencies = false;
public string StagedHoudini = null;
public bool DebugStagedHoudini = false;
public bool StagedHoudiniReachabilityAnalysis = false;
public bool StagedHoudiniMergeIgnoredCandidates = false;
public int StagedHoudiniThreads = 2;
public string VariableDependenceIgnore = null;
public string AbstractHoudini = null;
public bool UseUnsatCoreForContractInfer = false;
public bool PrintAssignment = false;
public int InlineDepth = -1;
public bool UseProverEvaluate = false; // Use ProverInterface's Evaluate method, instead of model to get variable values
public bool UseUncheckedContracts = false;
public bool SimplifyLogFileAppend = false;
public bool SoundnessSmokeTest = false;
public string Z3ExecutablePath = null;
public string CVC4ExecutablePath = null;
public enum ProverWarnings {
None,
Stdout,
Stderr
}
public ProverWarnings PrintProverWarnings = ProverWarnings.None;
public int ProverShutdownLimit = 0;
public enum SubsumptionOption {
Never,
NotForQuantifiers,
Always
}
public SubsumptionOption UseSubsumption = SubsumptionOption.Always;
public bool AlwaysAssumeFreeLoopInvariants = false;
public enum ShowEnvironment {
Never,
DuringPrint,
Always
}
public ShowEnvironment ShowEnv = ShowEnvironment.DuringPrint;
public bool DontShowLogo = false;
[ContractInvariantMethod]
void ObjectInvariant3() {
Contract.Invariant(-1 <= LoopFrameConditions && LoopFrameConditions < 3);
Contract.Invariant(0 <= ModifiesDefault && ModifiesDefault < 7);
Contract.Invariant((0 <= PrintErrorModel && PrintErrorModel <= 2) || PrintErrorModel == 4);
Contract.Invariant(0 <= EnhancedErrorMessages && EnhancedErrorMessages < 2);
Contract.Invariant(0 <= StepsBeforeWidening && StepsBeforeWidening <= 9);
Contract.Invariant(-1 <= BracketIdsInVC && BracketIdsInVC < 2);
Contract.Invariant(cce.NonNullElements(ProverOptions));
}
public int LoopUnrollCount = -1; // -1 means don't unroll loops
public bool SoundLoopUnrolling = false;
public int LoopFrameConditions = -1; // -1 means not specified -- this will be replaced by the "implications" section below
public int ModifiesDefault = 5;
public bool LocalModifiesChecks = true;
public bool NoVerifyByDefault = false;
public enum OwnershipModelOption {
Standard,
Experimental,
Trivial
}
public OwnershipModelOption OwnershipModelEncoding = OwnershipModelOption.Standard;
public int PrintErrorModel = 0;
public string PrintErrorModelFile = null;
public string/*?*/ ModelViewFile = null;
public int EnhancedErrorMessages = 0;
public string PrintCFGPrefix = null;
public bool ForceBplErrors = false; // if true, boogie error is shown even if "msg" attribute is present
public bool UseArrayTheory = false;
public bool UseSmtOutputFormat = false;
public bool WeakArrayTheory = false;
public bool UseLabels = true;
public bool MonomorphicArrays {
get {
return UseArrayTheory || TypeEncodingMethod == TypeEncoding.Monomorphic;
}
}
public bool ExpandLambdas = true; // not useful from command line, only to be set to false programatically
public bool DoModSetAnalysis = false;
public bool DoBitVectorAnalysis = false;
public string BitVectorAnalysisOutputBplFile = null;
public bool UseAbstractInterpretation = true; // true iff the user want to use abstract interpretation
public int /*0..9*/StepsBeforeWidening = 0; // The number of steps that must be done before applying a widen operator
public string OwickiGriesDesugaredOutputFile = null;
public enum VCVariety {
Structured,
Block,
Local,
BlockNested,
BlockReach,
BlockNestedReach,
Dag,
DagIterative,
Doomed,
Unspecified
}
public VCVariety vcVariety = VCVariety.Unspecified; // will not be Unspecified after command line has been parsed
public bool RemoveEmptyBlocks = true;
public bool CoalesceBlocks = true;
public bool PruneInfeasibleEdges = true;
[Rep]
public ProverFactory TheProverFactory;
public string ProverName;
[Peer]
public List<string/*!*/>/*!*/ ProverOptions = new List<string/*!*/>();
public int BracketIdsInVC = -1; // -1 - not specified, 0 - no, 1 - yes
public bool CausalImplies = false;
public int SimplifyProverMatchDepth = -1; // -1 means not specified
public int ProverKillTime = -1; // -1 means not specified
public int SmokeTimeout = 10; // default to 10s
public int ProverCCLimit = 5;
public bool z3AtFlag = true;
public bool RestartProverPerVC = false;
public double VcsMaxCost = 1.0;
public double VcsPathJoinMult = 0.8;
public double VcsPathCostMult = 1.0;
public double VcsAssumeMult = 0.01;
public double VcsPathSplitMult = 0.5; // 0.5-always, 2-rarely do path splitting
public int VcsMaxSplits = 1;
public int VcsMaxKeepGoingSplits = 1;
public int VcsFinalAssertTimeout = 30;
public int VcsKeepGoingTimeout = 1;
public int VcsCores = 1;
public bool VcsDumpSplits = false;
public bool DebugRefuted = false;
public XmlSink XmlRefuted {
get {
if (DebugRefuted)
return XmlSink;
else
return null;
}
}
[ContractInvariantMethod]
void ObjectInvariant4() {
Contract.Invariant(cce.NonNullElements(Z3Options));
Contract.Invariant(0 <= Z3lets && Z3lets < 4);
}
[Peer]
public List<string/*!*/>/*!*/ Z3Options = new List<string/*!*/>();
public bool Z3types = false;
public int Z3lets = 3; // 0 - none, 1 - only LET TERM, 2 - only LET FORMULA, 3 - (default) any
// Maximum amount of virtual memory (in bytes) for the prover to use
//
// Non-positive number indicates unbounded.
public long MaxProverMemory = 100 * Megabyte;
// Minimum number of prover calls before restart
public int MinNumOfProverCalls = 5;
public enum PlatformType {
notSpecified,
v1,
v11,
v2,
cli1
}
public PlatformType TargetPlatform;
public string TargetPlatformLocation;
public string StandardLibraryLocation;
// whether procedure inlining is enabled at call sites.
public enum Inlining {
None,
Assert,
Assume,
Spec
};
public Inlining ProcedureInlining = Inlining.Assume;
public bool PrintInlined = false;
public bool ExtractLoops = false;
public bool DeterministicExtractLoops = false;
public int StratifiedInlining = 0;
public string FixedPointEngine = null;
public int StratifiedInliningOption = 0;
public bool StratifiedInliningWithoutModels = false; // disable model generation for SI
public int StratifiedInliningVerbose = 0; // verbosity level
public int RecursionBound = 500;
public bool NonUniformUnfolding = false;
public string inferLeastForUnsat = null;
public string CoverageReporterPath = null;
public Process coverageReporter = null; // used internally for debugging
// Inference mode for fixed point engine
public enum FixedPointInferenceMode {
Corral,
OldCorral,
Flat,
Procedure,
Call
};
public FixedPointInferenceMode FixedPointMode = FixedPointInferenceMode.Procedure;
public enum TypeEncoding {
None,
Predicates,
Arguments,
Monomorphic
};
public TypeEncoding TypeEncodingMethod = TypeEncoding.Predicates;
public bool Monomorphize = false;
public bool ReflectAdd = false;
public int LiveVariableAnalysis = 1;
// Static constructor
static CommandLineOptions() {
if (System.Type.GetType("Mono.Runtime") == null) { // MONO
TraceListenerCollection/*!*/ dbl = Debug.Listeners;
Contract.Assert(dbl != null);
Contract.Assume(cce.IsPeerConsistent(dbl)); // hangs off static field
dbl.Add(new DefaultTraceListener());
}
}
public List<string/*!*/> ProcsToCheck = null; // null means "no restriction"
[ContractInvariantMethod]
void ObjectInvariant5() {
Contract.Invariant(cce.NonNullElements(ProcsToCheck, true));
Contract.Invariant(Ai != null);
}
public class AiFlags {
public bool J_Trivial = false;
public bool J_Intervals = false;
public bool DebugStatistics = false;
}
public AiFlags/*!*/ Ai = new AiFlags();
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 (ProcsToCheck == null) {
ProcsToCheck = new List<string/*!*/>();
}
if (ps.ConfirmArgumentCount(1)) {
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 "OwickiGries":
if (ps.ConfirmArgumentCount(1)) {
OwickiGriesDesugaredOutputFile = args[ps.i];
}
return true;
case "proverLog":
if (ps.ConfirmArgumentCount(1)) {
SimplifyLogFilePath = 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 "stagedHoudiniMergeIgnoredCandidates": {
if (ps.ConfirmArgumentCount(0)) {
StagedHoudiniMergeIgnoredCandidates = 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;