Type check the return statement

This commit is contained in:
2025-03-25 11:29:29 +01:00
parent c022805c53
commit d359056354
13 changed files with 483 additions and 477 deletions

View File

@ -49,17 +49,29 @@ namespace elna::gcc
layout_type(elna_string_type_node);
}
static
void declare_builtin_type(std::shared_ptr<symbol_table> symbol_table, const char *name, tree type)
{
tree identifier = get_identifier(name);
tree type_declaration = build_decl(UNKNOWN_LOCATION, TYPE_DECL, identifier, type);
TREE_PUBLIC(type_declaration) = 1;
TYPE_NAME(type_declaration) = identifier;
symbol_table->enter(name, type_declaration);
}
std::shared_ptr<symbol_table> builtin_symbol_table()
{
std::shared_ptr<elna::gcc::symbol_table> symbol_table = std::make_shared<elna::gcc::symbol_table>();
symbol_table->enter("Int", elna_int_type_node);
symbol_table->enter("Word", elna_word_type_node);
symbol_table->enter("Char", elna_char_type_node);
symbol_table->enter("Bool", elna_bool_type_node);
symbol_table->enter("Byte", elna_byte_type_node);
symbol_table->enter("Float", elna_float_type_node);
symbol_table->enter("String", elna_string_type_node);
declare_builtin_type(symbol_table, "Int", elna_int_type_node);
declare_builtin_type(symbol_table, "Word", elna_word_type_node);
declare_builtin_type(symbol_table, "Char", elna_char_type_node);
declare_builtin_type(symbol_table, "Bool", elna_bool_type_node);
declare_builtin_type(symbol_table, "Byte", elna_byte_type_node);
declare_builtin_type(symbol_table, "Float", elna_float_type_node);
declare_builtin_type(symbol_table, "String", elna_string_type_node);
return symbol_table;
}