End while and if statements with the end token
This commit is contained in:
@ -15,9 +15,9 @@ namespace elna
|
||||
{
|
||||
namespace gcc
|
||||
{
|
||||
generic_visitor::generic_visitor()
|
||||
generic_visitor::generic_visitor(std::shared_ptr<source::symbol_table<tree>> symbol_table)
|
||||
{
|
||||
this->symbol_map = std::make_shared<source::symbol_table<tree>>();
|
||||
this->symbol_map = symbol_table;
|
||||
}
|
||||
|
||||
void generic_visitor::visit(source::call_statement *statement)
|
||||
@ -270,7 +270,7 @@ namespace gcc
|
||||
this->current_expression = build_string_literal(string->string().size() + 1, string->string().c_str());
|
||||
}
|
||||
|
||||
void generic_visitor::build_binarary_operation(bool condition, source::binary_expression *expression,
|
||||
void generic_visitor::build_binary_operation(bool condition, source::binary_expression *expression,
|
||||
tree_code operator_code, tree left, tree right, tree target_type)
|
||||
{
|
||||
auto expression_location = get_location(&expression->position());
|
||||
@ -354,7 +354,7 @@ namespace gcc
|
||||
}
|
||||
if (operator_code != ERROR_MARK) // An arithmetic operation.
|
||||
{
|
||||
build_binarary_operation(left_type == integer_type_node || left_type == double_type_node,
|
||||
build_binary_operation(left_type == integer_type_node || left_type == double_type_node,
|
||||
expression, operator_code, left, right, target_type);
|
||||
return;
|
||||
}
|
||||
@ -373,7 +373,7 @@ namespace gcc
|
||||
}
|
||||
if (operator_code != ERROR_MARK) // A logical operation.
|
||||
{
|
||||
build_binarary_operation(left_type == boolean_type_node,
|
||||
build_binary_operation(left_type == boolean_type_node,
|
||||
expression, operator_code, left, right, target_type);
|
||||
return;
|
||||
}
|
||||
@ -538,7 +538,7 @@ namespace gcc
|
||||
tree record_type_node = make_node(RECORD_TYPE);
|
||||
tree_chain record_chain;
|
||||
|
||||
for (auto& field : record_type->fields())
|
||||
for (auto& field : record_type->fields)
|
||||
{
|
||||
if (field_names.find(field.first) != field_names.cend())
|
||||
{
|
||||
@ -564,6 +564,38 @@ namespace gcc
|
||||
|
||||
return record_type_node;
|
||||
}
|
||||
else if (source::union_type_expression *union_type = type.is_union())
|
||||
{
|
||||
std::set<std::string> field_names;
|
||||
tree union_type_node = make_node(UNION_TYPE);
|
||||
tree_chain union_chain;
|
||||
|
||||
for (auto& field : union_type->fields)
|
||||
{
|
||||
if (field_names.find(field.first) != field_names.cend())
|
||||
{
|
||||
error_at(get_location(&field.second->position()), "repeated field name");
|
||||
return error_mark_node;
|
||||
}
|
||||
field_names.insert(field.first);
|
||||
|
||||
tree field_type = build_type(*field.second);
|
||||
if (field_type == NULL_TREE || field_type == error_mark_node)
|
||||
{
|
||||
return field_type;
|
||||
}
|
||||
tree field_declaration = build_decl(get_location(&field.second->position()),
|
||||
FIELD_DECL, get_identifier(field.first.c_str()), field_type);
|
||||
TREE_ADDRESSABLE(field_declaration) = 1;
|
||||
DECL_CONTEXT(field_declaration) = union_type_node;
|
||||
|
||||
union_chain.append(field_declaration);
|
||||
}
|
||||
TYPE_FIELDS(union_type_node) = union_chain.head();
|
||||
layout_type(union_type_node);
|
||||
|
||||
return union_type_node;
|
||||
}
|
||||
return NULL_TREE;
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,6 @@ namespace gcc
|
||||
return TREE_CODE(type) == ARRAY_TYPE;
|
||||
}
|
||||
|
||||
bool is_record_type(tree type)
|
||||
{
|
||||
gcc_assert(TYPE_P(type));
|
||||
return TREE_CODE(type) == RECORD_TYPE;
|
||||
}
|
||||
|
||||
tree tree_chain_base::head()
|
||||
{
|
||||
return first;
|
||||
@ -79,5 +73,10 @@ namespace gcc
|
||||
{
|
||||
return m_block;
|
||||
}
|
||||
|
||||
std::shared_ptr<elna::source::symbol_table<tree>> builtin_symbol_table()
|
||||
{
|
||||
return std::make_shared<elna::source::symbol_table<tree>>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user