mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-03 03:32:37 +00:00
Add experimental atom op tables for llvm-backend
This commit is contained in:
@@ -256,9 +256,6 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def)
|
||||
GB_ASSERT(e->type == nullptr);
|
||||
|
||||
DeclInfo *decl = decl_info_of_entity(e);
|
||||
if (decl != nullptr) {
|
||||
check_decl_attributes(ctx, decl->attributes, const_decl_attribute, nullptr);
|
||||
}
|
||||
|
||||
bool is_distinct = is_type_distinct(init_expr);
|
||||
Ast *te = remove_type_alias_clutter(init_expr);
|
||||
@@ -280,6 +277,10 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def)
|
||||
error(init_expr, "'distinct' cannot be applied to 'typeid'");
|
||||
is_distinct = false;
|
||||
}
|
||||
if (is_distinct && is_type_any(e->type)) {
|
||||
error(init_expr, "'distinct' cannot be applied to 'any'");
|
||||
is_distinct = false;
|
||||
}
|
||||
if (!is_distinct) {
|
||||
e->type = bt;
|
||||
named->Named.base = bt;
|
||||
@@ -298,6 +299,23 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def)
|
||||
}
|
||||
}
|
||||
|
||||
if (decl != nullptr) {
|
||||
AttributeContext ac = {};
|
||||
check_decl_attributes(ctx, decl->attributes, type_decl_attribute, &ac);
|
||||
if (ac.atom_op_table != nullptr) {
|
||||
Type *bt = base_type(e->type);
|
||||
switch (bt->kind) {
|
||||
case Type_Struct:
|
||||
bt->Struct.atom_op_table = ac.atom_op_table;
|
||||
break;
|
||||
default:
|
||||
error(e->token, "Only struct types can have custom atom operations");
|
||||
gb_free(heap_allocator(), ac.atom_op_table);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// using decl
|
||||
if (decl->is_using) {
|
||||
|
||||
Reference in New Issue
Block a user