Implement .max and .min type properties
This commit is contained in:
@ -30,6 +30,18 @@ namespace gcc
|
||||
return linemap_position_for_column(line_table, position->column);
|
||||
}
|
||||
|
||||
std::string print_aggregate_name(tree type, const std::string& kind_name)
|
||||
{
|
||||
if (TYPE_IDENTIFIER(type) == NULL_TREE)
|
||||
{
|
||||
return kind_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::string(IDENTIFIER_POINTER(TYPE_IDENTIFIER(type)));
|
||||
}
|
||||
}
|
||||
|
||||
std::string print_type(tree type)
|
||||
{
|
||||
gcc_assert(TYPE_P(type));
|
||||
@ -68,7 +80,7 @@ namespace gcc
|
||||
}
|
||||
else if (is_pointer_type(type))
|
||||
{
|
||||
return std::string("pointer to " + print_type(TREE_TYPE(type)));
|
||||
return std::string("^" + print_type(TREE_TYPE(type)));
|
||||
}
|
||||
else if (is_procedure_type(type))
|
||||
{
|
||||
@ -100,11 +112,11 @@ namespace gcc
|
||||
}
|
||||
else if (TREE_CODE(type) == RECORD_TYPE)
|
||||
{
|
||||
return "record";
|
||||
return print_aggregate_name(type, "record");
|
||||
}
|
||||
else if (TREE_CODE(type) == UNION_TYPE)
|
||||
{
|
||||
return "union";
|
||||
return print_aggregate_name(type, "union");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -733,6 +733,7 @@ namespace gcc
|
||||
if (result)
|
||||
{
|
||||
TREE_PUBLIC(definition_tree) = definition->exported;
|
||||
TYPE_NAME(tree_type) = get_identifier(definition->identifier.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -952,6 +953,14 @@ namespace gcc
|
||||
this->current_expression = build_int_cstu(elna_word_type_node,
|
||||
TYPE_ALIGN_UNIT(this->current_expression));
|
||||
}
|
||||
else if (expression->field() == "min" && is_integral_type(this->current_expression))
|
||||
{
|
||||
this->current_expression = TYPE_MIN_VALUE(this->current_expression);
|
||||
}
|
||||
else if (expression->field() == "max" && is_integral_type(this->current_expression))
|
||||
{
|
||||
this->current_expression = TYPE_MAX_VALUE(this->current_expression);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_at(expression_location, "type '%s' does not have property '%s'",
|
||||
|
Reference in New Issue
Block a user