Implement the sizeof operator

This commit is contained in:
2025-01-29 12:55:52 +01:00
parent be1a56a557
commit 5178027d9f
7 changed files with 106 additions and 12 deletions

View File

@ -67,6 +67,13 @@ namespace gcc
cast_target, this->current_expression);
}
void generic_visitor::visit(source::size_of_expression *expression)
{
auto body_type = build_type(expression->body());
this->current_expression = build1(CONVERT_EXPR, integer_type_node, TYPE_SIZE_UNIT(body_type));
}
void generic_visitor::visit(source::program *program)
{
for (const auto definition : program->value_definitions)