aboutsummaryrefslogtreecommitdiff
path: root/gcc/elna-generic.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-07-03 11:09:44 +0200
committerEugen Wissner <belka@caraus.de>2026-07-03 11:09:44 +0200
commitb6b68b25043fc4008af6c7bfb4573593a858a9de (patch)
tree4fdf4a1fc8030993f0fe3fe9829337c6548f212a /gcc/elna-generic.cc
parentd9cd03ffeb13a5c30d8337ba27f15e1ba2959e4d (diff)
downloadelna-b6b68b25043fc4008af6c7bfb4573593a858a9de.tar.gz
Rename frontend to boot(strap)HEADcpp
Diffstat (limited to 'gcc/elna-generic.cc')
-rw-r--r--gcc/elna-generic.cc170
1 files changed, 85 insertions, 85 deletions
diff --git a/gcc/elna-generic.cc b/gcc/elna-generic.cc
index a5aa5f5..66bd9a2 100644
--- a/gcc/elna-generic.cc
+++ b/gcc/elna-generic.cc
@@ -35,13 +35,13 @@ along with GCC; see the file COPYING3. If not see
namespace elna::gcc
{
- generic_visitor::generic_visitor(std::shared_ptr<symbol_table> symbol_table, elna::frontend::symbol_bag bag)
+ generic_visitor::generic_visitor(std::shared_ptr<symbol_table> symbol_table, boot::symbol_bag bag)
: bag(bag), symbols(symbol_table)
{
}
void generic_visitor::build_procedure_call(location_t call_location,
- tree procedure_address, const std::vector<frontend::expression *>& arguments)
+ tree procedure_address, const std::vector<boot::expression *>& arguments)
{
vec<tree, va_gc> *argument_trees = nullptr;
tree symbol_type = TREE_TYPE(TREE_TYPE(procedure_address));
@@ -49,7 +49,7 @@ namespace elna::gcc
tree current_parameter = TYPE_ARG_TYPES(symbol_type);
vec_alloc(argument_trees, arguments.size());
- for (frontend::expression *const argument : arguments)
+ for (boot::expression *const argument : arguments)
{
location_t argument_location = get_location(&argument->position());
if (VOID_TYPE_P(TREE_VALUE(current_parameter)))
@@ -88,11 +88,11 @@ namespace elna::gcc
}
void generic_visitor::build_record_call(location_t call_location,
- tree symbol, const std::vector<frontend::expression *>& arguments)
+ tree symbol, const std::vector<boot::expression *>& arguments)
{
vec<constructor_elt, va_gc> *tree_arguments = nullptr;
tree record_fields = TYPE_FIELDS(symbol);
- for (frontend::expression *const argument : arguments)
+ for (boot::expression *const argument : arguments)
{
location_t argument_location = get_location(&argument->position());
@@ -129,7 +129,7 @@ namespace elna::gcc
}
void generic_visitor::build_assert_builtin(location_t call_location,
- const std::vector<frontend::expression *>& arguments)
+ const std::vector<boot::expression *>& arguments)
{
if (arguments.size() != 1)
{
@@ -165,11 +165,11 @@ namespace elna::gcc
}
}
- bool generic_visitor::build_builtin_procedures(frontend::procedure_call *call)
+ bool generic_visitor::build_builtin_procedures(boot::procedure_call *call)
{
location_t call_location = get_location(&call->position());
- if (frontend::named_expression *named_call = call->callable().is_named())
+ if (boot::named_expression *named_call = call->callable().is_named())
{
if (named_call->name == "assert")
{
@@ -180,7 +180,7 @@ namespace elna::gcc
return false;
}
- void generic_visitor::visit(frontend::procedure_call *call)
+ void generic_visitor::visit(boot::procedure_call *call)
{
if (build_builtin_procedures(call))
{
@@ -215,7 +215,7 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::cast_expression *expression)
+ void generic_visitor::visit(boot::cast_expression *expression)
{
tree cast_target = get_inner_alias(expression->expression_type, this->symbols->scope());
@@ -235,9 +235,9 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::program *program)
+ void generic_visitor::visit(boot::program *program)
{
- visit(static_cast<frontend::unit *>(program));
+ visit(static_cast<boot::unit *>(program));
tree declaration_type = build_function_type_list(elna_int_type_node,
elna_int_type_node,
@@ -285,27 +285,27 @@ namespace elna::gcc
cgraph_node::finalize_function(fndecl, true);
}
- void generic_visitor::visit(frontend::unit *unit)
+ void generic_visitor::visit(boot::unit *unit)
{
- for (frontend::import_declaration *const declaration : unit->imports)
+ for (boot::import_declaration *const declaration : unit->imports)
{
declaration->accept(this);
}
- for (frontend::constant_declaration *const constant : unit->constants)
+ for (boot::constant_declaration *const constant : unit->constants)
{
constant->accept(this);
}
- for (frontend::variable_declaration *const variable : unit->variables)
+ for (boot::variable_declaration *const variable : unit->variables)
{
variable->accept(this);
}
- for (frontend::procedure_declaration *const procedure : unit->procedures)
+ for (boot::procedure_declaration *const procedure : unit->procedures)
{
procedure->accept(this);
}
}
- void generic_visitor::visit(frontend::procedure_declaration *definition)
+ void generic_visitor::visit(boot::procedure_declaration *definition)
{
tree fndecl = this->symbols->lookup(definition->identifier.name);
@@ -324,11 +324,11 @@ namespace elna::gcc
{
this->symbols->enter(IDENTIFIER_POINTER(DECL_NAME(argument_chain)), argument_chain);
}
- for (frontend::constant_declaration *const constant : definition->body.value().constants())
+ for (boot::constant_declaration *const constant : definition->body.value().constants())
{
constant->accept(this);
}
- for (frontend::variable_declaration *const variable : definition->body.value().variables())
+ for (boot::variable_declaration *const variable : definition->body.value().variables())
{
variable->accept(this);
}
@@ -381,17 +381,17 @@ namespace elna::gcc
return bind_expr;
}
- void generic_visitor::visit(frontend::literal<std::int32_t> *literal)
+ void generic_visitor::visit(boot::literal<std::int32_t> *literal)
{
this->current_expression = build_int_cst(elna_int_type_node, literal->value);
}
- void generic_visitor::visit(frontend::literal<std::uint32_t> *literal)
+ void generic_visitor::visit(boot::literal<std::uint32_t> *literal)
{
this->current_expression = build_int_cstu(elna_word_type_node, literal->value);
}
- void generic_visitor::visit(frontend::literal<double> *literal)
+ void generic_visitor::visit(boot::literal<double> *literal)
{
REAL_VALUE_TYPE real_value1;
@@ -406,22 +406,22 @@ namespace elna::gcc
mpfr_clear(number);
}
- void generic_visitor::visit(frontend::literal<bool> *boolean)
+ void generic_visitor::visit(boot::literal<bool> *boolean)
{
this->current_expression = boolean->value ? boolean_true_node : boolean_false_node;
}
- void generic_visitor::visit(frontend::literal<unsigned char> *character)
+ void generic_visitor::visit(boot::literal<unsigned char> *character)
{
this->current_expression = build_int_cstu(elna_char_type_node, character->value);
}
- void generic_visitor::visit(frontend::literal<nullptr_t> *)
+ void generic_visitor::visit(boot::literal<nullptr_t> *)
{
this->current_expression = elna_pointer_nil_node;
}
- void generic_visitor::visit(frontend::literal<std::string> *string)
+ void generic_visitor::visit(boot::literal<std::string> *string)
{
tree index_constant = build_int_cstu(elna_word_type_node, string->value.size());
tree string_type = build_array_type(elna_char_type_node, build_index_type(index_constant));
@@ -444,38 +444,38 @@ namespace elna::gcc
this->current_expression = build_constructor(elna_string_type_node, elms);
}
- tree generic_visitor::build_arithmetic_operation(frontend::binary_expression *expression,
+ tree generic_visitor::build_arithmetic_operation(boot::binary_expression *expression,
tree_code operator_code, tree left, tree right)
{
return build_binary_operation(is_numeric_type(TREE_TYPE(left)),
expression, operator_code, left, right, TREE_TYPE(left));
}
- tree generic_visitor::build_comparison_operation(frontend::binary_expression *expression,
+ tree generic_visitor::build_comparison_operation(boot::binary_expression *expression,
tree_code operator_code, tree left, tree right)
{
return build_binary_operation(is_numeric_type(TREE_TYPE(left)) || POINTER_TYPE_P(TREE_TYPE(left)),
expression, operator_code, left, right, elna_bool_type_node);
}
- tree generic_visitor::build_bit_logic_operation(frontend::binary_expression *expression, tree left, tree right)
+ tree generic_visitor::build_bit_logic_operation(boot::binary_expression *expression, tree left, tree right)
{
location_t expression_location = get_location(&expression->position());
tree left_type = TREE_TYPE(left);
tree right_type = TREE_TYPE(right);
tree_code logical_code, bit_code;
- if (expression->operation() == frontend::binary_operator::conjunction)
+ if (expression->operation() == boot::binary_operator::conjunction)
{
bit_code = BIT_AND_EXPR;
logical_code = TRUTH_ANDIF_EXPR;
}
- else if (expression->operation() == frontend::binary_operator::disjunction)
+ else if (expression->operation() == boot::binary_operator::disjunction)
{
bit_code = BIT_IOR_EXPR;
logical_code = TRUTH_ORIF_EXPR;
}
- else if (expression->operation() == frontend::binary_operator::exclusive_disjunction)
+ else if (expression->operation() == boot::binary_operator::exclusive_disjunction)
{
bit_code = BIT_XOR_EXPR;
logical_code = TRUTH_XOR_EXPR;
@@ -496,22 +496,22 @@ namespace elna::gcc
{
error_at(expression_location, "Invalid operands of type '%s' and '%s' for operator %s",
print_type(left_type).c_str(), print_type(right_type).c_str(),
- elna::frontend::print_binary_operator(expression->operation()));
+ boot::print_binary_operator(expression->operation()));
return error_mark_node;
}
}
- tree generic_visitor::build_equality_operation(frontend::binary_expression *expression, tree left, tree right)
+ tree generic_visitor::build_equality_operation(boot::binary_expression *expression, tree left, tree right)
{
location_t expression_location = get_location(&expression->position());
tree_code equality_code, combination_code;
- if (expression->operation() == frontend::binary_operator::equals)
+ if (expression->operation() == boot::binary_operator::equals)
{
equality_code = EQ_EXPR;
combination_code = TRUTH_ANDIF_EXPR;
}
- else if (expression->operation() == frontend::binary_operator::not_equals)
+ else if (expression->operation() == boot::binary_operator::not_equals)
{
equality_code = NE_EXPR;
combination_code = TRUTH_ORIF_EXPR;
@@ -545,7 +545,7 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::binary_expression *expression)
+ void generic_visitor::visit(boot::binary_expression *expression)
{
expression->lhs().accept(this);
tree left = this->current_expression;
@@ -558,8 +558,8 @@ namespace elna::gcc
location_t expression_location = get_location(&expression->position());
if ((POINTER_TYPE_P(left_type) || POINTER_TYPE_P(right_type))
- && (expression->operation() == frontend::binary_operator::sum
- || expression->operation() == frontend::binary_operator::subtraction))
+ && (expression->operation() == boot::binary_operator::sum
+ || expression->operation() == boot::binary_operator::subtraction))
{
this->current_expression = do_pointer_arithmetic(expression->operation(),
left, right, expression_location);
@@ -567,7 +567,7 @@ namespace elna::gcc
{
error_at(expression_location,
"invalid operation %s on a pointer and an integral type",
- frontend::print_binary_operator(expression->operation()));
+ boot::print_binary_operator(expression->operation()));
}
else if (TREE_TYPE(this->current_expression) == ssizetype)
{
@@ -583,60 +583,60 @@ namespace elna::gcc
error_at(expression_location,
"invalid operands of type '%s' and '%s' for operator %s",
print_type(left_type).c_str(), print_type(right_type).c_str(),
- frontend::print_binary_operator(expression->operation()));
+ boot::print_binary_operator(expression->operation()));
this->current_expression = error_mark_node;
return;
}
switch (expression->operation())
{
- case frontend::binary_operator::sum:
+ case boot::binary_operator::sum:
this->current_expression = build_arithmetic_operation(expression, PLUS_EXPR, left, right);
break;
- case frontend::binary_operator::subtraction:
+ case boot::binary_operator::subtraction:
this->current_expression = build_arithmetic_operation(expression, MINUS_EXPR, left, right);
break;
- case frontend::binary_operator::division:
+ case boot::binary_operator::division:
this->current_expression = build_arithmetic_operation(expression, TRUNC_DIV_EXPR, left, right);
break;
- case frontend::binary_operator::remainder:
+ case boot::binary_operator::remainder:
this->current_expression = build_arithmetic_operation(expression, TRUNC_MOD_EXPR, left, right);
break;
- case frontend::binary_operator::multiplication:
+ case boot::binary_operator::multiplication:
this->current_expression = build_arithmetic_operation(expression, MULT_EXPR, left, right);
break;
- case frontend::binary_operator::less:
+ case boot::binary_operator::less:
this->current_expression = build_comparison_operation(expression, LT_EXPR, left, right);
break;
- case frontend::binary_operator::greater:
+ case boot::binary_operator::greater:
this->current_expression = build_comparison_operation(expression, GT_EXPR, left, right);
break;
- case frontend::binary_operator::less_equal:
+ case boot::binary_operator::less_equal:
this->current_expression = build_comparison_operation(expression, LE_EXPR, left, right);
break;
- case frontend::binary_operator::greater_equal:
+ case boot::binary_operator::greater_equal:
this->current_expression = build_comparison_operation(expression, GE_EXPR, left, right);
break;
- case frontend::binary_operator::conjunction:
+ case boot::binary_operator::conjunction:
this->current_expression = build_bit_logic_operation(expression, left, right);
break;
- case frontend::binary_operator::disjunction:
+ case boot::binary_operator::disjunction:
this->current_expression = build_bit_logic_operation(expression, left, right);
break;
- case frontend::binary_operator::exclusive_disjunction:
+ case boot::binary_operator::exclusive_disjunction:
this->current_expression = build_bit_logic_operation(expression, left, right);
break;
- case frontend::binary_operator::equals:
+ case boot::binary_operator::equals:
this->current_expression = build_equality_operation(expression, left, right);
break;
- case frontend::binary_operator::not_equals:
+ case boot::binary_operator::not_equals:
this->current_expression = build_equality_operation(expression, left, right);
break;
- case frontend::binary_operator::shift_left:
+ 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 frontend::binary_operator::shift_right:
+ 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);
@@ -644,14 +644,14 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::unary_expression *expression)
+ void generic_visitor::visit(boot::unary_expression *expression)
{
expression->operand().accept(this);
location_t location = get_location(&expression->position());
switch (expression->operation())
{
- case frontend::unary_operator::reference:
+ case boot::unary_operator::reference:
this->current_expression = prepare_rvalue(this->current_expression);
TREE_ADDRESSABLE(this->current_expression) = 1;
this->current_expression = build_fold_addr_expr_with_type_loc(location,
@@ -659,7 +659,7 @@ namespace elna::gcc
build_global_pointer_type(TREE_TYPE(this->current_expression)));
TREE_NO_TRAMPOLINE(this->current_expression) = 1;
break;
- case frontend::unary_operator::negation:
+ case boot::unary_operator::negation:
if (TREE_TYPE(this->current_expression) == elna_bool_type_node)
{
this->current_expression = build1_loc(location, TRUTH_NOT_EXPR,
@@ -677,7 +677,7 @@ namespace elna::gcc
this->current_expression = error_mark_node;
}
break;
- case frontend::unary_operator::minus:
+ case boot::unary_operator::minus:
if (is_integral_type(TREE_TYPE(this->current_expression)))
{
this->current_expression = fold_build1(NEGATE_EXPR, TREE_TYPE(this->current_expression),
@@ -692,7 +692,7 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::constant_declaration *definition)
+ void generic_visitor::visit(boot::constant_declaration *definition)
{
location_t definition_location = get_location(&definition->position());
definition->body().accept(this);
@@ -732,7 +732,7 @@ namespace elna::gcc
this->current_expression = NULL_TREE;
}
- void generic_visitor::visit(frontend::variable_declaration *declaration)
+ void generic_visitor::visit(boot::variable_declaration *declaration)
{
for (const auto& variable_identifier : declaration->identifiers)
{
@@ -784,7 +784,7 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::named_expression *expression)
+ void generic_visitor::visit(boot::named_expression *expression)
{
auto symbol = this->symbols->lookup(expression->name);
@@ -800,7 +800,7 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::array_access_expression *expression)
+ void generic_visitor::visit(boot::array_access_expression *expression)
{
expression->base().accept(this);
tree designator = this->current_expression;
@@ -829,7 +829,7 @@ namespace elna::gcc
tree string_ptr = build3_loc(location, COMPONENT_REF, TREE_TYPE(elna_string_ptr_field_node),
designator, elna_string_ptr_field_node, NULL_TREE);
- tree target_pointer = do_pointer_arithmetic(frontend::binary_operator::sum, string_ptr, offset, location);
+ tree target_pointer = do_pointer_arithmetic(boot::binary_operator::sum, string_ptr, offset, location);
this->current_expression = build1_loc(location, INDIRECT_REF,
elna_char_type_node, target_pointer);
@@ -842,7 +842,7 @@ namespace elna::gcc
}
}
- bool generic_visitor::expect_trait_type_only(frontend::traits_expression *trait)
+ bool generic_visitor::expect_trait_type_only(boot::traits_expression *trait)
{
if (trait->parameters.size() != 1)
{
@@ -856,7 +856,7 @@ namespace elna::gcc
return this->current_expression != error_mark_node;
}
- bool generic_visitor::expect_trait_for_integral_type(frontend::traits_expression *trait)
+ bool generic_visitor::expect_trait_for_integral_type(boot::traits_expression *trait)
{
if (!expect_trait_type_only(trait))
{
@@ -872,7 +872,7 @@ namespace elna::gcc
return true;
}
- void generic_visitor::visit(frontend::traits_expression *trait)
+ void generic_visitor::visit(boot::traits_expression *trait)
{
location_t trait_location = get_location(&trait->position());
@@ -945,7 +945,7 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::field_access_expression *expression)
+ void generic_visitor::visit(boot::field_access_expression *expression)
{
expression->base().accept(this);
location_t expression_location = get_location(&expression->position());
@@ -991,7 +991,7 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::dereference_expression *expression)
+ void generic_visitor::visit(boot::dereference_expression *expression)
{
expression->base().accept(this);
location_t expression_location = get_location(&expression->position());
@@ -1010,7 +1010,7 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::assign_statement *statement)
+ void generic_visitor::visit(boot::assign_statement *statement)
{
statement->lvalue().accept(this);
@@ -1045,7 +1045,7 @@ namespace elna::gcc
this->current_expression = NULL_TREE;
}
- void generic_visitor::visit(frontend::if_statement *statement)
+ void generic_visitor::visit(boot::if_statement *statement)
{
tree endif_label_decl = create_artificial_label(UNKNOWN_LOCATION);
tree goto_endif = build1(GOTO_EXPR, void_type_node, endif_label_decl);
@@ -1068,7 +1068,7 @@ namespace elna::gcc
this->current_expression = NULL_TREE;
}
- void generic_visitor::make_if_branch(frontend::conditional_statements& branch, tree goto_endif)
+ void generic_visitor::make_if_branch(boot::conditional_statements& branch, tree goto_endif)
{
branch.prerequisite().accept(this);
@@ -1102,11 +1102,11 @@ namespace elna::gcc
append_statement(else_label_expr);
}
- void generic_visitor::visit(frontend::import_declaration *)
+ void generic_visitor::visit(boot::import_declaration *)
{
}
- void generic_visitor::visit(frontend::while_statement *statement)
+ void generic_visitor::visit(boot::while_statement *statement)
{
location_t prerequisite_location = get_location(&statement->body().prerequisite().position());
tree prerequisite_label_decl = build_label_decl("while_do", prerequisite_location);
@@ -1127,9 +1127,9 @@ namespace elna::gcc
this->current_expression = NULL_TREE;
}
- void generic_visitor::visit_statements(const std::vector<frontend::statement *>& statements)
+ void generic_visitor::visit_statements(const std::vector<boot::statement *>& statements)
{
- for (frontend::statement *const statement : statements)
+ for (boot::statement *const statement : statements)
{
statement->accept(this);
@@ -1141,9 +1141,9 @@ namespace elna::gcc
}
}
- void generic_visitor::visit(frontend::return_statement *statement)
+ void generic_visitor::visit(boot::return_statement *statement)
{
- frontend::expression *return_expression = &statement->return_expression();
+ boot::expression *return_expression = &statement->return_expression();
location_t statement_position = get_location(&statement->position());
tree set_result{ NULL_TREE };
tree return_type = TREE_TYPE(TREE_TYPE(current_function_decl));
@@ -1183,14 +1183,14 @@ namespace elna::gcc
this->current_expression = NULL_TREE;
}
- void generic_visitor::visit(frontend::defer_statement *statement)
+ void generic_visitor::visit(boot::defer_statement *statement)
{
enter_scope();
visit_statements(statement->statements);
defer(leave_scope());
}
- void generic_visitor::visit(frontend::case_statement *statement)
+ void generic_visitor::visit(boot::case_statement *statement)
{
statement->condition().accept(this);
tree condition_expression = this->current_expression;
@@ -1207,9 +1207,9 @@ namespace elna::gcc
tree end_label_declaration = create_artificial_label(get_location(&statement->position()));
tree switch_statements = alloc_stmt_list();
- for (const frontend::switch_case& case_block : statement->cases)
+ for (const boot::switch_case& case_block : statement->cases)
{
- for (frontend::expression *const case_label : case_block.labels)
+ for (boot::expression *const case_label : case_block.labels)
{
case_label->accept(this);
location_t case_location = get_location(&case_label->position());