forked from dafny-lang/dafny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommonOptionBag.cs
533 lines (456 loc) · 27.1 KB
/
CommonOptionBag.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
using System.Collections.Generic;
using System.CommandLine;
using System.IO;
using System.Linq;
using DafnyCore;
using Microsoft.Dafny.Compilers;
namespace Microsoft.Dafny;
public class CommonOptionBag {
public enum AssertionShowMode { None, Implicit, All }
public static readonly Option<AssertionShowMode> ShowAssertions = new("--show-assertions", () => AssertionShowMode.None,
"Show hints on locations where implicit assertions occur");
public static readonly Option<bool> AddCompileSuffix =
new("--compile-suffix", "Add the suffix _Compile to module names without :extern") {
IsHidden = true
};
public static readonly Option<bool> ManualLemmaInduction =
new("--manual-lemma-induction", "Turn off automatic induction for lemmas.");
public static readonly Option<bool> StdIn = new("--stdin", () => false,
@"Read standard input and treat it as an input .dfy file.");
public static readonly Option<bool> Check = new("--check", () => false, @"
Instead of formatting files, verify that all files are already
formatted through and return a non-zero exit code if it is not the case".TrimStart());
public static readonly Option<bool> OptimizeErasableDatatypeWrapper = new("--optimize-erasable-datatype-wrapper", () => true, @"
false - Include all non-ghost datatype constructors in the compiled code
true - In the compiled target code, transform any non-extern
datatype with a single non-ghost constructor that has a single
non-ghost parameter into just that parameter. For example, the type
datatype Record = Record(x: int)
is transformed into just 'int' in the target code.".TrimStart());
public static readonly Option<bool> Verbose = new("--verbose",
"Print additional information such as which files are emitted where.");
public static readonly Option<bool> WarnDeprecation = new("--warn-deprecation", () => true,
"Warn about the use of deprecated features (default true).") {
};
public static readonly Option<bool> DisableNonLinearArithmetic = new("--disable-nonlinear-arithmetic",
@"
(experimental, will be replaced in the future)
Reduce Dafny's knowledge of non-linear arithmetic (*,/,%).
Results in more manual work, but also produces more predictable behavior.".TrimStart());
public static readonly Option<bool> EnforceDeterminism = new("--enforce-determinism",
"Check that only deterministic statements are used, so that values seen during execution will be the same in every run of the program.") {
};
public static readonly Option<bool> RelaxDefiniteAssignment = new("--relax-definite-assignment",
"Allow variables to be read before they are assigned, but only if they have an auto-initializable type or if they are ghost and have a nonempty type.") {
};
public static readonly Option<List<string>> VerificationLogFormat = new("--log-format", $@"
Logs verification results using the given test result format. The currently supported formats are `trx`, `csv`, and `text`. These are: the XML-based format commonly used for test results for .NET languages, a custom CSV schema, and a textual format meant for human consumption. You can provide configuration using the same string format as when using the --logger option for dotnet test, such as: --format ""trx;LogFileName=<...>"");
The `trx` and `csv` formats automatically choose an output file name by default, and print the name of this file to the console. The `text` format prints its output to the console by default, but can send output to a file given the `LogFileName` option.
The `text` format also includes a more detailed breakdown of what assertions appear in each assertion batch. When combined with the {BoogieOptionBag.IsolateAssertions.Name} option, it will provide approximate time and resource use costs for each assertion, allowing identification of especially expensive assertions.".TrimStart()) {
ArgumentHelpName = "configuration"
};
public static readonly Option<bool> JsonDiagnostics = new("--json-diagnostics", @"Deprecated. Return diagnostics in a JSON format.") {
IsHidden = true
};
public static readonly Option<IList<FileInfo>> Libraries = new("--library",
@"
The contents of this file and any files it includes can be referenced from other files as if they were included.
However, these contents are skipped during code generation and verification.
This option is useful in a diamond dependency situation,
to prevent code from the bottom dependency from being generated more than once.
The value may be a comma-separated list of files and folders.".TrimStart());
public static readonly Option<FileInfo> BuildFile = new(new[] { "--build", "-b" },
"Specify the filepath that determines where to place and how to name build files.") {
ArgumentHelpName = "file",
IsHidden = true
};
public static readonly Option<FileInfo> Output = new(new[] { "--output", "-o" },
"Specify the filename and location for the generated target language files.") {
ArgumentHelpName = "file",
};
public static readonly Option<IList<string>> PluginOption = new(new[] { "--plugin" },
@"
(experimental) One path to an assembly that contains at least one
instantiatable class extending Microsoft.Dafny.Plugin.Rewriter. It
can also extend Microsoft.Dafny.Plugins.PluginConfiguration to
receive arguments. More information about what plugins do and how
to define them:
https://github.com/dafny-lang/dafny/blob/master/Source/DafnyLanguageServer/README.md#about-plugins") {
ArgumentHelpName = "path-to-one-assembly[,argument]*",
IsHidden = true
};
public static readonly Option<FileInfo> Prelude = new("--prelude", "Choose the Dafny prelude file.") {
ArgumentHelpName = "file",
};
public static readonly Option<QuantifierSyntaxOptions> QuantifierSyntax = new("--quantifier-syntax",
result => {
if (result.Tokens.Any()) {
var value = result.Tokens[0].Value;
switch (value) {
case "3": return QuantifierSyntaxOptions.Version3;
case "4": return QuantifierSyntaxOptions.Version4;
default:
result.ErrorMessage = $"{value} is not a valid argument to {QuantifierSyntax.Name}";
return default;
}
}
return QuantifierSyntaxOptions.Version4;
}, true, @"
The syntax for quantification domains is changing from Dafny version 3 to version 4, more specifically where quantifier ranges (|
<Range>) are allowed. This switch gives early access to the new syntax.
3 - Ranges are only allowed after all quantified variables are declared.
(e.g. set x, y | 0 <= x < |s| && y in s[x] && 0 <= y :: y)
4 - Ranges are allowed after each quantified variable declaration.
(e.g. set x | 0 <= x < |s|, y <- s[x] | 0 <= y :: y)
Note that quantifier variable domains (<- <Domain>) are available in both syntax versions.".TrimStart()) {
ArgumentHelpName = "version",
};
public static readonly Option<string> Target = new(new[] { "--target", "-t" }, () => "cs", @"
cs - Compile to .NET via C#.
go - Compile to Go.
js - Compile to JavaScript.
java - Compile to Java.
py - Compile to Python.
cpp - Compile to C++.
Note that the C++ backend has various limitations (see Docs/Compilation/Cpp.md). This includes lack of support for BigIntegers (aka int), most higher order functions, and advanced features like traits or co-inductive types.".TrimStart()
) {
ArgumentHelpName = "language",
};
public static readonly Option<bool> UnicodeCharacters = new("--unicode-char", () => true,
@"
false - The char type represents any UTF-16 code unit.
true - The char type represents any Unicode scalar value.".TrimStart()) {
};
public static readonly Option<bool> TypeSystemRefresh = new("--type-system-refresh", () => false,
@"
false - The type-inference engine and supported types are those of Dafny 4.0.
true - Use an updated type-inference engine. Warning: This mode is under construction and probably won't work at this time.".TrimStart()) {
IsHidden = true
};
public enum GeneralTraitsOptions {
Legacy,
Datatype,
Full
}
public static readonly Option<GeneralTraitsOptions> GeneralTraits = new("--general-traits", () => GeneralTraitsOptions.Legacy,
@"
legacy - Every trait implicitly extends 'object', and thus is a reference type. Only traits and reference types can extend traits.
datatype - A trait is a reference type only if it or one of its ancestor traits is 'object'. Any non-'newtype' type with members can extend traits.
full - (don't use; not yet completely supported) A trait is a reference type only if it or one of its ancestor traits is 'object'. Any type with members can extend traits.".TrimStart()) {
IsHidden = true
};
public static readonly Option<bool> TypeInferenceDebug = new("--type-inference-trace", () => false,
@"
false - Don't print type-inference debug information.
true - Print type-inference debug information.".TrimStart()) {
IsHidden = true
};
public static readonly Option<bool> NewTypeInferenceDebug = new("--type-system-debug", () => false,
@"
false - Don't print debug information for the new type system.
true - Print debug information for the new type system.".TrimStart()) {
IsHidden = true
};
public static readonly Option<bool> VerifyIncludedFiles = new("--verify-included-files",
"Verify code in included files.");
public static readonly Option<bool> UseBaseFileName = new("--use-basename-for-filename",
"When parsing use basename of file for tokens instead of the path supplied on the command line") {
};
public static readonly Option<bool> SpillTranslation = new("--spill-translation",
@"In case the Dafny source code is translated to another language, emit that translation.") {
};
public static readonly Option<bool> WarningAsErrors = new("--warn-as-errors",
"Treat warnings as errors.");
public static readonly Option<bool> WarnMissingConstructorParenthesis = new("--warn-missing-constructor-parentheses",
"Emits a warning when a constructor name in a case pattern is not followed by parentheses.");
public static readonly Option<bool> WarnShadowing = new("--warn-shadowing",
"Emits a warning if the name of a declared variable caused another variable to be shadowed.");
public static readonly Option<bool> WarnContradictoryAssumptions = new("--warn-contradictory-assumptions", @"
(experimental) Emits a warning if any assertions are proved based on contradictory assumptions (vacuously).
May slow down verification slightly.
May produce spurious warnings.") {
IsHidden = true
};
public static readonly Option<bool> WarnRedundantAssumptions = new("--warn-redundant-assumptions", @"
(experimental) Emits a warning if any `requires` clause or `assume` statement was not needed to complete verification.
May slow down verification slightly.
May produce spurious warnings.") {
IsHidden = true
};
public static readonly Option<string> VerificationCoverageReport = new("--coverage-report",
"Emit verification coverage report to a given directory, in the same format as a test coverage report.") {
ArgumentHelpName = "directory"
};
public static readonly Option<bool> NoTimeStampForCoverageReport = new("--no-timestamp-for-coverage-report",
"Write coverage report directly to the specified folder instead of creating a timestamped subdirectory.") {
IsHidden = true
};
public static readonly Option<string> ExecutionCoverageReport = new("--test-coverage-report",
"Emit execution coverage report to a given directory.") {
ArgumentHelpName = "directory"
};
public static readonly Option<bool> IncludeRuntimeOption = new("--include-runtime",
"Include the Dafny runtime as source in the target language.");
/// <summary>
/// Copy of --include-runtime for execution commands like `dafny run`,
/// just so it can be internal only in that context:
/// it shouldn't matter to end users but is useful for testing.
/// </summary>
public static readonly Option<bool> InternalIncludeRuntimeOptionForExecution = new("--include-runtime", () => true,
"Include the Dafny runtime as source in the target language.") {
IsHidden = true
};
public enum SystemModuleMode {
Include,
Omit,
// Used to pre-compile the System module into the runtimes
OmitAllOtherModules
}
public static readonly Option<SystemModuleMode> SystemModule = new("--system-module", () => SystemModuleMode.Omit,
"How to handle the built-in _System module.") {
IsHidden = true
};
public static readonly Option<bool> UseJavadocLikeDocstringRewriterOption = new("--javadoclike-docstring-plugin",
"Rewrite docstrings using a simple Javadoc-to-markdown converter"
);
public static readonly Option<bool> ReadsClausesOnMethods = new("--reads-clauses-on-methods",
"Allows reads clauses on methods (with a default of 'reads *') as well as functions."
);
public enum TestAssumptionsMode {
None,
Externs
}
public static readonly Option<TestAssumptionsMode> TestAssumptions = new("--test-assumptions", () => TestAssumptionsMode.None, @"
(experimental) When turned on, inserts runtime tests at locations where (implicit) assumptions occur, such as when calling or being called by external code and when using assume statements.
Functionality is still being expanded. Currently only checks contracts on every call to a function or method marked with the {:extern} attribute.".TrimStart());
public enum DefaultFunctionOpacityOptions {
Transparent,
AutoRevealDependencies,
Opaque
}
public static readonly Option<DefaultFunctionOpacityOptions> DefaultFunctionOpacity = new("--default-function-opacity", () => DefaultFunctionOpacityOptions.Transparent,
@"
Change the default opacity of functions.
`transparent` (default) means functions are transparent, can be manually made opaque and then revealed.
`autoRevealDependencies` makes all functions not explicitly labelled as opaque to be opaque but reveals them automatically in scopes which do not have `{:autoRevealDependencies false}`.
`opaque` means functions are always opaque so the opaque keyword is not needed, and functions must be revealed everywhere needed for a proof.".TrimStart()) {
};
public static readonly Option<bool> UseStandardLibraries = new("--standard-libraries", () => false,
@"
Allow Dafny code to depend on the standard libraries included with the Dafny distribution.
See https://github.com/dafny-lang/dafny/blob/master/Source/DafnyStandardLibraries/README.md for more information.
Not compatible with the --unicode-char:false option.
");
static CommonOptionBag() {
DafnyOptions.RegisterLegacyUi(Target, DafnyOptions.ParseString, "Compilation options", "compileTarget", @"
cs (default) - Compile to .NET via C#.
go - Compile to Go.
js - Compile to JavaScript.
java - Compile to Java.
py - Compile to Python.
cpp - Compile to C++.
dfy - Compile to Dafny.
Note that the C++ backend has various limitations (see
Docs/Compilation/Cpp.md). This includes lack of support for
BigIntegers (aka int), most higher order functions, and advanced
features like traits or co-inductive types.".TrimStart(), "cs");
DafnyOptions.RegisterLegacyUi(OptimizeErasableDatatypeWrapper, DafnyOptions.ParseBoolean, "Compilation options", "optimizeErasableDatatypeWrapper", @"
0 - Include all non-ghost datatype constructors in the compiled code
1 (default) - In the compiled target code, transform any non-extern
datatype with a single non-ghost constructor that has a single
non-ghost parameter into just that parameter. For example, the type
datatype Record = Record(x: int)
is transformed into just 'int' in the target code.".TrimStart(), defaultValue: true);
DafnyOptions.RegisterLegacyUi(Output, DafnyOptions.ParseFileInfo, "Compilation options", "out");
DafnyOptions.RegisterLegacyUi(UnicodeCharacters, DafnyOptions.ParseBoolean, "Language feature selection", "unicodeChar", @"
0 - The char type represents any UTF-16 code unit.
1 (default) - The char type represents any Unicode scalar value.".TrimStart(), defaultValue: true);
DafnyOptions.RegisterLegacyUi(TypeSystemRefresh, DafnyOptions.ParseBoolean, "Language feature selection", "typeSystemRefresh", @"
0 (default) - The type-inference engine and supported types are those of Dafny 4.0.
1 - Use an updated type-inference engine. Warning: This mode is under construction and probably won't work at this time.".TrimStart(), defaultValue: false);
DafnyOptions.RegisterLegacyUi(GeneralTraits, DafnyOptions.ParseGeneralTraitsOption, "Language feature selection", "generalTraits", @"
legacy (default) - Every trait implicitly extends 'object', and thus is a reference type. Only traits and reference types can extend traits.
datatype - A trait is a reference type only if it or one of its ancestor traits is 'object'. Any non-'newtype' type with members can extend traits.
full - (don't use; not yet completely supported) A trait is a reference type only if it or one of its ancestor traits is 'object'. Any type with members can extend traits.".TrimStart());
DafnyOptions.RegisterLegacyUi(TypeInferenceDebug, DafnyOptions.ParseBoolean, "Language feature selection", "titrace", @"
0 (default) - Don't print type-inference debug information.
1 - Print type-inference debug information.".TrimStart(), defaultValue: false);
DafnyOptions.RegisterLegacyUi(NewTypeInferenceDebug, DafnyOptions.ParseBoolean, "Language feature selection", "ntitrace", @"
0 (default) - Don't print debug information for the new type system.
1 - Print debug information for the new type system.".TrimStart(), defaultValue: false);
DafnyOptions.RegisterLegacyUi(UseStandardLibraries, DafnyOptions.ParseBoolean, "Language feature selection", "standardLibraries", @"
0 (default) - Do not allow Dafny code to depend on the standard libraries included with the Dafny distribution.
1 - Allow Dafny code to depend on the standard libraries included with the Dafny distribution.
See https://github.com/dafny-lang/dafny/blob/master/Source/DafnyStandardLibraries/README.md for more information.
Not compatible with the /unicodeChar:0 option.".TrimStart(), defaultValue: false);
DafnyOptions.RegisterLegacyUi(PluginOption, DafnyOptions.ParseStringElement, "Plugins", defaultValue: new List<string>());
DafnyOptions.RegisterLegacyUi(Prelude, DafnyOptions.ParseFileInfo, "Input configuration", "dprelude");
DafnyOptions.RegisterLegacyUi(Libraries, DafnyOptions.ParseFileInfoElement, "Compilation options", defaultValue: new List<FileInfo>());
DafnyOptions.RegisterLegacyUi(DeveloperOptionBag.ResolvedPrint, DafnyOptions.ParseString, "Overall reporting and printing", "rprint");
DafnyOptions.RegisterLegacyUi(DeveloperOptionBag.Print, DafnyOptions.ParseString, "Overall reporting and printing", "dprint");
DafnyOptions.RegisterLegacyUi(DafnyConsolePrinter.ShowSnippets, DafnyOptions.ParseBoolean, "Overall reporting and printing", "showSnippets", @"
0 (default) - Don't show source code snippets for Dafny messages.
1 - Show a source code snippet for each Dafny message.".TrimStart());
DafnyOptions.RegisterLegacyUi(Printer.PrintMode, ParsePrintMode, "Overall reporting and printing", "printMode", legacyDescription: @"
Everything (default) - Print everything listed below.
DllEmbed - print the source that will be included in a compiled dll.
NoIncludes - disable printing of {:verify false} methods
incorporated via the include mechanism, as well as datatypes and
fields included from other files.
NoGhost - disable printing of functions, ghost methods, and proof
statements in implementation methods. It also disables anything
NoIncludes disables.".TrimStart(),
argumentName: "Everything|DllEmbed|NoIncludes|NoGhost",
defaultValue: PrintModes.Everything);
DafnyOptions.RegisterLegacyUi(DefaultFunctionOpacity, DafnyOptions.ParseDefaultFunctionOpacity, "Language feature selection", "defaultFunctionOpacity", null);
void ParsePrintMode(Option<PrintModes> option, Boogie.CommandLineParseState ps, DafnyOptions options) {
if (ps.ConfirmArgumentCount(1)) {
if (ps.args[ps.i].Equals("Everything")) {
options.Set(option, PrintModes.Everything);
} else if (ps.args[ps.i].Equals("NoIncludes")) {
options.Set(option, PrintModes.NoIncludes);
} else if (ps.args[ps.i].Equals("NoGhost")) {
options.Set(option, PrintModes.NoGhost);
} else if (ps.args[ps.i].Equals("DllEmbed")) {
// This is called DllEmbed because it was previously only used inside Dafny-compiled .dll files for C#,
// but it is now used by the LibraryBackend when building .doo files as well.
options.Set(option, PrintModes.Serialization);
} else {
DafnyOptions.InvalidArgumentError(option.Name, ps);
}
}
}
DafnyOptions.RegisterLegacyUi(AddCompileSuffix, DafnyOptions.ParseBoolean, "Compilation options", "compileSuffix");
DafnyOptions.RegisterLegacyUi(ReadsClausesOnMethods, DafnyOptions.ParseBoolean, "Language feature selection", "readsClausesOnMethods", @"
0 (default) - Reads clauses on methods are forbidden.
1 - Reads clauses on methods are permitted (with a default of 'reads *').".TrimStart(), defaultValue: false);
QuantifierSyntax = QuantifierSyntax.FromAmong("3", "4");
DafnyOptions.RegisterLegacyBinding(JsonDiagnostics, (options, value) => {
if (value) {
options.Printer = new DafnyJsonConsolePrinter(options);
options.DiagnosticsFormat = DafnyOptions.DiagnosticsFormats.JSON;
}
});
DafnyOptions.RegisterLegacyBinding(TestAssumptions, (options, value) => {
options.TestContracts = value == TestAssumptionsMode.Externs ? DafnyOptions.ContractTestingMode.Externs : DafnyOptions.ContractTestingMode.None;
});
DafnyOptions.RegisterLegacyBinding(ManualLemmaInduction, (options, value) => {
if (value) {
options.Induction = 1;
}
});
DafnyOptions.RegisterLegacyBinding(IncludeRuntimeOption, (options, value) => { options.IncludeRuntime = value; });
DafnyOptions.RegisterLegacyBinding(InternalIncludeRuntimeOptionForExecution, (options, value) => { options.IncludeRuntime = value; });
DafnyOptions.RegisterLegacyBinding(SystemModule, (options, value) => { options.SystemModuleTranslationMode = value; });
DafnyOptions.RegisterLegacyBinding(UseBaseFileName, (o, f) => o.UseBaseNameForFileName = f);
DafnyOptions.RegisterLegacyBinding(UseJavadocLikeDocstringRewriterOption,
(options, value) => { options.UseJavadocLikeDocstringRewriter = value; });
DafnyOptions.RegisterLegacyBinding(WarnShadowing, (options, value) => { options.WarnShadowing = value; });
DafnyOptions.RegisterLegacyBinding(WarnMissingConstructorParenthesis,
(options, value) => { options.DisallowConstructorCaseWithoutParentheses = value; });
DafnyOptions.RegisterLegacyBinding(WarningAsErrors, (options, value) => { options.WarningsAsErrors = value; });
DafnyOptions.RegisterLegacyBinding(VerifyIncludedFiles,
(options, value) => { options.VerifyAllModules = value; });
DafnyOptions.RegisterLegacyBinding(WarnContradictoryAssumptions, (options, value) => {
if (value) { options.TrackVerificationCoverage = true; }
});
DafnyOptions.RegisterLegacyBinding(WarnRedundantAssumptions, (options, value) => {
if (value) { options.TrackVerificationCoverage = true; }
});
DafnyOptions.RegisterLegacyBinding(Target, (options, value) => { options.CompilerName = value; });
DafnyOptions.RegisterLegacyBinding(QuantifierSyntax, (options, value) => { options.QuantifierSyntax = value; });
DafnyOptions.RegisterLegacyBinding(PluginOption, (options, value) => { options.AdditionalPluginArguments = value; });
DafnyOptions.RegisterLegacyBinding(Check, (options, value) => {
options.FormatCheck = value;
});
DafnyOptions.RegisterLegacyBinding(StdIn, (options, value) => {
options.UseStdin = value;
});
DafnyOptions.RegisterLegacyBinding(FormatPrint, (options, value) => {
options.DafnyPrintFile = value ? "-" : null;
});
DafnyOptions.RegisterLegacyBinding(Prelude, (options, value) => {
options.DafnyPrelude = value?.FullName;
options.ExpandFilename(options.DafnyPrelude, x => options.DafnyPrelude = x, options.LogPrefix,
options.FileTimestamp);
});
DafnyOptions.RegisterLegacyBinding(BuildFile, (options, value) => { options.DafnyPrintCompiledFile = value?.FullName; });
DafnyOptions.RegisterLegacyBinding(Libraries,
(options, value) => { options.LibraryFiles = value.Select(fi => fi.FullName).ToHashSet(); });
DafnyOptions.RegisterLegacyBinding(Output, (options, value) => { options.DafnyPrintCompiledFile = value?.FullName; });
DafnyOptions.RegisterLegacyBinding(Verbose, (o, v) => o.Verbose = v);
DafnyOptions.RegisterLegacyBinding(DisableNonLinearArithmetic, (o, v) => o.DisableNLarith = v);
DafnyOptions.RegisterLegacyBinding(WarnDeprecation, (o, v) => o.DeprecationNoise = v ? 1 : 0);
DafnyOptions.RegisterLegacyBinding(VerificationLogFormat, (o, v) => o.VerificationLoggerConfigs = v);
DafnyOptions.RegisterLegacyBinding(SpillTranslation, (o, f) => o.SpillTargetCode = f ? 1U : 0U);
DafnyOptions.RegisterLegacyBinding(EnforceDeterminism, (options, value) => {
options.ForbidNondeterminism = value;
options.DefiniteAssignmentLevel = 4;
});
RelaxDefiniteAssignment.AddValidator(optionResult => {
var enforceDeterminismResult = optionResult.FindResultFor(EnforceDeterminism);
if (enforceDeterminismResult is not null && enforceDeterminismResult.GetValueOrDefault<bool>()) {
optionResult.ErrorMessage =
$"The option {RelaxDefiniteAssignment.Name} can not be used in conjunction with {EnforceDeterminism.Name}.";
}
});
DafnyOptions.RegisterLegacyBinding(RelaxDefiniteAssignment,
(options, value) => {
if (!options.Get(EnforceDeterminism)) {
options.DefiniteAssignmentLevel = value ? 1 : 4;
}
});
DooFile.RegisterLibraryChecks(
new Dictionary<Option, DooFile.OptionCheck>() {
{ UnicodeCharacters, DooFile.CheckOptionMatches },
{ EnforceDeterminism, DooFile.CheckOptionLocalImpliesLibrary },
{ RelaxDefiniteAssignment, DooFile.CheckOptionLibraryImpliesLocal },
{ ReadsClausesOnMethods, DooFile.CheckOptionLocalImpliesLibrary },
}
);
DooFile.RegisterNoChecksNeeded(
Check,
Libraries,
Output,
PluginOption,
Prelude,
Target,
Verbose,
WarnDeprecation,
FormatPrint,
JsonDiagnostics,
QuantifierSyntax,
SpillTranslation,
StdIn,
TestAssumptions,
WarnShadowing,
ManualLemmaInduction,
TypeInferenceDebug,
GeneralTraits,
TypeSystemRefresh,
VerificationLogFormat,
VerifyIncludedFiles,
WarningAsErrors,
DisableNonLinearArithmetic,
NewTypeInferenceDebug,
UseBaseFileName,
WarnMissingConstructorParenthesis,
UseJavadocLikeDocstringRewriterOption,
IncludeRuntimeOption,
InternalIncludeRuntimeOptionForExecution,
WarnContradictoryAssumptions,
WarnRedundantAssumptions,
VerificationCoverageReport,
NoTimeStampForCoverageReport,
DefaultFunctionOpacity,
UseStandardLibraries,
OptimizeErasableDatatypeWrapper,
AddCompileSuffix,
SystemModule,
ExecutionCoverageReport
);
}
public static readonly Option<bool> FormatPrint = new("--print",
@"Print Dafny program to stdout after formatting it instead of altering the files.") {
};
}