diff options
| author | gingerBill <bill@gingerbill.org> | 2020-11-23 16:56:31 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-11-23 16:56:31 +0000 |
| commit | 4762d2f2d15d64e012e2de876f1fd78c3ebd7c3e (patch) | |
| tree | 31673f9df6ebb1fa7041fcd31ac6105baa6a6a6f /src | |
| parent | 67bc35e882800164c2a7a30cadc237d4051a4b46 (diff) | |
map type internal reorganization
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_type.cpp | 17 | ||||
| -rw-r--r-- | src/checker.cpp | 8 | ||||
| -rw-r--r-- | src/ir.cpp | 2 | ||||
| -rw-r--r-- | src/llvm_backend.cpp | 2 | ||||
| -rw-r--r-- | src/types.cpp | 2 |
5 files changed, 15 insertions, 16 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index dfd0f093d..a3b71a034 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2784,24 +2784,23 @@ void init_map_entry_type(Type *type) { if (type->Map.entry_type != nullptr) return; // NOTE(bill): The preload types may have not been set yet - GB_ASSERT(t_map_key != nullptr); + GB_ASSERT(t_map_hash != nullptr); Type *entry_type = alloc_type_struct(); /* struct { - hash: __MapKey; - next: int; - key: Key; - value: Value; + key: runtime.Map_Key, + next: int, + value: Value, } */ Ast *dummy_node = alloc_ast_node(nullptr, Ast_Invalid); Scope *s = create_scope(builtin_pkg->scope); - auto fields = array_make<Entity *>(permanent_allocator(), 0, 3); - array_add(&fields, alloc_entity_field(s, make_token_ident(str_lit("key")), t_map_key, false, 0, EntityState_Resolved)); - array_add(&fields, alloc_entity_field(s, make_token_ident(str_lit("next")), t_int, false, 1, EntityState_Resolved)); - array_add(&fields, alloc_entity_field(s, make_token_ident(str_lit("value")), type->Map.value, false, 2, EntityState_Resolved)); + auto fields = array_make<Entity *>(permanent_allocator(), 0, 4); + array_add(&fields, alloc_entity_field(s, make_token_ident(str_lit("key")), t_map_hash, false, cast(i32)fields.count, EntityState_Resolved)); + array_add(&fields, alloc_entity_field(s, make_token_ident(str_lit("next")), t_int, false, cast(i32)fields.count, EntityState_Resolved)); + array_add(&fields, alloc_entity_field(s, make_token_ident(str_lit("value")), type->Map.value, false, cast(i32)fields.count, EntityState_Resolved)); entry_type->Struct.fields = fields; diff --git a/src/checker.cpp b/src/checker.cpp index bba790cb2..efa7d76f7 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -2278,14 +2278,14 @@ void init_core_source_code_location(Checker *c) { } void init_core_map_type(Checker *c) { - if (t_map_key == nullptr) { - Entity *e = find_core_entity(c, str_lit("Map_Key")); + if (t_map_hash == nullptr) { + Entity *e = find_core_entity(c, str_lit("Map_Hash")); if (e->state == EntityState_Unresolved) { auto ctx = c->init_ctx; check_entity_decl(&ctx, e, nullptr, nullptr); } - t_map_key = e->type; - GB_ASSERT(t_map_key != nullptr); + t_map_hash = e->type; + GB_ASSERT(t_map_hash != nullptr); } if (t_map_header == nullptr) { diff --git a/src/ir.cpp b/src/ir.cpp index 28edd5981..634e0a698 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -3608,7 +3608,7 @@ irValue *ir_gen_map_header(irProcedure *proc, irValue *map_val_ptr, Type *map_ty irValue *ir_gen_map_key(irProcedure *proc, irValue *key, Type *key_type) { Type *hash_type = t_u64; - irValue *v = ir_add_local_generated(proc, t_map_key, true); + irValue *v = ir_add_local_generated(proc, t_map_hash, true); Type *t = base_type(ir_type(key)); key = ir_emit_conv(proc, key, key_type); diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 0272d1dfa..1fb0891b5 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -10259,7 +10259,7 @@ lbValue lb_gen_map_header(lbProcedure *p, lbValue map_val_ptr, Type *map_type) { lbValue lb_gen_map_key(lbProcedure *p, lbValue key, Type *key_type) { Type *hash_type = t_u64; - lbAddr v = lb_add_local_generated(p, t_map_key, true); + lbAddr v = lb_add_local_generated(p, t_map_hash, true); lbValue vp = lb_addr_get_ptr(p, v); Type *t = base_type(key.type); key = lb_emit_conv(p, key, key_type); diff --git a/src/types.cpp b/src/types.cpp index 0fc529213..7ca9a3cc2 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -684,7 +684,7 @@ gb_global Type *t_context_ptr = nullptr; gb_global Type *t_source_code_location = nullptr; gb_global Type *t_source_code_location_ptr = nullptr; -gb_global Type *t_map_key = nullptr; +gb_global Type *t_map_hash = nullptr; gb_global Type *t_map_header = nullptr; gb_global Type *t_vector_x86_mmx = nullptr; |