Update subtype based Type_Info

This commit is contained in:
gingerBill
2025-06-10 09:58:16 +01:00
parent 3b9ce3f142
commit 4a044a0fce
5 changed files with 16 additions and 32 deletions

View File

@@ -612,7 +612,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
case:
panic("unknown bit_size size")
}
case runtime.Type_Info_Matrix:
case ^runtime.Type_Info_Matrix:
count := info.column_count * info.elem_stride
err_conv(_encode_u64(e, u64(count), .Array)) or_return
@@ -631,7 +631,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
}
return
case runtime.Type_Info_Simd_Vector:
case ^runtime.Type_Info_Simd_Vector:
err_conv(_encode_u64(e, u64(info.count), .Array)) or_return
if impl, ok := _tag_implementations_type[info.elem.id]; ok {

View File

@@ -591,7 +591,7 @@ _unmarshal_array :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
if out_of_space { return _unsupported(v, hdr) }
return
case reflect.Type_Info_Matrix:
case ^reflect.Type_Info_Matrix:
count := t.column_count * t.elem_stride
length, _ := err_conv(_decode_len_container(d, add)) or_return
if length > count {
@@ -604,7 +604,7 @@ _unmarshal_array :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
if out_of_space { return _unsupported(v, hdr) }
return
case reflect.Type_Info_Simd_Vector:
case ^reflect.Type_Info_Simd_Vector:
length, _ := err_conv(_decode_len_container(d, add)) or_return
if length > t.count {
return _unsupported(v, hdr)

View File

@@ -123,7 +123,7 @@ assign_int :: proc(val: any, i: $T) -> bool {
}
t := runtime.type_info_base(ti)
#partial switch info in t.variant {
case runtime.Type_Info_Integer:
case ^runtime.Type_Info_Integer:
switch info.endianness {
case .Platform: return false
case .Little: return ODIN_ENDIAN != .Little

View File

@@ -261,7 +261,7 @@ length :: proc(val: any) -> int {
return (^runtime.Raw_String)(val.data).len
}
case Type_Info_Simd_Vector:
case ^Type_Info_Simd_Vector:
return a.count
}
@@ -291,7 +291,7 @@ capacity :: proc(val: any) -> int {
case ^Type_Info_Map:
return runtime.map_cap((^runtime.Raw_Map)(val.data)^)
case Type_Info_Simd_Vector:
case ^Type_Info_Simd_Vector:
return a.count
}
@@ -1656,11 +1656,11 @@ equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_
return equal(va, vb, including_indirect_array_recursion, recursion_level+1)
case ^Type_Info_Map:
return false
case Type_Info_Float:
case ^Type_Info_Float:
x, _ := as_f64(a)
y, _ := as_f64(b)
return x == y
case Type_Info_Complex:
case ^Type_Info_Complex:
switch x in a {
case complex32:
#no_type_assert y := b.(complex32)
@@ -1673,7 +1673,7 @@ equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_
return x == y
}
return false
case Type_Info_Quaternion:
case ^Type_Info_Quaternion:
switch x in a {
case quaternion64:
#no_type_assert y := b.(quaternion64)

View File

@@ -594,29 +594,13 @@ gb_internal void lb_setup_type_info_data_giant_array(lbModule *m, i64 global_typ
lbValue v_count = lb_const_int(m, t_int, fields.count);
vals[1] = llvm_const_slice(m, lbValue{name_array.value, alloc_type_pointer(t_string)}, v_count);
vals[2] = llvm_const_slice(m, lbValue{value_array.value, alloc_type_pointer(t_type_info_enum_value)}, v_count);
else {
vals[1] = LLVMConstNull(lb_type(m, base_type(t_type_info_enum)->Struct.fields[1]->type));
vals[2] = LLVMConstNull(lb_type(m, base_type(t_type_info_enum)->Struct.fields[2]->type));
vals[2] = llvm_const_slice(m, lbValue{name_array.value, alloc_type_pointer(t_string)}, v_count);
vals[3] = llvm_const_slice(m, lbValue{value_array.value, alloc_type_pointer(t_type_info_enum_value)}, v_count);
} else {
vals[2] = LLVMConstNull(LLVMStructGetTypeAtIndex(stype, 2));
vals[3] = LLVMConstNull(LLVMStructGetTypeAtIndex(stype, 3));
}
LLVMValueRef name_init = llvm_const_array(lb_type(m, t_string), name_values, cast(unsigned)fields.count);
LLVMValueRef value_init = llvm_const_array(lb_type(m, t_type_info_enum_value), value_values, cast(unsigned)fields.count);
LLVMSetInitializer(name_array.value, name_init);
LLVMSetInitializer(value_array.value, value_init);
LLVMSetGlobalConstant(name_array.value, true);
LLVMSetGlobalConstant(value_array.value, true);
lbValue v_count = lb_const_int(m, t_int, fields.count);
vals[2] = llvm_const_slice(m, lbValue{name_array.value, alloc_type_pointer(t_string)}, v_count);
vals[3] = llvm_const_slice(m, lbValue{value_array.value, alloc_type_pointer(t_type_info_enum_value)}, v_count);
} else {
vals[2] = LLVMConstNull(LLVMStructGetTypeAtIndex(stype, 2));
vals[3] = LLVMConstNull(LLVMStructGetTypeAtIndex(stype, 3));
}
break;
break;
case Type_Union: {
tag_type = t_type_info_union;