es_builtin for type, type utils state fixes

This commit is contained in:
ProgramSnail 2024-01-03 21:55:24 +03:00
parent f03f77191f
commit ffa9c47107
3 changed files with 63 additions and 27 deletions

View file

@ -120,8 +120,8 @@ nodes::TypeCheckResult type_check_loop(const nodes::Loop &expression,
return condition_result.value();
}
if (condition_result.value().get().get()->to_builtin() !=
builtin::types::Type::BOOL) {
if (!condition_result.value().get().get()->is_builtin(
builtin::types::Type::BOOL)) {
sources_manager.get_error_log()->add_error(
error_handling::ErrorLog::ErrorMessage(
*expression.get_condition().value(),
@ -145,8 +145,9 @@ nodes::TypeCheckResult type_check_loop(const nodes::Loop &expression,
}
// // TODO ??
// if (variable_result.value().get().get_type()->to_builtin() !=
// builtin::types::Type::BOOL) {
// if
// (!variable_result.value().get().get_type()->is_builtin(builtin::types::Type::BOOL))
// {
// sources_manager.get_error_log()->add_error(
// error_handling::ErrorLog::ErrorMessage(
// *expression.get_condition().value(),
@ -156,8 +157,8 @@ nodes::TypeCheckResult type_check_loop(const nodes::Loop &expression,
// }
// TODO: ranges ??
if (condition_result.value().get().get()->to_builtin() !=
builtin::types::Type::ARRAY) {
if (!condition_result.value().get().get()->is_builtin(
builtin::types::Type::ARRAY)) {
sources_manager.get_error_log()->add_error(
error_handling::ErrorLog::ErrorMessage(
*expression.get_condition().value(),
@ -231,10 +232,10 @@ nodes::TypeCheckResult type_check_container(const nodes::Container &expression,
const Arguments &arguments) {
switch (expression.get_type()) {
case nodes::Container::ARRAY:
return type_check_array(expression, sources_manager, state);
return type_check_array(expression, sources_manager, state, arguments);
case nodes::Container::BLOCK:
return type_check_block(expression, sources_manager,
state); // TODO: check that expression brought
state, arguments); // TODO: check that expression brought
// type are same, -> brought_type
}
} // IN PROGRESS
@ -303,7 +304,7 @@ nodes::TypeCheckResult type_check_array_access(const nodes::Access &expression,
return value_result;
}
if (index_result.get().get()->to_builtin() != builtin::types::Type::INDEX) {
if (!index_result.get().get()->is_builtin(builtin::types::Type::INDEX)) {
sources_manager.get_error_log()->add_error(
error_handling::ErrorLog::ErrorMessage(
expression, "Can access only by Index",
@ -311,7 +312,7 @@ nodes::TypeCheckResult type_check_array_access(const nodes::Access &expression,
return nodes::TypeCheckResult::construct_invalid_result();
}
if (value_result.get().get()->to_builtin() != builtin::types::Type::ARRAY) {
if (!value_result.get().get()->is_builtin(builtin::types::Type::ARRAY)) {
sources_manager.get_error_log()->add_error(
error_handling::ErrorLog::ErrorMessage(
expression, "Can apply array access only to Array",
@ -342,7 +343,7 @@ nodes::TypeCheckResult type_check_tuple_access(const nodes::Access &expression,
->get<size_t>() // Index type
.value();
if (value_result.get().get()->to_builtin() != builtin::types::Type::TUPLE) {
if (!value_result.get().get()->is_builtin(builtin::types::Type::TUPLE)) {
sources_manager.get_error_log()->add_error(
error_handling::ErrorLog::ErrorMessage(
expression, "Can apply tuple access only to Tuple",