mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Update type changes.
This commit is contained in:
committed by
Christoffer Lerno
parent
2ca67d1489
commit
6df6d2c084
@@ -537,6 +537,8 @@ static inline TypeInfo *parse_array_type_index(ParseContext *c, TypeInfo *type)
|
||||
}
|
||||
if (try_consume(c, TOKEN_RBRACKET))
|
||||
{
|
||||
bool is_resolved = type->resolve_status == RESOLVE_DONE;
|
||||
if (is_resolved && !type_is_valid_for_array(type->type)) goto DIRECT_SUBARRAY;
|
||||
switch (type->subtype)
|
||||
{
|
||||
case TYPE_COMPRESSED_NONE:
|
||||
@@ -549,20 +551,20 @@ static inline TypeInfo *parse_array_type_index(ParseContext *c, TypeInfo *type)
|
||||
type->subtype = TYPE_COMPRESSED_SUBSUB;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
TypeInfo *subarray = type_info_new(TYPE_INFO_SUBARRAY, type->span);
|
||||
subarray->array.base = type;
|
||||
subarray->array.len = NULL;
|
||||
RANGE_EXTEND_PREV(subarray);
|
||||
return subarray;
|
||||
}
|
||||
goto DIRECT_SUBARRAY;
|
||||
}
|
||||
if (type->resolve_status == RESOLVE_DONE)
|
||||
if (is_resolved)
|
||||
{
|
||||
type->type = type_get_subarray(type->type);
|
||||
}
|
||||
RANGE_EXTEND_PREV(type);
|
||||
return type;
|
||||
DIRECT_SUBARRAY:;
|
||||
TypeInfo *subarray = type_info_new(TYPE_INFO_SUBARRAY, type->span);
|
||||
subarray->array.base = type;
|
||||
subarray->array.len = NULL;
|
||||
RANGE_EXTEND_PREV(subarray);
|
||||
return subarray;
|
||||
}
|
||||
TypeInfo *array = type_info_new(TYPE_INFO_ARRAY, type->span);
|
||||
array->array.base = type;
|
||||
|
||||
@@ -1108,8 +1108,8 @@ bool type_is_valid_for_array(Type *type)
|
||||
switch (type->type_kind)
|
||||
{
|
||||
case TYPE_DISTINCT:
|
||||
assert(type->decl->resolve_status == RESOLVE_DONE);
|
||||
type = type->decl->define_decl.type_info->type;
|
||||
assert(!type->decl || type->decl->resolve_status == RESOLVE_DONE);
|
||||
type = type->decl->distinct_decl.base_type;
|
||||
goto RETRY;
|
||||
case TYPE_ANY:
|
||||
case TYPE_ANYFAULT:
|
||||
@@ -1129,6 +1129,7 @@ bool type_is_valid_for_array(Type *type)
|
||||
case TYPE_VECTOR:
|
||||
return true;
|
||||
case TYPE_TYPEDEF:
|
||||
assert(!type->decl || type->decl->resolve_status == RESOLVE_DONE);
|
||||
type = type->canonical;
|
||||
goto RETRY;
|
||||
case TYPE_FLEXIBLE_ARRAY:
|
||||
@@ -1145,6 +1146,7 @@ bool type_is_valid_for_array(Type *type)
|
||||
case TYPE_VOID:
|
||||
return false;
|
||||
}
|
||||
UNREACHABLE
|
||||
}
|
||||
|
||||
Type *type_get_vector_bool(Type *original_type)
|
||||
|
||||
Reference in New Issue
Block a user