diff options
Diffstat (limited to 'boot/type_check.cc')
| -rw-r--r-- | boot/type_check.cc | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/boot/type_check.cc b/boot/type_check.cc index 529f66a..78e975a 100644 --- a/boot/type_check.cc +++ b/boot/type_check.cc @@ -174,25 +174,26 @@ namespace elna::boot { switch (payload) { - case kind::record_base: + using enum kind; + case record_base: return "Expected a record type, but got '" + this->actual.to_string() + "'"; - case kind::for_range: + case for_range: return "Expected an array or slice type, but got '" + this->actual.to_string() + "'"; - case kind::condition: + case condition: return "Condition must be a boolean expression, but got '" + this->actual.to_string() + "'"; - case kind::constant_assignment: + case constant_assignment: return "Cannot assign to a value of type '" + this->actual.to_string() + "', because it is constant or contains constant members"; - case kind::array_index: + case array_index: return "Array index must be an integral type, but got '" + this->actual.to_string() + "'"; - case kind::non_indexable: + case non_indexable: return "Indexing is not allowed on type '" + this->actual.to_string() + "'"; - case kind::dereference_of_non_pointer: + case dereference_of_non_pointer: return "Type '" + this->actual.to_string() + "' cannot be dereferenced, it is not a pointer"; default: @@ -422,17 +423,24 @@ namespace elna::boot bool assign_check::run() { - for (auto handler : {&assign_check::guard_const_laundering, - &assign_check::check_exact_match, - &assign_check::check_slice_conversion, - &assign_check::check_pointer_hatch, - &assign_check::check_pointer_conversion}) + auto const assign_handlers = { + &assign_check::guard_const_laundering, + &assign_check::check_exact_match, + &assign_check::check_slice_conversion, + &assign_check::check_pointer_hatch, + &assign_check::check_pointer_conversion + }; + for (auto handler : assign_handlers) { switch ((this->*handler)()) { - case verdict::accept: return true; - case verdict::reject: return false; - case verdict::pass:; + using enum verdict; + case accept: + return true; + case reject: + return false; + case pass: + break; } } return false; @@ -441,11 +449,11 @@ namespace elna::boot bool type_analysis_visitor::is_assignable_from(const type& assignee, const type& assignment) { return assign_check{ - resolve_aliases(assignee), - resolve_aliases(assignment), - resolve_underlying_type(assignee), - resolve_underlying_type(assignment) - }.run(); + resolve_aliases(assignee), + resolve_aliases(assignment), + resolve_underlying_type(assignee), + resolve_underlying_type(assignment) + }.run(); } type_analysis_visitor::type_analysis_visitor(symbol_bag bag, const target_info& target) @@ -893,7 +901,7 @@ namespace elna::boot switch (operation) { - using enum binary_operator; + using enum binary_operator; case sum: valid = (is_any_pointer_type(lhs_resolved) && is_integral_type(rhs_resolved)) || (is_integral_type(lhs_resolved) && is_any_pointer_type(rhs_resolved)) |
