|
|
|
@ -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(¶meter_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(¶meter->position()), PARM_DECL,
|
|
|
|
|
get_identifier(parameter->identifier.c_str()), function_args_iter_cond(¶meter_type));
|
|
|
|
|
get_identifier(parameter_name->c_str()), function_args_iter_cond(¶meter_type));
|
|
|
|
|
DECL_CONTEXT(declaration_tree) = fndecl;
|
|
|
|
|
DECL_ARG_TYPE(declaration_tree) = function_args_iter_cond(¶meter_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(¶meter_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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|