mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Correct parapoly determination of generated internal type of a map
This commit is contained in:
+7
-1
@@ -1360,7 +1360,13 @@ bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source,
|
|||||||
if (source->kind == Type_Map) {
|
if (source->kind == Type_Map) {
|
||||||
bool key = is_polymorphic_type_assignable(c, poly->Map.key, source->Map.key, true, modify_type);
|
bool key = is_polymorphic_type_assignable(c, poly->Map.key, source->Map.key, true, modify_type);
|
||||||
bool value = is_polymorphic_type_assignable(c, poly->Map.value, source->Map.value, true, modify_type);
|
bool value = is_polymorphic_type_assignable(c, poly->Map.value, source->Map.value, true, modify_type);
|
||||||
return key || value;
|
if (key || value) {
|
||||||
|
poly->Map.entry_type = nullptr;
|
||||||
|
poly->Map.internal_type = nullptr;
|
||||||
|
poly->Map.lookup_result_type = nullptr;
|
||||||
|
init_map_internal_types(poly);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -2211,7 +2211,6 @@ void init_map_internal_types(Type *type) {
|
|||||||
GB_ASSERT(type->kind == Type_Map);
|
GB_ASSERT(type->kind == Type_Map);
|
||||||
init_map_entry_type(type);
|
init_map_entry_type(type);
|
||||||
if (type->Map.internal_type != nullptr) return;
|
if (type->Map.internal_type != nullptr) return;
|
||||||
if (type->Map.generated_struct_type != nullptr) return;
|
|
||||||
|
|
||||||
Type *key = type->Map.key;
|
Type *key = type->Map.key;
|
||||||
Type *value = type->Map.value;
|
Type *value = type->Map.value;
|
||||||
@@ -2239,7 +2238,6 @@ void init_map_internal_types(Type *type) {
|
|||||||
generated_struct_type->Struct.fields = fields;
|
generated_struct_type->Struct.fields = fields;
|
||||||
type_set_offsets(generated_struct_type);
|
type_set_offsets(generated_struct_type);
|
||||||
|
|
||||||
type->Map.generated_struct_type = generated_struct_type;
|
|
||||||
type->Map.internal_type = generated_struct_type;
|
type->Map.internal_type = generated_struct_type;
|
||||||
type->Map.lookup_result_type = make_optional_ok_type(value);
|
type->Map.lookup_result_type = make_optional_ok_type(value);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1922,7 +1922,7 @@ void add_type_info_type_internal(CheckerContext *c, Type *t) {
|
|||||||
init_map_internal_types(bt);
|
init_map_internal_types(bt);
|
||||||
add_type_info_type_internal(c, bt->Map.key);
|
add_type_info_type_internal(c, bt->Map.key);
|
||||||
add_type_info_type_internal(c, bt->Map.value);
|
add_type_info_type_internal(c, bt->Map.value);
|
||||||
add_type_info_type_internal(c, bt->Map.generated_struct_type);
|
add_type_info_type_internal(c, bt->Map.internal_type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Type_Tuple:
|
case Type_Tuple:
|
||||||
@@ -2144,7 +2144,7 @@ void add_min_dep_type_info(Checker *c, Type *t) {
|
|||||||
init_map_internal_types(bt);
|
init_map_internal_types(bt);
|
||||||
add_min_dep_type_info(c, bt->Map.key);
|
add_min_dep_type_info(c, bt->Map.key);
|
||||||
add_min_dep_type_info(c, bt->Map.value);
|
add_min_dep_type_info(c, bt->Map.value);
|
||||||
add_min_dep_type_info(c, bt->Map.generated_struct_type);
|
add_min_dep_type_info(c, bt->Map.internal_type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Type_Tuple:
|
case Type_Tuple:
|
||||||
|
|||||||
@@ -521,7 +521,6 @@ lbValue lb_gen_map_header_table_internal(lbProcedure *p, Type *map_type) {
|
|||||||
i64 value_offset = type_offset_of(map_type->Map.entry_type, 3);
|
i64 value_offset = type_offset_of(map_type->Map.entry_type, 3);
|
||||||
i64 value_size = type_size_of (map_type->Map.value);
|
i64 value_size = type_size_of (map_type->Map.value);
|
||||||
|
|
||||||
|
|
||||||
Type *key_type = map_type->Map.key;
|
Type *key_type = map_type->Map.key;
|
||||||
Type *val_type = map_type->Map.value;
|
Type *val_type = map_type->Map.value;
|
||||||
gb_unused(val_type);
|
gb_unused(val_type);
|
||||||
|
|||||||
@@ -787,7 +787,7 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da
|
|||||||
tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_map_ptr);
|
tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_map_ptr);
|
||||||
init_map_internal_types(t);
|
init_map_internal_types(t);
|
||||||
|
|
||||||
lbValue gst = lb_type_info(m, t->Map.generated_struct_type);
|
lbValue gst = lb_type_info(m, t->Map.internal_type);
|
||||||
|
|
||||||
LLVMValueRef vals[5] = {
|
LLVMValueRef vals[5] = {
|
||||||
lb_type_info(m, t->Map.key).value,
|
lb_type_info(m, t->Map.key).value,
|
||||||
|
|||||||
@@ -1130,7 +1130,7 @@ lbValue lb_emit_struct_ev(lbProcedure *p, lbValue s, i32 index) {
|
|||||||
case Type_Map:
|
case Type_Map:
|
||||||
{
|
{
|
||||||
init_map_internal_types(t);
|
init_map_internal_types(t);
|
||||||
Type *gst = t->Map.generated_struct_type;
|
Type *gst = t->Map.internal_type;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: result_type = get_struct_field_type(gst, 0); break;
|
case 0: result_type = get_struct_field_type(gst, 0); break;
|
||||||
case 1: result_type = get_struct_field_type(gst, 1); break;
|
case 1: result_type = get_struct_field_type(gst, 1); break;
|
||||||
|
|||||||
@@ -227,7 +227,6 @@ struct TypeProc {
|
|||||||
Type *key; \
|
Type *key; \
|
||||||
Type *value; \
|
Type *value; \
|
||||||
Type *entry_type; \
|
Type *entry_type; \
|
||||||
Type *generated_struct_type; \
|
|
||||||
Type *internal_type; \
|
Type *internal_type; \
|
||||||
Type *lookup_result_type; \
|
Type *lookup_result_type; \
|
||||||
}) \
|
}) \
|
||||||
|
|||||||
Reference in New Issue
Block a user