Provide record initialization syntax
This commit is contained in:
@ -79,6 +79,18 @@ namespace gcc
|
||||
this->current_expression = stmt;
|
||||
}
|
||||
}
|
||||
else if (TYPE_P(symbol) && is_record_type(symbol))
|
||||
{
|
||||
vec<constructor_elt, va_gc> *arguments = NULL;
|
||||
tree record_fields = TYPE_FIELDS(symbol);
|
||||
for (std::size_t i = 0; i < expression->arguments().size(); ++i)
|
||||
{
|
||||
expression->arguments().at(i)->accept(this);
|
||||
CONSTRUCTOR_APPEND_ELT(arguments, record_fields, this->current_expression);
|
||||
record_fields = TREE_CHAIN(record_fields);
|
||||
}
|
||||
this->current_expression = build_constructor(symbol, arguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_at(call_location, "'%s' cannot be called, it is neither a procedure nor record",
|
||||
|
@ -62,6 +62,11 @@ namespace gcc
|
||||
return type == NULL_TREE || type == void_type_node;
|
||||
}
|
||||
|
||||
bool is_record_type(tree type)
|
||||
{
|
||||
return TREE_CODE(type) == RECORD_TYPE;
|
||||
}
|
||||
|
||||
bool are_compatible_pointers(tree lhs, tree rhs)
|
||||
{
|
||||
tree lhs_type = TREE_TYPE(lhs);
|
||||
|
Reference in New Issue
Block a user