Skip to content
← Back

src/compiler/build_flags.ghul

1
namespace Compiler is
2
use IO.Std
3
4
// Accessibility policy for underscore-prefixed declarations. LEGACY keeps
5
// the historic emission (methods public, fields assembly, types public).
6
// PRIVATE and PROTECTED both make underscore members and types invisible
7
// outside the assembly; they differ only in whether a subclass in the same
8
// assembly can see them.
9
enum UnderscoreAccess is
10
LEGACY, PRIVATE, PROTECTED
11
si
12
13
class GLOBAL_BUILD_FLAGS is
14
is_valid: bool
15
16
underscore_access: UnderscoreAccess public
17
18
_logger: Logging.Logger?
19
20
want_analyse: bool public
21
want_debug: bool public
22
want_declare_symbols: bool public
23
want_compile_up_to_expressions: bool public
24
want_compile_expressions: bool public
25
want_executable: bool public
26
// Set by `--library`: emit a DLL rather than an EXE, and
27
// require no entry point.
28
want_library: bool public
29
want_assembler: bool public
30
want_analysis_stats: bool public
31
32
// The definite-return / definite-assignment / possible-null-
33
// dereference / non-optional-by-default flow warnings are on
34
// by default. Each `no_warn_*` getter consults the logger's
35
// suppression set, populated by `--no-warn-*` and `--suppress`
36
// CLI flags (both routes feed the same set).
37
no_warn_definite_return: bool => _logger? /\ _logger.is_suppressed("definite-return")
38
no_warn_definite_assignment: bool => _logger? /\ _logger.is_suppressed("definite-assignment")
39
no_warn_field_definite_assignment: bool => _logger? /\ _logger.is_suppressed("field-definite-assignment")
40
no_warn_non_optional: bool => _logger? /\ _logger.is_suppressed("non-optional")
41
no_warn_impossible_cast: bool => _logger? /\ _logger.is_suppressed("impossible-cast")
42
no_warn_cast_may_throw: bool => _logger? /\ _logger.is_suppressed("cast-may-throw")
43
no_warn_narrowing_always_succeeds: bool => _logger? /\ _logger.is_suppressed("narrowing-always-succeeds")
44
no_warn_irrefutable_destructure: bool => _logger? /\ _logger.is_suppressed("irrefutable-destructure")
45
no_warn_likely_override_mismatch: bool => _logger? /\ _logger.is_suppressed("likely-override-mismatch")
46
no_warn_redundant_unwrap: bool => _logger? /\ _logger.is_suppressed("redundant-unwrap")
47
no_warn_impure_function_value: bool => _logger? /\ _logger.is_suppressed("impure-function-value")
48
no_warn_impure_function_argument: bool => _logger? /\ _logger.is_suppressed("impure-function-argument")
49
ignore_errors: bool public
50
exclude_runtime_symbols: bool public
51
is_test_run: bool public
52
53
// Report every diagnostic a pass makes, including ones that
54
// repeat another exactly. On for a test run, and separately
55
// available so a test of the analyser can ask for it.
56
keep_duplicate_diagnostics: bool public
57
58
// Emit diagnostics in MSBuild's canonical error format
59
// (see the `--msbuild-diagnostics` driver flag). MSBuild parses
60
// that shape and nothing else, so without it a build reports the
61
// compiler's own diagnostics as untyped message text and counts
62
// only the non-zero exit as an error.
63
want_msbuild_diagnostics: bool public
64
65
// Suppresses the analysis-mode heap watchdog's post-compile heap
66
// sampling (see the `--no-analysis-heap-watchdog` driver flag). The
67
// sampling forces a full GC after every compile; turning it off is
68
// useful when profiling the analyser.
69
no_analysis_heap_watchdog: bool public
70
71
// Opts into the incremental body re-walk for interface-preserving
72
// single-file EDITs. On by default; `--no-incremental-analysis`
73
// turns it off.
74
want_incremental_analysis: bool public
75
76
// Seconds an analyser may sit with no request before exiting (see
77
// `--analysis-idle-timeout`); 0 disables it. A warm analyser retains
78
// the whole symbol table, so an editor window left open overnight
79
// holds hundreds of megabytes to answer nothing; the cold rebuild
80
// the next request pays is the cheaper side of that trade. Only
81
// consulted in analysis mode, where the process is long-lived.
82
analysis_idle_timeout_seconds: int public
83
84
// Aggregates definitions outside any namespace into a single unnamed
85
// global namespace shared across every file, rather than the default
86
// per-file private namespace (see `--global-namespace`). Off by
87
// default, so each file's global definitions stay file-private.
88
want_global_namespace: bool public
89
90
// The name of the namespace a file with no namespace of its own
91
// is given, in place of one derived from the file's path, and
92
// the mark of a submission: one step of an interactive session,
93
// compiled as a library whose entry returns the value of its
94
// final expression (see `--submission`). Null otherwise.
95
submission_name: string? public
96
97
// The imports `use default` stands for, when the project names
98
// its own set with `--default-use`. Empty leaves the curated set
99
// in `DEFAULT_USES` in force.
100
default_uses: Collections.LIST[string] public
101
102
// Gives every file with no namespace of its own an implicit
103
// `use default`, as if the file had written it first (see
104
// `--implicit-default-use`). A script run directly wants this;
105
// a project, whose files choose their own imports, does not.
106
want_implicit_default_use: bool public
107
108
// Default idle timeout, in seconds. Long enough that a user stepping
109
// away from an editor and coming back rarely pays the cold rebuild,
110
// short enough that an abandoned window gives its memory back within
111
// the hour.
112
default_analysis_idle_timeout_seconds: int static => 1800
113
114
init() is
115
underscore_access = UnderscoreAccess.PRIVATE
116
analysis_idle_timeout_seconds = default_analysis_idle_timeout_seconds
117
want_incremental_analysis = true
118
default_uses = Collections.LIST[string]()
119
si
120
121
set_logger(logger: Logging.Logger) is
122
_logger = logger
123
si
124
125
mark_valid() is
126
is_valid = true
127
si
128
129
check_valid() is
130
assert is_valid else "build flags accessed before being set"
131
si
132
si
133
si