Allow for base enum type with an enum declaration

This commit is contained in:
gingerBill
2018-06-11 22:50:13 +01:00
parent 555fe37ad8
commit 8236c6d4b7
6 changed files with 51 additions and 47 deletions
+6
View File
@@ -486,6 +486,12 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type
} }
} }
if (is_type_enum(dst) && are_types_identical(dst->Enum.base_type, operand->type)) {
if (c->in_enum_type) {
return 3;
}
}
#if 0 #if 0
if (are_types_identical(dst, src) && (!is_type_named(dst) || !is_type_named(src))) { if (are_types_identical(dst, src) && (!is_type_named(dst) || !is_type_named(src))) {
return 1; return 1;
+1
View File
@@ -1931,6 +1931,7 @@ bool check_type_internal(CheckerContext *ctx, AstNode *e, Type **type, Type *nam
bool ips = ctx->in_polymorphic_specialization; bool ips = ctx->in_polymorphic_specialization;
defer (ctx->in_polymorphic_specialization = ips); defer (ctx->in_polymorphic_specialization = ips);
ctx->in_polymorphic_specialization = false; ctx->in_polymorphic_specialization = false;
ctx->in_enum_type = true;
*type = alloc_type_enum(); *type = alloc_type_enum();
set_base_type(named_type, *type); set_base_type(named_type, *type);
-3
View File
@@ -549,9 +549,6 @@ void init_universal_scope(void) {
add_global_constant(str_lit("false"), t_untyped_bool, exact_value_bool(false)); add_global_constant(str_lit("false"), t_untyped_bool, exact_value_bool(false));
add_global_entity(alloc_entity_nil(str_lit("nil"), t_untyped_nil)); add_global_entity(alloc_entity_nil(str_lit("nil"), t_untyped_nil));
// add_global_entity(alloc_entity_library_name(universal_scope,
// make_token_ident(str_lit("__llvm_core")), t_invalid,
// str_lit(""), str_lit("__llvm_core")));
// TODO(bill): Set through flags in the compiler // TODO(bill): Set through flags in the compiler
add_global_string_constant(str_lit("ODIN_VENDOR"), bc->ODIN_VENDOR); add_global_string_constant(str_lit("ODIN_VENDOR"), bc->ODIN_VENDOR);
+1
View File
@@ -343,6 +343,7 @@ struct CheckerContext {
CheckerTypePath *type_path; CheckerTypePath *type_path;
isize type_level; // TODO(bill): Actually handle correctly isize type_level; // TODO(bill): Actually handle correctly
bool in_enum_type;
bool collect_delayed_decls; bool collect_delayed_decls;
bool allow_polymorphic_types; bool allow_polymorphic_types;
bool no_polymorphic_errors; bool no_polymorphic_errors;
-1
View File
@@ -1030,7 +1030,6 @@ AstNode *ast_attribute(AstFile *f, Token token, Token open, Token close, Array<A
bool next_token0(AstFile *f) { bool next_token0(AstFile *f) {
// Token prev = f->curr_token;
if (f->curr_token_index+1 < f->tokens.count) { if (f->curr_token_index+1 < f->tokens.count) {
f->curr_token = f->tokens[++f->curr_token_index]; f->curr_token = f->tokens[++f->curr_token_index];
return true; return true;