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`: link with `ilasm -DLL` and require no entry
27
// point, for library assemblies. Distinct from `want_assembler`
28
// (`-S`), which emits IL and stops before linking at all.
29
want_library: bool public;
30
want_assembler: bool public;
31
want_keep_out_il: bool public;
32
want_library_boilerplate: bool public;
33
want_analysis_stats: bool public;
34
35
// The definite-return / definite-assignment / possible-null-
36
// dereference / non-optional-by-default flow warnings are on
37
// by default. Each `no_warn_*` getter consults the logger's
38
// suppression set, populated by `--no-warn-*` and `--suppress`
39
// CLI flags (both routes feed the same set).
40
no_warn_definite_return: bool => _logger? /\ _logger.is_suppressed("definite-return");
41
no_warn_definite_assignment: bool => _logger? /\ _logger.is_suppressed("definite-assignment");
42
no_warn_null_deref: bool => _logger? /\ _logger.is_suppressed("null-deref");
43
no_warn_non_optional: bool => _logger? /\ _logger.is_suppressed("non-optional");
44
no_warn_impossible_cast: bool => _logger? /\ _logger.is_suppressed("impossible-cast");
45
no_warn_cast_may_throw: bool => _logger? /\ _logger.is_suppressed("cast-may-throw");
46
no_warn_narrowing_always_succeeds: bool => _logger? /\ _logger.is_suppressed("narrowing-always-succeeds");
47
no_warn_likely_override_mismatch: bool => _logger? /\ _logger.is_suppressed("likely-override-mismatch");
48
no_warn_redundant_unwrap: bool => _logger? /\ _logger.is_suppressed("redundant-unwrap");
49
no_warn_impure_function_value: bool => _logger? /\ _logger.is_suppressed("impure-function-value");
50
ignore_errors: bool public;
51
exclude_runtime_symbols: bool public;
52
is_test_run: bool public;
53
54
// Suppresses the analysis-mode heap watchdog's post-compile heap
55
// sampling (see the `--no-analysis-heap-watchdog` driver flag). The
56
// sampling forces a full GC after every compile; turning it off is
57
// useful when profiling the analyser.
58
no_analysis_heap_watchdog: bool public;
59
60
// Opts into the incremental body re-walk for interface-preserving
61
// single-file EDITs (see `--incremental-analysis`). Off by default.
62
want_incremental_analysis: bool public;
63
64
// Aggregates definitions outside any namespace into a single unnamed
65
// global namespace shared across every file, rather than the default
66
// per-file private namespace (see `--global-namespace`). Off by
67
// default, so each file's global definitions stay file-private.
68
want_global_namespace: bool public;
69
70
init() is
71
underscore_access = UnderscoreAccess.PRIVATE;
72
si
73
74
set_logger(logger: Logging.Logger) is
75
_logger = logger;
76
si
77
78
mark_valid() is
79
is_valid = true;
80
si
81
82
check_valid() is
83
assert is_valid else "build flags accessed before being set";
84
si
85
si
86
si