Add a char type
This commit is contained in:
@ -28,6 +28,10 @@ namespace gcc
|
||||
{
|
||||
return "Float";
|
||||
}
|
||||
else if (type == elna_char_type_node)
|
||||
{
|
||||
return "Char";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<<unknown-type>>";
|
||||
|
@ -42,6 +42,10 @@ namespace gcc
|
||||
{
|
||||
format_number = "%f\n";
|
||||
}
|
||||
else if (argument_type == elna_char_type_node)
|
||||
{
|
||||
format_number = "%c\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
error_at(get_location(&argument->position()),
|
||||
@ -125,9 +129,14 @@ namespace gcc
|
||||
mpfr_clear(number);
|
||||
}
|
||||
|
||||
void generic_visitor::visit(source::boolean_literal *literal)
|
||||
void generic_visitor::visit(source::number_literal<bool> *boolean)
|
||||
{
|
||||
this->current_expression = build_int_cst_type(boolean_type_node, literal->boolean());
|
||||
this->current_expression = build_int_cst_type(boolean_type_node, boolean->number());
|
||||
}
|
||||
|
||||
void generic_visitor::visit(source::char_literal *character)
|
||||
{
|
||||
this->current_expression = build_int_cstu(elna_char_type_node, character->character());
|
||||
}
|
||||
|
||||
void generic_visitor::visit(source::binary_expression *expression)
|
||||
@ -262,6 +271,10 @@ namespace gcc
|
||||
{
|
||||
declaration_type = double_type_node;
|
||||
}
|
||||
else if (declaration->type().base() == "Char")
|
||||
{
|
||||
declaration_type = elna_char_type_node;
|
||||
}
|
||||
else
|
||||
{
|
||||
error_at(get_location(&declaration->type().position()),
|
||||
|
@ -1,3 +1,11 @@
|
||||
#include "elna/gcc/elna-tree.h"
|
||||
|
||||
#include "stor-layout.h"
|
||||
|
||||
tree elna_global_trees[ELNA_TI_MAX];
|
||||
|
||||
void elna_init_ttree(void)
|
||||
{
|
||||
elna_char_type_node = make_unsigned_type(8);
|
||||
TYPE_STRING_FLAG(elna_char_type_node) = 1;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ struct GTY (()) language_function
|
||||
static bool elna_langhook_init(void)
|
||||
{
|
||||
build_common_tree_nodes(false);
|
||||
enumeral_node = make_node(ENUMERAL_TYPE);
|
||||
elna_init_ttree();
|
||||
|
||||
/* I don't know why this has to be done explicitly. */
|
||||
void_list_node = build_tree_list(NULL_TREE, void_type_node);
|
||||
|
Reference in New Issue
Block a user