Skip to content
← Back

src/semantic/capability_checker.ghul

1
namespace Semantic is
2
use Logging
3
use Source
4
5
// Checks a use of a feature against what the target supports, and
6
// reports the uses it does not. Every check for every feature goes
7
// through check, so the diagnostics all say the same thing in the same
8
// shape.
9
class CAPABILITY_CHECKER is
10
_capabilities: TargetCapabilities
11
_logger: Logger
12
13
init(capabilities: TargetCapabilities, logger: Logger) is
14
_capabilities = capabilities
15
_logger = logger
16
si
17
18
// Whether the target supports `capability`. A use it does not is
19
// reported at `location`, naming the use `feature`.
20
check(capability: Capability, location: LOCATION, feature: string) -> bool is
21
if _capabilities.is_supported(capability) then
22
return true
23
fi
24
25
_logger.error(
26
location,
27
"{feature} not supported on the {_capabilities.target_name} target")
28
29
return false
30
si
31
si
32
si