diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-08-14 23:14:38 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-08-14 23:14:38 +0200 |
| commit | 33ae72a3c73f6219be86715e8da71ed345f6077c (patch) | |
| tree | 1c6c98be816508e9231fa1ada3f79ec940ab1cf1 /boot/type_check.cc | |
| parent | d696abc97143061bf2abb05922188e12b59306c1 (diff) | |
| download | elna-33ae72a3c73f6219be86715e8da71ed345f6077c.tar.gz | |
Map Int and Word to hardware word sizes
Diffstat (limited to 'boot/type_check.cc')
| -rw-r--r-- | boot/type_check.cc | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/boot/type_check.cc b/boot/type_check.cc index 07e563f..e58a50e 100644 --- a/boot/type_check.cc +++ b/boot/type_check.cc @@ -90,7 +90,7 @@ namespace elna::boot trait_error::trait_error(const source_position position, const std::string& trait_name, payload_type payload) - : error(position), trait_name(trait_name), payload(std::move(payload)) + : diagnostic(position), trait_name(trait_name), payload(std::move(payload)) { } @@ -115,7 +115,7 @@ namespace elna::boot type_mismatch_error::type_mismatch_error(const source_position position, type actual, payload_type payload) - : error(position), actual(std::move(actual)), payload(std::move(payload)) + : diagnostic(position), actual(std::move(actual)), payload(std::move(payload)) { } @@ -158,11 +158,6 @@ namespace elna::boot return "Type '" + this->actual.to_string() + "' cannot be converted to '" + payload.target.to_string() + "'"; } - else if constexpr (std::is_same_v<T, integer_literal_overflow>) - { - return "The number " + payload.overflow.to_string() - + " does not fit into the type '" + actual.to_string() + "'"; - } else if constexpr (std::is_same_v<T, constant_assignment>) { return "Cannot assign to a value of type '" + this->actual.to_string() @@ -173,7 +168,7 @@ namespace elna::boot type_requirement_error::type_requirement_error(const source_position position, type actual, kind kind) - : error(position), actual(std::move(actual)), m_kind(kind) + : diagnostic(position), actual(std::move(actual)), m_kind(kind) { } @@ -207,7 +202,7 @@ namespace elna::boot cyclic_declaration_error::cyclic_declaration_error(const source_position position, const std::vector<std::string>& cycle) - : error(position), cycle(cycle) + : diagnostic(position), cycle(cycle) { } @@ -226,7 +221,7 @@ namespace elna::boot argument_count_error::argument_count_error(const source_position position, kind kind, std::string applicand, std::size_t expected, std::size_t actual) - : error(position), m_kind(kind), applicand(std::move(applicand)), expected(expected), actual(actual) + : diagnostic(position), m_kind(kind), applicand(std::move(applicand)), expected(expected), actual(actual) { } @@ -1059,21 +1054,4 @@ namespace elna::boot } } - void type_analysis_visitor::visit(literal<integer_literal> *expression) - { - bool narrowed{ false }; - if (expression->value.is_signed()) - { - narrowed = expression->value.fit_into(target.int_properties.front().size); - } - else - { - narrowed = expression->value.fit_into(target.word_properties.front().size); - } - if (!narrowed) - { - add_error<type_mismatch_error>(expression->position(), expression->type_decoration, - type_mismatch_error::integer_literal_overflow{ expression->value }); - } - } } |
