-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathEngineOptions.v3
66 lines (62 loc) · 1.94 KB
/
EngineOptions.v3
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
// Copyright 2021 Ben L. Titzer. All rights reserved.
// See LICENSE for details of Apache 2.0 license.
// Parses command-line options that configure an engine.
component EngineOptions {
var group = OptionsRegistry.newGroup("ENGINE", printHelp);
var extensions: Extension.set;
def DEFAULT_STACK_SIZE = 512u * 1024u;
def STACK_SIZE = group.newSizeOption("stack-size", DEFAULT_STACK_SIZE, "Initial stack size in bytes for Wasm execution stacks.");
def JIT_FILTER = group.newDeclFilterOption("jit-filter", "Filters functions compiled by the JIT.");
def X_ = OptionsRegistry.addParseFunc(parse);
def parse(arg: string, err: ErrorGen) -> bool {
if (Strings.startsWith(arg, "-ext:")) {
if (Strings.endsWithFrom(arg, 5, "all")) {
extensions = Extension.set.all;
return true;
}
for (e in Extension) {
if (Strings.endsWithFrom(arg, 5, e.short_name)) {
extensions |= Extensions.setImplications(e);
return true;
}
}
}
if (Strings.startsWith(arg, "-mode=")) {
return ExecuteOptions.setMode(arg[6 ...]);
}
return false;
}
def printHelp(out: TraceBuilder) {
var H = out.putsln, L = out.ln;
H("Wizard supports a number of engine-wide options which enable extensions and configure");
H("the execution mode. Each extension can be enabled independently with its own flag.");
H("Some extensions imply other extensions as indicated below.");
L();
for (e in Extension) {
out.puts(" -ext:");
out.puts(e.short_name);
out.pad(' ', 32);
out.puts(e.help);
out.ln();
var set: Extension.set = e;
var none: Extension.set;
set = Extensions.setImplications(set) - e;
if (set != none) {
out.puts(" implies: ");
var first = true;
for (e in set) {
if (!first) out.csp();
out.puts(e.short_name);
first = false;
}
out.ln();
}
}
L();
ExecuteOptions.printHelp(out);
L();
H("Other engine configuration options include:");
L();
group.print(out, false);
}
}