mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Typekind enums are changed CONST_ENUM -> CONSTDEF, DISTINCT -> TYPEDEF.
This commit is contained in:
@@ -115,8 +115,8 @@ macro bool is_native_atomic_type($Type)
|
||||
$case FLOAT:
|
||||
$case BOOL:
|
||||
return true;
|
||||
$case DISTINCT:
|
||||
$case CONST_ENUM:
|
||||
$case TYPEDEF:
|
||||
$case CONSTDEF:
|
||||
return is_native_atomic_type($Type.inner);
|
||||
$default:
|
||||
return false;
|
||||
|
||||
@@ -97,8 +97,8 @@ macro bool is_subtype_of($Type, $OtherType)
|
||||
macro bool is_numerical($Type)
|
||||
{
|
||||
$switch $Type.kindof:
|
||||
$case DISTINCT:
|
||||
$case CONST_ENUM:
|
||||
$case TYPEDEF:
|
||||
$case CONSTDEF:
|
||||
return is_numerical($Type.inner);
|
||||
$case SIGNED_INT:
|
||||
$case UNSIGNED_INT:
|
||||
@@ -170,7 +170,7 @@ macro bool is_unsigned($Type) @const
|
||||
|
||||
macro typeid flat_type($Type) @const
|
||||
{
|
||||
$if $Type.kindof == DISTINCT || $Type.kindof == CONST_ENUM:
|
||||
$if $Type.kindof == TYPEDEF || $Type.kindof == CONSTDEF:
|
||||
return flat_type($Type.inner);
|
||||
$else
|
||||
return $Type.typeid;
|
||||
@@ -179,7 +179,7 @@ macro typeid flat_type($Type) @const
|
||||
|
||||
macro TypeKind flat_kind($Type) @const
|
||||
{
|
||||
$if $Type.kindof == DISTINCT || $Type.kindof == CONST_ENUM:
|
||||
$if $Type.kindof == TYPEDEF || $Type.kindof == CONSTDEF:
|
||||
return flat_type($Type.inner);
|
||||
$else
|
||||
return $Type.kindof;
|
||||
@@ -203,8 +203,8 @@ macro bool is_flat_intlike($Type) @const
|
||||
$case UNSIGNED_INT:
|
||||
return true;
|
||||
$case VECTOR:
|
||||
$case DISTINCT:
|
||||
$case CONST_ENUM:
|
||||
$case TYPEDEF:
|
||||
$case CONSTDEF:
|
||||
return is_flat_intlike($Type.inner);
|
||||
$default:
|
||||
return false;
|
||||
@@ -230,7 +230,7 @@ macro bool is_underlying_int($Type) @const
|
||||
$case SIGNED_INT:
|
||||
$case UNSIGNED_INT:
|
||||
return true;
|
||||
$case DISTINCT:
|
||||
$case TYPEDEF:
|
||||
return is_underlying_int($Type.inner);
|
||||
$default:
|
||||
return false;
|
||||
@@ -258,7 +258,7 @@ macro bool is_vector($Type) @const
|
||||
|
||||
macro typeid inner_type($Type) @const
|
||||
{
|
||||
$if $Type.kindof == DISTINCT || $Type.kindof == CONST_ENUM:
|
||||
$if $Type.kindof == TYPEDEF || $Type.kindof == CONSTDEF:
|
||||
return inner_type($Type.inner);
|
||||
$else
|
||||
return $Type.typeid;
|
||||
@@ -298,7 +298,7 @@ macro bool may_load_atomic($Type) @const
|
||||
$case POINTER:
|
||||
$case FLOAT:
|
||||
return true;
|
||||
$case DISTINCT:
|
||||
$case TYPEDEF:
|
||||
$case ENUM:
|
||||
return may_load_atomic($Type.inner);
|
||||
$default:
|
||||
@@ -313,8 +313,8 @@ macro lower_to_atomic_compatible_type($Type) @const
|
||||
$case SIGNED_INT:
|
||||
$case UNSIGNED_INT:
|
||||
return $Type.typeid;
|
||||
$case DISTINCT:
|
||||
$case CONST_ENUM:
|
||||
$case TYPEDEF:
|
||||
$case CONSTDEF:
|
||||
return lower_to_atomic_compatible_type($Type.inner);
|
||||
$case FLOAT:
|
||||
$switch $Type:
|
||||
@@ -379,6 +379,9 @@ macro bool @comparable_value(#value) @const
|
||||
$endif
|
||||
}
|
||||
|
||||
const CONST_ENUM @builtin @deprecated("Use TypeKind.CONSTDEF instead") = TypeKind.CONSTDEF;
|
||||
const DISTINCT @builtin @deprecated("Use TypeKind.TYPEDEF instead") = TypeKind.TYPEDEF;
|
||||
|
||||
enum TypeKind : char
|
||||
{
|
||||
VOID,
|
||||
@@ -390,7 +393,7 @@ enum TypeKind : char
|
||||
FAULT,
|
||||
ANY,
|
||||
ENUM,
|
||||
CONST_ENUM,
|
||||
CONSTDEF,
|
||||
STRUCT,
|
||||
UNION,
|
||||
BITSTRUCT,
|
||||
@@ -399,7 +402,7 @@ enum TypeKind : char
|
||||
ARRAY,
|
||||
SLICE,
|
||||
VECTOR,
|
||||
DISTINCT,
|
||||
TYPEDEF,
|
||||
POINTER,
|
||||
INTERFACE,
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ fn uint128? int_from_any(any arg, bool *is_neg) @private
|
||||
case POINTER:
|
||||
*is_neg = false;
|
||||
return (uint128)(uptr)*(void**)arg.ptr;
|
||||
case DISTINCT:
|
||||
case CONST_ENUM:
|
||||
case TYPEDEF:
|
||||
case CONSTDEF:
|
||||
return int_from_any(arg.as_inner(), is_neg);
|
||||
default:
|
||||
break;
|
||||
@@ -95,7 +95,7 @@ fn FloatType? float_from_any(any arg) @private
|
||||
$if env::F128_SUPPORT:
|
||||
if (arg.type == float128.typeid) return (FloatType)*((float128*)arg.ptr);
|
||||
$endif
|
||||
if (arg.type.kindof == DISTINCT || arg.type.kindof == CONST_ENUM)
|
||||
if (arg.type.kindof == TYPEDEF || arg.type.kindof == CONSTDEF)
|
||||
{
|
||||
return float_from_any(arg.as_inner());
|
||||
}
|
||||
@@ -945,8 +945,8 @@ fn usz? formatter_out_str(Formatter* self, any arg) @private
|
||||
return formatter_out_unknown(self, "union", arg);
|
||||
case BITSTRUCT:
|
||||
return formatter_out_unknown(self, "bitstruct", arg);
|
||||
case CONST_ENUM:
|
||||
case DISTINCT:
|
||||
case CONSTDEF:
|
||||
case TYPEDEF:
|
||||
if (arg.type == String.typeid)
|
||||
{
|
||||
return formatter_out_substr(self, *(String*)arg);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
- Support deprecating enum values.
|
||||
- Improve error when trying to use an extern const as a compile time constant. #2969
|
||||
- `vendor-fetch` command now lists all available packages by default. #2976
|
||||
- Typekind enums are changed CONST_ENUM -> CONSTDEF, DISTINCT -> TYPEDEF.
|
||||
|
||||
### Stdlib changes
|
||||
- Summarize sort macros as generic function wrappers to reduce the amount of generated code. #2831
|
||||
|
||||
@@ -116,7 +116,7 @@ static bool x86_should_return_type_in_reg(Type *type)
|
||||
case TYPE_FUNC_RAW:
|
||||
case TYPE_INTERFACE:
|
||||
case TYPE_OPTIONAL:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_ALIAS:
|
||||
case TYPE_TYPEID:
|
||||
case TYPE_VECTOR:
|
||||
|
||||
@@ -69,7 +69,7 @@ Decl *decl_new_with_type(const char *name, SourceSpan span, DeclKind decl_type)
|
||||
kind = TYPE_ENUM;
|
||||
break;
|
||||
case DECL_CONSTDEF:
|
||||
kind = TYPE_CONST_ENUM;
|
||||
kind = TYPE_CONSTDEF;
|
||||
break;
|
||||
case DECL_TYPEDEF:
|
||||
kind = TYPE_TYPEDEF;
|
||||
|
||||
@@ -95,7 +95,7 @@ static const char *c_type_name(GenContext *c, Type *type)
|
||||
case TYPE_FUNC_RAW:
|
||||
case TYPE_ALIAS:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_UNTYPED_LIST:
|
||||
case TYPE_INFERRED_ARRAY:
|
||||
case TYPE_INFERRED_VECTOR:
|
||||
@@ -149,7 +149,7 @@ static bool c_emit_type_decl(GenContext *c, Type *type)
|
||||
case TYPE_FUNC_RAW:
|
||||
case TYPE_ALIAS:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_UNTYPED_LIST:
|
||||
case TYPE_INFERRED_ARRAY:
|
||||
case TYPE_INFERRED_VECTOR:
|
||||
@@ -654,7 +654,7 @@ static void c_emit_local_decl(GenContext *c, Decl *decl, CValue *value)
|
||||
case TYPE_POISONED:
|
||||
case TYPE_VOID:
|
||||
case TYPE_TYPEDEF:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_FUNC_RAW:
|
||||
case TYPE_BITSTRUCT:
|
||||
case TYPE_ALIAS:
|
||||
|
||||
@@ -33,7 +33,7 @@ static inline LoweredType *type_lowering(Type *type)
|
||||
case TYPE_TYPEDEF:
|
||||
type = type->decl->distinct->type;
|
||||
continue;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_ENUM:
|
||||
type = enum_inner_type(type);
|
||||
continue;
|
||||
@@ -106,7 +106,7 @@ static inline LoweredType *type_lowering_abi(Type *type)
|
||||
case TYPE_TYPEDEF:
|
||||
type = type->decl->distinct->type;
|
||||
continue;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_ENUM:
|
||||
type = enum_inner_type(type);
|
||||
continue;
|
||||
|
||||
@@ -2891,7 +2891,7 @@ INLINE bool type_may_implement_interface(Type *type)
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_TYPEDEF:
|
||||
case TYPE_BITSTRUCT:
|
||||
return true;
|
||||
@@ -2990,7 +2990,7 @@ INLINE bool type_is_atomic(Type *type_flat)
|
||||
case ALL_SIGNED_INTS:
|
||||
case ALL_FLOATS:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_ANYFAULT:
|
||||
case TYPE_TYPEID:
|
||||
case TYPE_BOOL:
|
||||
@@ -3158,7 +3158,7 @@ INLINE Type *type_flatten_for_bitstruct(Type *type)
|
||||
{
|
||||
type = type->decl->distinct->type;
|
||||
}
|
||||
if (type->type_kind == TYPE_ENUM || type->type_kind == TYPE_CONST_ENUM)
|
||||
if (type->type_kind == TYPE_ENUM || type->type_kind == TYPE_CONSTDEF)
|
||||
{
|
||||
type = enum_inner_type(type)->canonical;
|
||||
goto RETRY;
|
||||
@@ -3217,7 +3217,7 @@ static inline Type *type_base(Type *type)
|
||||
type = type->decl->distinct->type;
|
||||
break;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = enum_inner_type(type);
|
||||
break;
|
||||
case TYPE_OPTIONAL:
|
||||
@@ -3234,7 +3234,7 @@ static inline Type *type_base(Type *type)
|
||||
|
||||
static const bool is_distinct_like[TYPE_LAST + 1] = {
|
||||
[TYPE_ENUM] = true,
|
||||
[TYPE_CONST_ENUM] = true,
|
||||
[TYPE_CONSTDEF] = true,
|
||||
[TYPE_TYPEDEF] = true
|
||||
};
|
||||
|
||||
@@ -3289,7 +3289,7 @@ static inline Type *type_flatten_and_inline(Type *type)
|
||||
case TYPE_TYPEDEF:
|
||||
type = type->decl->distinct->type;
|
||||
continue;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = type->decl->enums.type_info->type;
|
||||
continue;
|
||||
case TYPE_ENUM:
|
||||
@@ -3321,7 +3321,7 @@ static inline Type *type_flat_distinct_enum_inline(Type *type)
|
||||
if (!decl->is_substruct) return type;;
|
||||
type = decl->distinct->type;
|
||||
continue;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
decl = type->decl;
|
||||
if (!decl->is_substruct) return type;
|
||||
type = decl->enums.type_info->type;
|
||||
@@ -3346,7 +3346,7 @@ INLINE bool type_is_user_defined(Type *type)
|
||||
{
|
||||
static const bool user_defined_types[TYPE_LAST + 1] = {
|
||||
[TYPE_ENUM] = true,
|
||||
[TYPE_CONST_ENUM] = true,
|
||||
[TYPE_CONSTDEF] = true,
|
||||
[TYPE_STRUCT] = true,
|
||||
[TYPE_FUNC_RAW] = true,
|
||||
[TYPE_UNION] = true,
|
||||
@@ -3388,7 +3388,7 @@ static inline Type *type_flatten_to_int(Type *type)
|
||||
case TYPE_BITSTRUCT:
|
||||
type = type->decl->strukt.container_type->type;
|
||||
break;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = type->decl->enums.type_info->type;
|
||||
break;
|
||||
case TYPE_ENUM:
|
||||
@@ -3415,7 +3415,7 @@ static inline CanonicalType *type_distinct_inline(Type *type)
|
||||
case TYPE_ENUM:
|
||||
if (!type->decl->is_substruct) return type;
|
||||
FALLTHROUGH;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = enum_inner_type(type);
|
||||
break;
|
||||
case TYPE_TYPEDEF:
|
||||
@@ -3438,7 +3438,7 @@ static inline FlatType *type_flatten(Type *type)
|
||||
type = type->canonical;
|
||||
switch (type->type_kind)
|
||||
{
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = enum_inner_type(type);
|
||||
break;
|
||||
case TYPE_TYPEDEF:
|
||||
@@ -3469,7 +3469,7 @@ static inline Type *type_flatten_no_export(Type *type)
|
||||
if (type->decl->is_export) return type;
|
||||
type = type->decl->distinct->type;
|
||||
break;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
if (type->decl->is_export) return type;
|
||||
type = enum_inner_type(type);
|
||||
break;
|
||||
@@ -3579,7 +3579,7 @@ static inline Type *type_flat_for_arithmethics(Type *type)
|
||||
case TYPE_OPTIONAL:
|
||||
type = type->optional;
|
||||
continue;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_TYPEDEF:
|
||||
inner = type_inline(type);
|
||||
if (type->decl->is_substruct)
|
||||
|
||||
@@ -1743,7 +1743,7 @@ typedef enum
|
||||
TYPE_FUNC_PTR,
|
||||
TYPE_POINTER,
|
||||
TYPE_TYPEDEF,
|
||||
TYPE_CONST_ENUM,
|
||||
TYPE_CONSTDEF,
|
||||
TYPE_ENUM,
|
||||
TYPE_FUNC_RAW,
|
||||
TYPE_STRUCT,
|
||||
@@ -2177,7 +2177,7 @@ static_assert(EXPR_LAST < 128, "Too many expression types");
|
||||
|
||||
#define LOWERED_TYPES CT_TYPES: case TYPE_ENUM: case TYPE_ALIAS: case TYPE_TYPEID: \
|
||||
case TYPE_TYPEDEF: case TYPE_ANYFAULT: case TYPE_BITSTRUCT: \
|
||||
case TYPE_OPTIONAL: case TYPE_INTERFACE: case TYPE_CONST_ENUM
|
||||
case TYPE_OPTIONAL: case TYPE_INTERFACE: case TYPE_CONSTDEF
|
||||
|
||||
#define CT_TYPES TYPE_TYPEINFO: case TYPE_INFERRED_ARRAY: case TYPE_INFERRED_VECTOR: case TYPE_UNTYPED_LIST: \
|
||||
case TYPE_POISONED: case TYPE_MEMBER: case TYPE_WILDCARD
|
||||
|
||||
@@ -688,7 +688,7 @@ void expr_rewrite_to_const_zero(Expr *expr, Type *type)
|
||||
expr->const_expr.fault = NULL;
|
||||
expr->resolve_status = RESOLVE_DONE;
|
||||
break;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
expr_rewrite_const_int(expr, type, 0);
|
||||
return;
|
||||
case TYPE_ENUM:
|
||||
|
||||
@@ -164,7 +164,7 @@ static void header_print_type(HeaderContext *c, Type *type)
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
PRINTF("%s", decl_get_extname(type->decl));
|
||||
return;
|
||||
case TYPE_BITSTRUCT:
|
||||
@@ -554,7 +554,7 @@ RETRY:
|
||||
case TYPE_ENUM:
|
||||
header_gen_enum(c, 0, type->decl);
|
||||
return;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
// TODO;
|
||||
type = type_flatten(type);
|
||||
goto RETRY;
|
||||
|
||||
@@ -656,7 +656,7 @@ static inline LLVMMetadataRef llvm_get_debug_type_internal(GenContext *c, Type *
|
||||
return type->backend_debug_type = llvm_debug_pointer_type(c, type);
|
||||
case TYPE_ENUM:
|
||||
return type->backend_debug_type = llvm_debug_enum_type(c, type, scope);
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
return type->backend_debug_type = llvm_debug_raw_enum_type(c, type, scope);
|
||||
case TYPE_FUNC_RAW:
|
||||
return type->backend_debug_type = llvm_debug_func_type(c, type);
|
||||
|
||||
@@ -3595,7 +3595,7 @@ static void llvm_emit_array_comp(GenContext *c, BEValue *result, BEValue *lhs, B
|
||||
case ALL_INTS:
|
||||
case TYPE_POINTER:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_FUNC_PTR:
|
||||
case TYPE_INTERFACE:
|
||||
case TYPE_ANY:
|
||||
|
||||
@@ -643,7 +643,7 @@ LLVMValueRef llvm_get_typeid(GenContext *c, Type *type)
|
||||
return llvm_generate_introspection_global(c, NULL, type, INTROSPECT_TYPE_DISTINCT, type_inline(type), 0, NULL, false);
|
||||
case TYPE_ENUM:
|
||||
return llvm_get_introspection_for_enum(c, type);
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
return llvm_generate_introspection_global(c, NULL, type, INTROSPECT_TYPE_CONST_ENUM, type_inline(type), vec_size(type->decl->enums.values), NULL, false);
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
|
||||
@@ -2698,7 +2698,7 @@ static ConvGroup group_from_type[TYPE_LAST + 1] = {
|
||||
[TYPE_TYPEID] = CONV_TYPEID,
|
||||
[TYPE_POINTER] = CONV_POINTER,
|
||||
[TYPE_ENUM] = CONV_ENUM,
|
||||
[TYPE_CONST_ENUM] = CONV_RAW_ENUM,
|
||||
[TYPE_CONSTDEF] = CONV_RAW_ENUM,
|
||||
[TYPE_FUNC_PTR] = CONV_FUNC,
|
||||
[TYPE_STRUCT] = CONV_STRUCT,
|
||||
[TYPE_UNION] = CONV_UNION,
|
||||
|
||||
@@ -465,7 +465,7 @@ RETRY:;
|
||||
case TYPE_SLICE:
|
||||
return compiler.platform.align_pointer.align / 8;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = enum_inner_type(type);
|
||||
goto RETRY;
|
||||
case TYPE_STRUCT:
|
||||
@@ -1061,7 +1061,7 @@ RETRY:
|
||||
case TYPE_ANYFAULT:
|
||||
case TYPE_TYPEID:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_BITSTRUCT:
|
||||
@@ -2902,7 +2902,7 @@ static inline bool sema_analyse_method(SemaContext *context, Decl *decl)
|
||||
goto NOT_VALID_NAME;
|
||||
}
|
||||
FALLTHROUGH;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
{
|
||||
@@ -4663,7 +4663,7 @@ RETRY:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_SLICE:
|
||||
size = i128_mult64(size, type_size(type));
|
||||
break;
|
||||
@@ -5644,7 +5644,7 @@ RETRY:
|
||||
return true;
|
||||
case TYPE_FUNC_RAW:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_BITSTRUCT:
|
||||
|
||||
@@ -251,7 +251,7 @@ Expr *sema_enter_inline_member(Expr *parent, CanonicalType *type)
|
||||
expr->type = type;
|
||||
break;
|
||||
}
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
{
|
||||
Decl *decl = type->decl;
|
||||
if (!decl->is_substruct) return NULL;
|
||||
@@ -1227,7 +1227,7 @@ static inline bool sema_identifier_find_possible_inferred(SemaContext *context,
|
||||
to = to->canonical;
|
||||
switch (to->type_kind)
|
||||
{
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_ENUM:
|
||||
if (!decl_ok(to->decl)) return expr_poison(expr), true;
|
||||
return sema_expr_analyse_enum_constant(context, expr, expr->unresolved_ident_expr.ident, to->decl);
|
||||
@@ -1458,7 +1458,7 @@ static inline bool sema_binary_analyse_with_inference(SemaContext *context, Expr
|
||||
switch (left->type->canonical->type_kind)
|
||||
{
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
return sema_analyse_inferred_expr(context, left->type, right, NULL);
|
||||
default:
|
||||
return sema_analyse_expr_rvalue(context, right);
|
||||
@@ -1477,7 +1477,7 @@ static inline bool sema_binary_analyse_subexpr(SemaContext *context, Expr *left,
|
||||
switch (type_flatten(left->type)->type_kind)
|
||||
{
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
return sema_analyse_inferred_expr(context, left->type, right, NULL);
|
||||
default:
|
||||
break;
|
||||
@@ -1490,7 +1490,7 @@ static inline bool sema_binary_analyse_subexpr(SemaContext *context, Expr *left,
|
||||
switch (type_flatten(right->type)->type_kind)
|
||||
{
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
return sema_analyse_inferred_expr(context, right->type, left, NULL);
|
||||
default:
|
||||
break;
|
||||
@@ -5341,7 +5341,7 @@ static inline bool sema_create_const_len(Expr *expr, Type *type, Type *flat)
|
||||
ASSERT_SPAN(expr, flat == type_flatten(flat) && "Should be flattened already.");
|
||||
|
||||
size_t len;
|
||||
if (type->type_kind == TYPE_CONST_ENUM)
|
||||
if (type->type_kind == TYPE_CONSTDEF)
|
||||
{
|
||||
len = vec_size(type->decl->enums.values);
|
||||
expr_rewrite_const_int(expr, type_usz, len);
|
||||
@@ -5381,7 +5381,7 @@ static inline bool sema_create_const_inner(SemaContext *context, Expr *expr, Typ
|
||||
case TYPE_TYPEDEF:
|
||||
inner = type->decl->distinct->type->canonical;
|
||||
break;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_ENUM:
|
||||
inner = enum_inner_type(type)->canonical;
|
||||
break;
|
||||
@@ -5954,7 +5954,7 @@ static bool sema_type_property_is_valid_for_type(CanonicalType *original_type, T
|
||||
case TYPE_OPTIONAL:
|
||||
case TYPE_TYPEDEF:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_BITSTRUCT:
|
||||
case TYPE_ARRAY:
|
||||
case TYPE_FLEXIBLE_ARRAY:
|
||||
@@ -5977,7 +5977,7 @@ static bool sema_type_property_is_valid_for_type(CanonicalType *original_type, T
|
||||
case TYPE_PROPERTY_IS_SUBSTRUCT:
|
||||
return type->type_kind == TYPE_STRUCT;
|
||||
case TYPE_PROPERTY_LEN:
|
||||
if (original_type->type_kind == TYPE_CONST_ENUM) return true;
|
||||
if (original_type->type_kind == TYPE_CONSTDEF) return true;
|
||||
switch (type->type_kind)
|
||||
{
|
||||
case TYPE_ARRAY:
|
||||
@@ -5996,7 +5996,7 @@ static bool sema_type_property_is_valid_for_type(CanonicalType *original_type, T
|
||||
case TYPE_PROPERTY_FROM_ORDINAL:
|
||||
case TYPE_PROPERTY_NAMES:
|
||||
case TYPE_PROPERTY_VALUES:
|
||||
return type->type_kind == TYPE_ENUM || original_type->canonical->type_kind == TYPE_CONST_ENUM;
|
||||
return type->type_kind == TYPE_ENUM || original_type->canonical->type_kind == TYPE_CONSTDEF;
|
||||
case TYPE_PROPERTY_ELEMENTS:
|
||||
case TYPE_PROPERTY_ASSOCIATED:
|
||||
return type->type_kind == TYPE_ENUM;
|
||||
@@ -6090,7 +6090,7 @@ static bool sema_expr_rewrite_to_type_property(SemaContext *context, Expr *expr,
|
||||
case TYPE_PROPERTY_MAX:
|
||||
return sema_create_const_max(expr, type, flat);
|
||||
case TYPE_PROPERTY_NAMES:
|
||||
if (type->type_kind == TYPE_CONST_ENUM)
|
||||
if (type->type_kind == TYPE_CONSTDEF)
|
||||
{
|
||||
return sema_expr_replace_with_enum_name_array(context, expr, type->decl);
|
||||
}
|
||||
@@ -6105,7 +6105,7 @@ static bool sema_expr_rewrite_to_type_property(SemaContext *context, Expr *expr,
|
||||
expr_rewrite_const_int(expr, type_isz, vec_size(flat->decl->enums.values));
|
||||
return true;
|
||||
case TYPE_PROPERTY_VALUES:
|
||||
if (type->type_kind == TYPE_CONST_ENUM)
|
||||
if (type->type_kind == TYPE_CONSTDEF)
|
||||
{
|
||||
return sema_expr_replace_with_const_enum_array(context, expr, type->decl);
|
||||
}
|
||||
@@ -6560,7 +6560,7 @@ CHECK_DEEPER:
|
||||
}
|
||||
if (kw == kw_nameof)
|
||||
{
|
||||
if (flat_type->type_kind == TYPE_CONST_ENUM)
|
||||
if (flat_type->type_kind == TYPE_CONSTDEF)
|
||||
{
|
||||
if (sema_cast_const(current_parent))
|
||||
{
|
||||
@@ -7076,7 +7076,7 @@ bool sema_expr_analyse_assign_right_side(SemaContext *context, Expr *expr, Type
|
||||
switch (left_type->type_kind)
|
||||
{
|
||||
case TYPE_TYPEDEF:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
is_declaration = false;
|
||||
break;
|
||||
default:
|
||||
@@ -8648,7 +8648,7 @@ BoolErr sema_type_can_check_equality_with_overload(SemaContext *context, Type *t
|
||||
type = type->array.base;
|
||||
goto RETRY;
|
||||
case TYPE_TYPEDEF:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
if (sema_type_has_equality_overload(context, type)) return true;
|
||||
type = type_inline(type);
|
||||
goto RETRY;
|
||||
|
||||
@@ -1021,7 +1021,7 @@ bool sema_resolve_type_decl(SemaContext *context, Type *type)
|
||||
if (!type->function.prototype && type->function.decl->decl_kind == DECL_FNTYPE) return sema_analyse_decl(context, type->function.decl);
|
||||
return true;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_BITSTRUCT:
|
||||
@@ -1067,7 +1067,7 @@ Decl *sema_resolve_type_method(SemaContext *context, CanonicalType *type, const
|
||||
type = type_decl->distinct->type->canonical;
|
||||
goto RETRY;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = enum_inner_type(type)->canonical;
|
||||
goto RETRY;
|
||||
default:
|
||||
|
||||
@@ -2693,7 +2693,7 @@ static inline bool sema_analyse_ct_switch_stmt(SemaContext *context, Ast *statem
|
||||
is_type = true;
|
||||
FALLTHROUGH;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case ALL_INTS:
|
||||
case ALL_FLOATS:
|
||||
case TYPE_BOOL:
|
||||
|
||||
@@ -141,7 +141,7 @@ void type_append_name_to_scratch(Type *type)
|
||||
case TYPE_ALIAS:
|
||||
UNREACHABLE_VOID;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_TYPEDEF:
|
||||
@@ -276,7 +276,7 @@ const char *type_to_error_string(Type *type)
|
||||
case TYPE_WILDCARD:
|
||||
return type->name;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_ALIAS:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
@@ -343,7 +343,7 @@ static const char *type_to_error_string_with_path(Type *type)
|
||||
case TYPE_WILDCARD:
|
||||
return type->name;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_ALIAS:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
@@ -434,7 +434,7 @@ TypeSize type_size(Type *type)
|
||||
case TYPE_ALIAS:
|
||||
return type->size = type_size(type->canonical);
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
ASSERT(type->decl->enums.type_info->resolve_status == RESOLVE_DONE);
|
||||
return type->size = type_size(enum_inner_type(type)->canonical);
|
||||
case TYPE_STRUCT:
|
||||
@@ -546,7 +546,7 @@ bool type_is_aggregate(Type *type)
|
||||
case TYPE_TYPEID:
|
||||
case TYPE_POINTER:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_FUNC_PTR:
|
||||
case TYPE_FUNC_RAW:
|
||||
case VECTORS:
|
||||
@@ -591,7 +591,7 @@ bool type_is_ordered(Type *type)
|
||||
case TYPE_POINTER:
|
||||
case TYPE_BOOL:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
return true;
|
||||
case TYPE_ALIAS:
|
||||
type = type->canonical;
|
||||
@@ -634,7 +634,7 @@ bool type_is_comparable(Type *type)
|
||||
type = type->array.base;
|
||||
goto RETRY;
|
||||
case TYPE_TYPEDEF:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = type_inline(type);
|
||||
goto RETRY;
|
||||
case TYPE_BOOL:
|
||||
@@ -739,7 +739,7 @@ void type_mangle_introspect_name_to_buffer(Type *type)
|
||||
}
|
||||
return;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_BITSTRUCT:
|
||||
@@ -824,7 +824,7 @@ INLINE AlignSize type_alignment_(Type *type, bool alloca)
|
||||
type = type->canonical;
|
||||
goto RETRY;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = enum_inner_type(type)->canonical;
|
||||
goto RETRY;
|
||||
case TYPE_STRUCT:
|
||||
@@ -1206,7 +1206,7 @@ Type *type_get_indexed_type(Type *type)
|
||||
case TYPE_FLEXIBLE_ARRAY:
|
||||
case VECTORS:
|
||||
return type->array.base;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
type = enum_inner_type(type);
|
||||
goto RETRY;
|
||||
case TYPE_TYPEDEF:
|
||||
@@ -1329,7 +1329,7 @@ bool type_is_valid_for_array(Type *type)
|
||||
case TYPE_TYPEID:
|
||||
case TYPE_POINTER:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_FUNC_PTR:
|
||||
case TYPE_FUNC_RAW:
|
||||
case TYPE_STRUCT:
|
||||
@@ -1617,7 +1617,7 @@ bool type_is_scalar(Type *type)
|
||||
case TYPE_POINTER:
|
||||
case TYPE_FUNC_PTR:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_ANYFAULT:
|
||||
return true;
|
||||
case TYPE_BITSTRUCT:
|
||||
@@ -1643,7 +1643,7 @@ Type *type_find_parent_type(Type *type)
|
||||
Decl *decl;
|
||||
switch (type->type_kind)
|
||||
{
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
decl = type->decl;
|
||||
return decl->is_substruct ? decl->enums.type_info->type : NULL;
|
||||
case TYPE_TYPEDEF:
|
||||
@@ -1882,7 +1882,7 @@ bool type_may_have_method(Type *type)
|
||||
case TYPE_UNION:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_BITSTRUCT:
|
||||
case ALL_FLOATS:
|
||||
case ALL_INTS:
|
||||
@@ -1925,7 +1925,7 @@ bool type_may_have_sub_elements(Type *type)
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_ENUM:
|
||||
case TYPE_BITSTRUCT:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_INTERFACE:
|
||||
return true;
|
||||
default:
|
||||
@@ -2229,7 +2229,7 @@ RETRY_DISTINCT:
|
||||
if (other->pointer->function.prototype->raw_type != type->pointer->function.prototype->raw_type) return NULL;
|
||||
return type;
|
||||
case TYPE_TYPEDEF:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
if (type_is_distinct_like(other))
|
||||
{
|
||||
return type_find_max_distinct_type(type, other);
|
||||
@@ -2351,7 +2351,7 @@ unsigned type_get_introspection_kind(TypeKind kind)
|
||||
return INTROSPECT_TYPE_POINTER;
|
||||
case TYPE_ENUM:
|
||||
return INTROSPECT_TYPE_ENUM;
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
return INTROSPECT_TYPE_CONST_ENUM;
|
||||
case TYPE_FUNC_PTR:
|
||||
return INTROSPECT_TYPE_FUNC;
|
||||
@@ -2410,7 +2410,7 @@ Module *type_base_module(Type *type)
|
||||
case TYPE_FUNC_RAW:
|
||||
return type->function.decl ? type->function.decl->unit->module : NULL;
|
||||
case TYPE_ENUM:
|
||||
case TYPE_CONST_ENUM:
|
||||
case TYPE_CONSTDEF:
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
case TYPE_BITSTRUCT:
|
||||
|
||||
Reference in New Issue
Block a user