-
Notifications
You must be signed in to change notification settings - Fork 30
/
JLangOptions.java
80 lines (66 loc) · 2.42 KB
/
JLangOptions.java
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
//Copyright (C) 2018 Cornell University
package jlang;
import polyglot.ext.jl5.JL5Options;
import polyglot.main.OptFlag;
import polyglot.main.UsageError;
import java.util.Set;
public class JLangOptions extends JL5Options {
public String entryPointClass;
public boolean entryPointEmitted;
public boolean printDesugar;
public int maxPasses;
public JLangOptions(JLangExtensionInfo extension) {
super(extension);
this.setOutputExtension("ll");
}
@Override
protected void populateFlags(Set<OptFlag<?>> flags) {
//Add the ox flag before the super call to ensure the correct default ("ll") is used.
flags.add(new OptFlag<String>("-ox", "<ext>", "set output extension") {
@Override
public Arg<String> handle(String[] args, int index) {
return createArg(index + 1, args[index]);
}
@Override
public Arg<String> defaultArg() {
return createDefault("ll");
}
});
super.populateFlags(flags);
flags.add(new OptFlag<String>(
"-entry-point", "<classname>",
"Fully qualified main class to call") {
@Override
public Arg<String> handle(String[] args, int index) {
return createArg(index + 1, args[index]);
}
@Override
public Arg<String> defaultArg() {
return createDefault(this.defaultValue);
}
});
flags.add(new OptFlag.Switch(
"-dump-desugared", "Print the desugared AST to stderr", true));
flags.add(new OptFlag.IntFlag("-max-runs", "<number of total compiler runs>",
"An upper bound on the number of total compiler runs"
+ " which ~ 7 * num_input_files") {
@Override
public Arg<Integer> defaultArg() {
return createDefault(-1);
}
});
}
@Override
protected void handleArg(OptFlag.Arg<?> arg) throws UsageError {
if (arg.flag().ids().contains("-entry-point")) {
this.entryPointClass = (String) arg.value();
}
else if (arg.flag().ids().contains("-dump-desugared")) {
this.printDesugar = (Boolean) arg.value();
}
else if (arg.flag().ids().contains("-max-runs")) {
this.maxPasses = (Integer) arg.value();
}
else super.handleArg(arg);
}
}