diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-01-05 13:38:14 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-01-05 14:26:53 +0200 |
| commit | 01dba1c054724b4957778932fb5cd0df14d214b3 (patch) | |
| tree | 4344dda57656bebd2d548f5628843cf5194d4d6f /src/Module.zig | |
| parent | 0ecec5fcca3ae8f33bf307c2ca66b8d11baf3d1d (diff) | |
| download | zig-01dba1c054724b4957778932fb5cd0df14d214b3.tar.gz zig-01dba1c054724b4957778932fb5cd0df14d214b3.zip | |
Sema: add system for checking backend feature support
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig index 9c7d3ee885..24047f8798 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -6749,3 +6749,25 @@ pub fn getDeclExports(mod: Module, decl_index: Decl.Index) []const *Export { return &[0]*Export{}; } } + +pub const Feature = enum { + panic_fn, + panic_unwrap_error, + safety_check_formatted, + error_return_trace, + is_named_enum_value, + error_set_has_value, +}; + +pub fn backendSupportsFeature(mod: Module, feature: Feature) bool { + return switch (feature) { + .panic_fn => mod.comp.bin_file.options.target.ofmt == .c or + mod.comp.bin_file.options.use_llvm, + .panic_unwrap_error => mod.comp.bin_file.options.target.ofmt == .c or + mod.comp.bin_file.options.use_llvm, + .safety_check_formatted => mod.comp.bin_file.options.use_llvm, + .error_return_trace => mod.comp.bin_file.options.use_llvm, + .is_named_enum_value => mod.comp.bin_file.options.use_llvm, + .error_set_has_value => mod.comp.bin_file.options.use_llvm, + }; +} |
