diff options
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/gcc/elna-generic.cc | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index 94a70df..ed75fa4 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -286,13 +286,9 @@ namespace elna::gcc void generic_visitor::visit(boot::unit *unit) { - for (boot::variable_declaration *const variable : unit->variables) + for (boot::declaration *const unit_declaration : unit->declarations) { - variable->accept(this); - } - for (boot::procedure_declaration *const procedure : unit->procedures) - { - procedure->accept(this); + unit_declaration->accept(this); } if (unit->entry_point.has_value()) { @@ -365,6 +361,69 @@ namespace elna::gcc } } + void generic_visitor::visit(boot::type_declaration *) + { + } + + void generic_visitor::visit(boot::variable_declaration *declaration) + { + for (const auto& variable_identifier : declaration->identifiers) + { + const location_t declaration_location = get_location(&declaration->position()); + const std::string& variable_name = variable_identifier.name(); + tree declaration_tree = this->symbols->lookup(variable_name); + + auto variable_symbol = this->bag.lookup(variable_name)->is_variable(); + + if (declaration_tree == NULL_TREE) + { + declaration_tree = declare_variable(variable_name, *variable_symbol, this->symbols); + } + if (variable_symbol->alignment.has_value()) + { + SET_DECL_ALIGN(declaration_tree, + variable_symbol->alignment.value() * BITS_PER_UNIT); + DECL_USER_ALIGN(declaration_tree) = 1; + } + if (variable_symbol->value.has_value()) + { + tree type = get_inner_alias(variable_symbol->symbol, this->symbols); + DECL_INITIAL(declaration_tree) = constant_to_tree( + variable_symbol->value.value(), this->symbols, type); + } + else if (declaration->initializer != nullptr) + { + declaration->initializer->accept(this); + DECL_INITIAL(declaration_tree) = this->current_expression; + } + else if (!declaration->is_extern && POINTER_TYPE_P(TREE_TYPE(declaration_tree))) + { + DECL_INITIAL(declaration_tree) = null_pointer_node; + } + if (variable_symbol->symbol.get<boot::constant_type>() != nullptr) + { + TREE_READONLY(declaration_tree) = 1; + } + this->current_expression = NULL_TREE; + + if (lang_hooks.decls.global_bindings_p()) + { + TREE_STATIC(declaration_tree) = static_cast<unsigned>(!declaration->is_extern); + varpool_node::get_create(declaration_tree); + varpool_node::finalize_decl(declaration_tree); + } + else + { + DECL_CONTEXT(declaration_tree) = current_function_decl; + f_binding_level->names = chainon(f_binding_level->names, declaration_tree); + + tree declaration_statement = build1_loc(declaration_location, DECL_EXPR, + void_type_node, declaration_tree); + append_statement(declaration_statement); + } + } + } + void generic_visitor::visit(boot::procedure_declaration *declaration) { tree fndecl = this->symbols->lookup(declaration->identifier.name()); @@ -751,65 +810,6 @@ namespace elna::gcc } } - void generic_visitor::visit(boot::variable_declaration *declaration) - { - for (const auto& variable_identifier : declaration->identifiers) - { - const location_t declaration_location = get_location(&declaration->position()); - const std::string& variable_name = variable_identifier.name(); - tree declaration_tree = this->symbols->lookup(variable_name); - - auto variable_symbol = this->bag.lookup(variable_name)->is_variable(); - - if (declaration_tree == NULL_TREE) - { - declaration_tree = declare_variable(variable_name, *variable_symbol, this->symbols); - } - if (variable_symbol->alignment.has_value()) - { - SET_DECL_ALIGN(declaration_tree, - variable_symbol->alignment.value() * BITS_PER_UNIT); - DECL_USER_ALIGN(declaration_tree) = 1; - } - if (variable_symbol->value.has_value()) - { - tree type = get_inner_alias(variable_symbol->symbol, this->symbols); - DECL_INITIAL(declaration_tree) = constant_to_tree( - variable_symbol->value.value(), this->symbols, type); - } - else if (declaration->initializer != nullptr) - { - declaration->initializer->accept(this); - DECL_INITIAL(declaration_tree) = this->current_expression; - } - else if (!declaration->is_extern && POINTER_TYPE_P(TREE_TYPE(declaration_tree))) - { - DECL_INITIAL(declaration_tree) = null_pointer_node; - } - if (variable_symbol->symbol.get<boot::constant_type>() != nullptr) - { - TREE_READONLY(declaration_tree) = 1; - } - this->current_expression = NULL_TREE; - - if (lang_hooks.decls.global_bindings_p()) - { - TREE_STATIC(declaration_tree) = static_cast<unsigned>(!declaration->is_extern); - varpool_node::get_create(declaration_tree); - varpool_node::finalize_decl(declaration_tree); - } - else - { - DECL_CONTEXT(declaration_tree) = current_function_decl; - f_binding_level->names = chainon(f_binding_level->names, declaration_tree); - - tree declaration_statement = build1_loc(declaration_location, DECL_EXPR, - void_type_node, declaration_tree); - append_statement(declaration_statement); - } - } - } - void generic_visitor::visit(boot::named_expression *expression) { tree symbol = this->symbols->lookup(expression->name); |
