Implement shift operators

This commit is contained in:
2025-02-15 00:38:46 +01:00
parent ee4ebf64b9
commit 82b3806fd2
7 changed files with 53 additions and 23 deletions

View File

@ -575,10 +575,11 @@ namespace gcc
}
if (left_type != right_type
&& !are_compatible_pointers(left_type, right)
&& !are_compatible_pointers(right_type, left))
&& !are_compatible_pointers(right_type, left)
&& !(is_integral_type(left_type) && right_type == elna_word_type_node))
{
error_at(expression_location,
"invalid operands of type %s and %s for operator %s",
"invalid operands of type '%s' and '%s' for operator %s",
print_type(left_type).c_str(), print_type(right_type).c_str(),
boot::print_binary_operator(expression->operation()));
this->current_expression = error_mark_node;
@ -628,6 +629,16 @@ namespace gcc
case boot::binary_operator::not_equals:
this->current_expression = build_equality_operation(expression, left, right);
break;
case boot::binary_operator::shift_left:
this->current_expression = build_binary_operation(
is_numeric_type(left_type) && right_type == elna_word_type_node,
expression, LSHIFT_EXPR, left, right, left_type);
break;
case boot::binary_operator::shift_right:
this->current_expression = build_binary_operation(
is_numeric_type(left_type) && right_type == elna_word_type_node,
expression, RSHIFT_EXPR, left, right, left_type);
break;
}
}