gingerBill před 1 rokem
rodič
revize
a61ae7c861

+ 14 - 6
src/check_type.cpp

@@ -2495,18 +2495,16 @@ gb_internal Type *get_map_cell_type(Type *type) {
 	return s;
 }
 
-gb_internal void init_map_internal_types(Type *type) {
+gb_internal void init_map_internal_debug_types(Type *type) {
 	GB_ASSERT(type->kind == Type_Map);
 	GB_ASSERT(t_allocator != nullptr);
-	if (type->Map.lookup_result_type != nullptr) return;
+	if (type->Map.debug_metadata_type != nullptr) return;
 
 	Type *key   = type->Map.key;
 	Type *value = type->Map.value;
 	GB_ASSERT(key != nullptr);
 	GB_ASSERT(value != nullptr);
 
-
-
 	Type *key_cell   = get_map_cell_type(key);
 	Type *value_cell = get_map_cell_type(value);
 
@@ -2541,6 +2539,18 @@ gb_internal void init_map_internal_types(Type *type) {
 	gb_unused(type_size_of(debug_type));
 
 	type->Map.debug_metadata_type = debug_type;
+}
+
+
+gb_internal void init_map_internal_types(Type *type) {
+	GB_ASSERT(type->kind == Type_Map);
+	GB_ASSERT(t_allocator != nullptr);
+	if (type->Map.lookup_result_type != nullptr) return;
+
+	Type *key   = type->Map.key;
+	Type *value = type->Map.value;
+	GB_ASSERT(key != nullptr);
+	GB_ASSERT(value != nullptr);
 
 	type->Map.lookup_result_type = make_optional_ok_type(value);
 }
@@ -2613,8 +2623,6 @@ gb_internal void check_map_type(CheckerContext *ctx, Type *type, Ast *node) {
 
 	init_core_map_type(ctx->checker);
 	init_map_internal_types(type);
-
-	// error(node, "'map' types are not yet implemented");
 }
 
 gb_internal void check_matrix_type(CheckerContext *ctx, Type **type, Ast *node) {

+ 4 - 1
src/checker.hpp

@@ -563,4 +563,7 @@ gb_internal void init_mem_allocator(Checker *c);
 gb_internal void add_untyped_expressions(CheckerInfo *cinfo, UntypedExprInfoMap *untyped);
 
 
-gb_internal GenTypesData *ensure_polymorphic_record_entity_has_gen_types(CheckerContext *ctx, Type *original_type);
+gb_internal GenTypesData *ensure_polymorphic_record_entity_has_gen_types(CheckerContext *ctx, Type *original_type);
+
+
+gb_internal void init_map_internal_types(Type *type);

+ 1 - 1
src/llvm_backend_general.cpp

@@ -2070,7 +2070,7 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
 		break;
 
 	case Type_Map:
-		init_map_internal_types(type);
+		init_map_internal_debug_types(type);
 		GB_ASSERT(t_raw_map != nullptr);
 		return lb_type_internal(m, t_raw_map);
 

+ 1 - 1
src/llvm_backend_type.cpp

@@ -903,7 +903,7 @@ gb_internal void lb_setup_type_info_data_giant_array(lbModule *m, i64 global_typ
 
 		case Type_Map: {
 			tag_type = t_type_info_map;
-			init_map_internal_types(t);
+			init_map_internal_debug_types(t);
 
 			LLVMValueRef vals[3] = {
 				get_type_info_ptr(m, t->Map.key),

+ 2 - 2
src/llvm_backend_utility.cpp

@@ -1125,7 +1125,7 @@ gb_internal lbValue lb_emit_struct_ep(lbProcedure *p, lbValue s, i32 index) {
 		case 3: result_type = t_allocator; break;
 		}
 	} else if (is_type_map(t)) {
-		init_map_internal_types(t);
+		init_map_internal_debug_types(t);
 		Type *itp = alloc_type_pointer(t_raw_map);
 		s = lb_emit_transmute(p, s, itp);
 
@@ -1264,7 +1264,7 @@ gb_internal lbValue lb_emit_struct_ev(lbProcedure *p, lbValue s, i32 index) {
 
 	case Type_Map:
 		{
-			init_map_internal_types(t);
+			init_map_internal_debug_types(t);
 			switch (index) {
 			case 0: result_type = get_struct_field_type(t_raw_map, 0); break;
 			case 1: result_type = get_struct_field_type(t_raw_map, 1); break;

+ 0 - 1
src/types.cpp

@@ -769,7 +769,6 @@ gb_internal gbString type_to_string (Type *type, bool shorthand=true);
 gb_internal gbString type_to_string (Type *type, gbAllocator allocator, bool shorthand=true);
 gb_internal i64      type_size_of_internal(Type *t, TypePath *path);
 gb_internal i64     type_align_of_internal(Type *t, TypePath *path);
-gb_internal void     init_map_internal_types(Type *type);
 gb_internal Type *   bit_set_to_int(Type *t);
 gb_internal bool     are_types_identical(Type *x, Type *y);