Skip parameter names in procedure type expressions

This commit is contained in:
2025-03-18 11:37:10 +01:00
parent 6eb4e91b2c
commit df3282cd96
20 changed files with 181 additions and 224 deletions

View File

@ -21,9 +21,7 @@ along with GCC; see the file COPYING3. If not see
#include "stringpool.h"
#include "elna/gcc/elna-tree.h"
namespace elna
{
namespace gcc
namespace elna::gcc
{
void init_ttree()
{
@ -66,4 +64,3 @@ namespace gcc
return symbol_table;
}
}
}

View File

@ -19,9 +19,7 @@ along with GCC; see the file COPYING3. If not see
#include "elna/gcc/elna-tree.h"
#include "elna/gcc/elna1.h"
namespace elna
{
namespace gcc
namespace elna::gcc
{
location_t get_location(const boot::position *position)
{
@ -144,4 +142,3 @@ namespace gcc
}
}
}
}

View File

@ -34,9 +34,7 @@ along with GCC; see the file COPYING3. If not see
#include "fold-const.h"
#include "langhooks.h"
namespace elna
{
namespace gcc
namespace elna::gcc
{
tree get_inner_alias(const boot::type& type, std::shared_ptr<symbol_table> symbols)
{
@ -317,7 +315,7 @@ namespace gcc
tree fndecl = build_fn_decl(definition->identifier.c_str(), declaration_type);
this->symbols->enter(definition->identifier, fndecl);
if (definition->heading().no_return)
if (definition->heading().return_type.no_return)
{
TREE_THIS_VOLATILE(fndecl) = 1;
}
@ -336,19 +334,22 @@ namespace gcc
function_args_iterator parameter_type;
function_args_iter_init(&parameter_type, declaration_type);
for (const boot::variable_declaration *parameter : definition->heading().parameters)
std::vector<std::string>::const_iterator parameter_name = definition->parameter_names.cbegin();
for (std::shared_ptr<boot::type_expression> parameter : definition->heading().parameters)
{
tree declaration_tree = build_decl(get_location(&parameter->position()), PARM_DECL,
get_identifier(parameter->identifier.c_str()), function_args_iter_cond(&parameter_type));
get_identifier(parameter_name->c_str()), function_args_iter_cond(&parameter_type));
DECL_CONTEXT(declaration_tree) = fndecl;
DECL_ARG_TYPE(declaration_tree) = function_args_iter_cond(&parameter_type);
if (definition->body != nullptr)
{
this->symbols->enter(parameter->identifier, declaration_tree);
this->symbols->enter(*parameter_name, declaration_tree);
}
argument_chain = chainon(argument_chain, declaration_tree);
function_args_iter_next(&parameter_type);
++parameter_name;
}
DECL_ARGUMENTS(fndecl) = argument_chain;
TREE_PUBLIC(fndecl) = definition->exported;
@ -409,17 +410,17 @@ namespace gcc
return bind_expr;
}
void generic_visitor::visit(boot::number_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(boot::number_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(boot::number_literal<double> *literal)
void generic_visitor::visit(boot::literal<double> *literal)
{
REAL_VALUE_TYPE real_value1;
@ -434,22 +435,22 @@ namespace gcc
mpfr_clear(number);
}
void generic_visitor::visit(boot::number_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(boot::number_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(boot::number_literal<nullptr_t> *)
void generic_visitor::visit(boot::literal<nullptr_t> *)
{
this->current_expression = elna_pointer_nil_node;
}
void generic_visitor::visit(boot::number_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));
@ -779,15 +780,14 @@ namespace gcc
for (std::size_t i = 0; i < type.parameters.size(); ++i)
{
boot::type_expression& parameter_type = type.parameters.at(i)->variable_type();
parameter_type.accept(this);
type.parameters.at(i)->accept(this);
parameter_types[i] = this->current_expression;
}
tree return_type = void_type_node;
if (type.return_type != nullptr)
if (type.return_type.type != nullptr)
{
type.return_type->accept(this);
type.return_type.type->accept(this);
return_type = this->current_expression;
}
this->current_expression = NULL_TREE;
@ -1226,4 +1226,3 @@ namespace gcc
defer(leave_scope());
}
}
}

View File

@ -24,9 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "fold-const.h"
#include "diagnostic-core.h"
namespace elna
{
namespace gcc
namespace elna::gcc
{
bool is_pointer_type(tree type)
{
@ -210,4 +208,3 @@ namespace gcc
}
}
}
}