Type_Info_* -> ^Type_Info_*

This commit is contained in:
gingerBill
2025-03-06 09:48:48 +00:00
parent 19188a6e5c
commit 33939f09b6
14 changed files with 146 additions and 146 deletions

View File

@@ -104,16 +104,16 @@ marshal_into_encoder :: proc(e: Encoder, v: any) -> (err: Marshal_Error) {
_marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (err: Marshal_Error) {
a := any{v.data, ti.id}
#partial switch info in ti.variant {
case runtime.Type_Info_Named, runtime.Type_Info_Enum, runtime.Type_Info_Bit_Field:
case ^runtime.Type_Info_Named, ^runtime.Type_Info_Enum, ^runtime.Type_Info_Bit_Field:
unreachable()
case runtime.Type_Info_Pointer:
case ^runtime.Type_Info_Pointer:
switch vv in v {
case Undefined: return _encode_undefined(e.writer)
case Nil: return _encode_nil(e.writer)
}
case runtime.Type_Info_Integer:
case ^runtime.Type_Info_Integer:
switch vv in v {
case Simple: return err_conv(_encode_simple(e.writer, vv))
case Negative_U8: return _encode_u8(e.writer, u8(vv), .Negative)
@@ -159,11 +159,11 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
case u128be: return err_conv(_encode_uint(e, _u128_to_u64(u128(i)) or_return))
}
case runtime.Type_Info_Rune:
case ^runtime.Type_Info_Rune:
buf, w := utf8.encode_rune(a.(rune))
return err_conv(_encode_text(e, string(buf[:w])))
case runtime.Type_Info_Float:
case ^runtime.Type_Info_Float:
switch f in a {
case f16: return _encode_f16(e.writer, f)
case f32: return _encode_f32(e, f)
@@ -178,7 +178,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
case f64be: return _encode_f64(e, f64(f))
}
case runtime.Type_Info_Complex:
case ^runtime.Type_Info_Complex:
switch z in a {
case complex32:
arr: [2]Value = {real(z), imag(z)}
@@ -191,7 +191,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
return err_conv(_encode_array(e, arr[:]))
}
case runtime.Type_Info_Quaternion:
case ^runtime.Type_Info_Quaternion:
switch q in a {
case quaternion64:
arr: [4]Value = {imag(q), jmag(q), kmag(q), real(q)}
@@ -204,13 +204,13 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
return err_conv(_encode_array(e, arr[:]))
}
case runtime.Type_Info_String:
case ^runtime.Type_Info_String:
switch s in a {
case string: return err_conv(_encode_text(e, s))
case cstring: return err_conv(_encode_text(e, string(s)))
}
case runtime.Type_Info_Boolean:
case ^runtime.Type_Info_Boolean:
switch b in a {
case bool: return _encode_bool(e.writer, b)
case b8: return _encode_bool(e.writer, bool(b))
@@ -219,7 +219,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
case b64: return _encode_bool(e.writer, bool(b))
}
case runtime.Type_Info_Array:
case ^runtime.Type_Info_Array:
if info.elem.id == byte {
raw := ([^]byte)(v.data)
return err_conv(_encode_bytes(e, raw[:info.count]))
@@ -242,8 +242,8 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
}
return
case runtime.Type_Info_Enumerated_Array:
// index := runtime.type_info_base(info.index).variant.(runtime.Type_Info_Enum)
case ^runtime.Type_Info_Enumerated_Array:
// index := runtime.type_info_base(info.index).variant.(^runtime.Type_Info_Enum)
err_conv(_encode_u64(e, u64(info.count), .Array)) or_return
if impl, ok := _tag_implementations_type[info.elem.id]; ok {
@@ -261,7 +261,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
}
return
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
if info.elem.id == byte {
raw := (^[dynamic]byte)(v.data)
return err_conv(_encode_bytes(e, raw[:]))
@@ -285,7 +285,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
}
return
case runtime.Type_Info_Slice:
case ^runtime.Type_Info_Slice:
if info.elem.id == byte {
raw := (^[]byte)(v.data)
return err_conv(_encode_bytes(e, raw^))
@@ -309,7 +309,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
}
return
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
m := (^mem.Raw_Map)(v.data)
err_conv(_encode_u64(e, u64(runtime.map_len(m^)), .Map)) or_return
if m != nil {
@@ -468,12 +468,12 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
}
}
case runtime.Type_Info_Struct:
case ^runtime.Type_Info_Struct:
switch vv in v {
case Tag: return err_conv(_encode_tag(e, vv))
}
field_name :: #force_inline proc(info: runtime.Type_Info_Struct, i: int) -> string {
field_name :: #force_inline proc(info: ^runtime.Type_Info_Struct, i: int) -> string {
if cbor_name := string(reflect.struct_tag_get(reflect.Struct_Tag(info.tags[i]), "cbor")); cbor_name != "" {
return cbor_name
} else {
@@ -481,7 +481,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
}
}
marshal_entry :: #force_inline proc(e: Encoder, info: runtime.Type_Info_Struct, v: any, i: int) -> Marshal_Error {
marshal_entry :: #force_inline proc(e: Encoder, info: ^runtime.Type_Info_Struct, v: any, i: int) -> Marshal_Error {
id := info.types[i].id
data := rawptr(uintptr(v.data) + info.offsets[i])
field_any := any{data, id}
@@ -554,7 +554,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
}
return
case runtime.Type_Info_Union:
case ^runtime.Type_Info_Union:
switch vv in v {
case Value: return err_conv(encode(e, vv))
}
@@ -577,7 +577,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
vti := reflect.union_variant_type_info(v)
#partial switch vt in vti.variant {
case reflect.Type_Info_Named:
case ^reflect.Type_Info_Named:
err_conv(_encode_text(e, vt.name)) or_return
case:
builder := strings.builder_make(e.temp_allocator) or_return
@@ -588,7 +588,7 @@ _marshal_into_encoder :: proc(e: Encoder, v: any, ti: ^runtime.Type_Info) -> (er
return marshal_into(e, any{v.data, vti.id})
case runtime.Type_Info_Bit_Set:
case ^runtime.Type_Info_Bit_Set:
// Store bit_set as big endian just like the protocol.
do_byte_swap := !reflect.bit_set_is_big_endian(v)
switch ti.size * 8 {

View File

@@ -264,17 +264,17 @@ tag_cbor_marshal :: proc(_: ^Tag_Implementation, e: Encoder, v: any) -> Marshal_
_encode_u8(e.writer, TAG_CBOR_NR, .Tag) or_return
ti := runtime.type_info_base(type_info_of(v.id))
#partial switch t in ti.variant {
case runtime.Type_Info_String:
case ^runtime.Type_Info_String:
return marshal_into(e, v)
case runtime.Type_Info_Array:
case ^runtime.Type_Info_Array:
elem_base := reflect.type_info_base(t.elem)
if elem_base.id != byte { return .Bad_Tag_Value }
return marshal_into(e, v)
case runtime.Type_Info_Slice:
case ^runtime.Type_Info_Slice:
elem_base := reflect.type_info_base(t.elem)
if elem_base.id != byte { return .Bad_Tag_Value }
return marshal_into(e, v)
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
elem_base := reflect.type_info_base(t.elem)
if elem_base.id != byte { return .Bad_Tag_Value }
return marshal_into(e, v)
@@ -297,7 +297,7 @@ tag_base64_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number,
defer delete(bytes, context.temp_allocator)
#partial switch t in ti.variant {
case reflect.Type_Info_String:
case ^reflect.Type_Info_String:
if t.is_cstring {
length := base64.decoded_len(bytes)
@@ -313,7 +313,7 @@ tag_base64_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number,
return
case reflect.Type_Info_Slice:
case ^reflect.Type_Info_Slice:
elem_base := reflect.type_info_base(t.elem)
if elem_base.id != byte { return _unsupported(v, hdr) }
@@ -322,7 +322,7 @@ tag_base64_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number,
raw^ = base64.decode(bytes) or_return
return
case reflect.Type_Info_Dynamic_Array:
case ^reflect.Type_Info_Dynamic_Array:
elem_base := reflect.type_info_base(t.elem)
if elem_base.id != byte { return _unsupported(v, hdr) }
@@ -336,7 +336,7 @@ tag_base64_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number,
raw.allocator = context.allocator
return
case reflect.Type_Info_Array:
case ^reflect.Type_Info_Array:
elem_base := reflect.type_info_base(t.elem)
if elem_base.id != byte { return _unsupported(v, hdr) }
@@ -366,7 +366,7 @@ tag_base64_marshal :: proc(_: ^Tag_Implementation, e: Encoder, v: any) -> Marsha
case [dynamic]byte: bytes = val[:]
case:
#partial switch t in ti.variant {
case runtime.Type_Info_Array:
case ^runtime.Type_Info_Array:
if t.elem.id != byte { return .Bad_Tag_Value }
bytes = ([^]byte)(v.data)[:t.count]
case:

View File

@@ -77,7 +77,7 @@ _unmarshal_any_ptr :: proc(d: Decoder, v: any, hdr: Maybe(Header) = nil, allocat
return .Non_Pointer_Parameter
}
data := any{(^rawptr)(v.data)^, ti.variant.(reflect.Type_Info_Pointer).elem.id}
data := any{(^rawptr)(v.data)^, ti.variant.(^reflect.Type_Info_Pointer).elem.id}
return _unmarshal_value(d, data, hdr.? or_else (_decode_header(d.reader) or_return), allocator, temp_allocator, loc)
}
@@ -87,7 +87,7 @@ _unmarshal_value :: proc(d: Decoder, v: any, hdr: Header, allocator := context.a
r := d.reader
// If it's a union with only one variant, then treat it as that variant
if u, ok := ti.variant.(reflect.Type_Info_Union); ok && len(u.variants) == 1 {
if u, ok := ti.variant.(^reflect.Type_Info_Union); ok && len(u.variants) == 1 {
#partial switch hdr {
case .Nil, .Undefined, nil: // no-op.
case:
@@ -328,7 +328,7 @@ _unmarshal_value :: proc(d: Decoder, v: any, hdr: Header, allocator := context.a
_unmarshal_bytes :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header, add: Add, allocator := context.allocator, loc := #caller_location) -> (err: Unmarshal_Error) {
#partial switch t in ti.variant {
case reflect.Type_Info_String:
case ^reflect.Type_Info_String:
bytes := err_conv(_decode_bytes(d, add, allocator=allocator, loc=loc)) or_return
if t.is_cstring {
@@ -343,7 +343,7 @@ _unmarshal_bytes :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
return
case reflect.Type_Info_Slice:
case ^reflect.Type_Info_Slice:
elem_base := reflect.type_info_base(t.elem)
if elem_base.id != byte { return _unsupported(v, hdr) }
@@ -353,7 +353,7 @@ _unmarshal_bytes :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
raw^ = transmute(mem.Raw_Slice)bytes
return
case reflect.Type_Info_Dynamic_Array:
case ^reflect.Type_Info_Dynamic_Array:
elem_base := reflect.type_info_base(t.elem)
if elem_base.id != byte { return _unsupported(v, hdr) }
@@ -366,7 +366,7 @@ _unmarshal_bytes :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
raw.allocator = allocator
return
case reflect.Type_Info_Array:
case ^reflect.Type_Info_Array:
elem_base := reflect.type_info_base(t.elem)
if elem_base.id != byte { return _unsupported(v, hdr) }
@@ -388,7 +388,7 @@ _unmarshal_bytes :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
_unmarshal_string :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header, add: Add, allocator := context.allocator, temp_allocator := context.temp_allocator, loc := #caller_location) -> (err: Unmarshal_Error) {
#partial switch t in ti.variant {
case reflect.Type_Info_String:
case ^reflect.Type_Info_String:
text := err_conv(_decode_text(d, add, allocator, loc)) or_return
if t.is_cstring {
@@ -403,7 +403,7 @@ _unmarshal_string :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Heade
return
// Enum by its variant name.
case reflect.Type_Info_Enum:
case ^reflect.Type_Info_Enum:
text := err_conv(_decode_text(d, add, allocator=temp_allocator, loc=loc)) or_return
defer delete(text, temp_allocator, loc)
@@ -414,7 +414,7 @@ _unmarshal_string :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Heade
}
}
case reflect.Type_Info_Rune:
case ^reflect.Type_Info_Rune:
text := err_conv(_decode_text(d, add, allocator=temp_allocator, loc=loc)) or_return
defer delete(text, temp_allocator, loc)
@@ -481,7 +481,7 @@ _unmarshal_array :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
}
#partial switch t in ti.variant {
case reflect.Type_Info_Slice:
case ^reflect.Type_Info_Slice:
length, scap := err_conv(_decode_len_container(d, add)) or_return
data := mem.alloc_bytes_non_zeroed(t.elem.size * scap, t.elem.align, allocator=allocator, loc=loc) or_return
@@ -501,7 +501,7 @@ _unmarshal_array :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
raw.len = da.len
return
case reflect.Type_Info_Dynamic_Array:
case ^reflect.Type_Info_Dynamic_Array:
length, scap := err_conv(_decode_len_container(d, add)) or_return
data := mem.alloc_bytes_non_zeroed(t.elem.size * scap, t.elem.align, loc=loc) or_return
@@ -521,7 +521,7 @@ _unmarshal_array :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
}
return
case reflect.Type_Info_Array:
case ^reflect.Type_Info_Array:
length, _ := err_conv(_decode_len_container(d, add)) or_return
if length > t.count {
return _unsupported(v, hdr)
@@ -533,7 +533,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_Enumerated_Array:
case ^reflect.Type_Info_Enumerated_Array:
length, _ := err_conv(_decode_len_container(d, add)) or_return
if length > t.count {
return _unsupported(v, hdr)
@@ -545,7 +545,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_Complex:
case ^reflect.Type_Info_Complex:
length, _ := err_conv(_decode_len_container(d, add)) or_return
if length > 2 {
return _unsupported(v, hdr)
@@ -565,7 +565,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_Quaternion:
case ^reflect.Type_Info_Quaternion:
length, _ := err_conv(_decode_len_container(d, add)) or_return
if length > 4 {
return _unsupported(v, hdr)
@@ -619,8 +619,8 @@ _unmarshal_map :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header,
}
#partial switch t in ti.variant {
case reflect.Type_Info_Struct:
if .raw_union in t.flags {
case ^reflect.Type_Info_Struct:
if .raw_union in t.struct_flags {
return _unsupported(v, hdr)
}
@@ -689,7 +689,7 @@ _unmarshal_map :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header,
return
case reflect.Type_Info_Map:
case ^reflect.Type_Info_Map:
raw_map := (^mem.Raw_Map)(v.data)
if raw_map.allocator.procedure == nil {
raw_map.allocator = context.allocator
@@ -751,7 +751,7 @@ _unmarshal_map :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header,
_unmarshal_union :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header, loc := #caller_location) -> (err: Unmarshal_Error) {
r := d.reader
#partial switch t in ti.variant {
case reflect.Type_Info_Union:
case ^reflect.Type_Info_Union:
idhdr: Header
target_name: string
{
@@ -783,7 +783,7 @@ _unmarshal_union :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header
}
#partial switch vti in variant.variant {
case reflect.Type_Info_Named:
case ^reflect.Type_Info_Named:
if vti.name == target_name {
reflect.set_union_variant_raw_tag(v, tag)
return _unmarshal_value(d, any{v.data, variant.id}, _decode_header(r) or_return, loc=loc)
@@ -850,7 +850,7 @@ _assign_int :: proc(val: any, i: $T) -> bool {
case uintptr: dst = uintptr(i)
case:
ti := type_info_of(v.id)
if _, ok := ti.variant.(runtime.Type_Info_Bit_Set); ok {
if _, ok := ti.variant.(^runtime.Type_Info_Bit_Set); ok {
do_byte_swap := !reflect.bit_set_is_big_endian(v)
switch ti.size * 8 {
case 0: // no-op.

View File

@@ -95,10 +95,10 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
a := any{v.data, ti.id}
switch info in ti.variant {
case runtime.Type_Info_Named:
case ^runtime.Type_Info_Named:
unreachable()
case runtime.Type_Info_Integer:
case ^runtime.Type_Info_Integer:
buf: [40]byte
u := cast_any_int_to_u128(a)
@@ -120,13 +120,13 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
io.write_string(w, s) or_return
case runtime.Type_Info_Rune:
case ^runtime.Type_Info_Rune:
r := a.(rune)
io.write_byte(w, '"') or_return
io.write_escaped_rune(w, r, '"', true) or_return
io.write_byte(w, '"') or_return
case runtime.Type_Info_Float:
case ^runtime.Type_Info_Float:
switch f in a {
case f16: io.write_f16(w, f) or_return
case f32: io.write_f32(w, f) or_return
@@ -134,7 +134,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
case: return .Unsupported_Type
}
case runtime.Type_Info_Complex:
case ^runtime.Type_Info_Complex:
r, i: f64
switch z in a {
case complex32: r, i = f64(real(z)), f64(imag(z))
@@ -149,16 +149,16 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
io.write_f64(w, i) or_return
io.write_byte(w, ']') or_return
case runtime.Type_Info_Quaternion:
case ^runtime.Type_Info_Quaternion:
return .Unsupported_Type
case runtime.Type_Info_String:
case ^runtime.Type_Info_String:
switch s in a {
case string: io.write_quoted_string(w, s, '"', nil, true) or_return
case cstring: io.write_quoted_string(w, string(s), '"', nil, true) or_return
}
case runtime.Type_Info_Boolean:
case ^runtime.Type_Info_Boolean:
val: bool
switch b in a {
case bool: val = bool(b)
@@ -169,37 +169,37 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
}
io.write_string(w, val ? "true" : "false") or_return
case runtime.Type_Info_Any:
case ^runtime.Type_Info_Any:
return .Unsupported_Type
case runtime.Type_Info_Type_Id:
case ^runtime.Type_Info_Type_Id:
return .Unsupported_Type
case runtime.Type_Info_Pointer:
case ^runtime.Type_Info_Pointer:
return .Unsupported_Type
case runtime.Type_Info_Multi_Pointer:
case ^runtime.Type_Info_Multi_Pointer:
return .Unsupported_Type
case runtime.Type_Info_Soa_Pointer:
case ^runtime.Type_Info_Soa_Pointer:
return .Unsupported_Type
case runtime.Type_Info_Procedure:
case ^runtime.Type_Info_Procedure:
return .Unsupported_Type
case runtime.Type_Info_Parameters:
case ^runtime.Type_Info_Parameters:
return .Unsupported_Type
case runtime.Type_Info_Simd_Vector:
case ^runtime.Type_Info_Simd_Vector:
return .Unsupported_Type
case runtime.Type_Info_Matrix:
case ^runtime.Type_Info_Matrix:
return .Unsupported_Type
case runtime.Type_Info_Bit_Field:
case ^runtime.Type_Info_Bit_Field:
return .Unsupported_Type
case runtime.Type_Info_Array:
case ^runtime.Type_Info_Array:
opt_write_start(w, opt, '[') or_return
for i in 0..<info.count {
opt_write_iteration(w, opt, i == 0) or_return
@@ -208,9 +208,9 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
}
opt_write_end(w, opt, ']') or_return
case runtime.Type_Info_Enumerated_Array:
case ^runtime.Type_Info_Enumerated_Array:
index_type := reflect.type_info_base(info.index)
enum_type := index_type.variant.(reflect.Type_Info_Enum)
enum_type := index_type.variant.(^reflect.Type_Info_Enum)
opt_write_start(w, opt, '{') or_return
for i in 0..<info.count {
@@ -227,7 +227,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
}
opt_write_end(w, opt, '}') or_return
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
opt_write_start(w, opt, '[') or_return
array := cast(^mem.Raw_Dynamic_Array)v.data
for i in 0..<array.len {
@@ -237,7 +237,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
}
opt_write_end(w, opt, ']') or_return
case runtime.Type_Info_Slice:
case ^runtime.Type_Info_Slice:
opt_write_start(w, opt, '[') or_return
slice := cast(^mem.Raw_Slice)v.data
for i in 0..<slice.len {
@@ -247,7 +247,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
}
opt_write_end(w, opt, ']') or_return
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
m := (^mem.Raw_Map)(v.data)
opt_write_start(w, opt, '{') or_return
@@ -277,13 +277,13 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
name: string
#partial switch info in kti.variant {
case runtime.Type_Info_String:
case ^runtime.Type_Info_String:
switch s in ka {
case string: name = s
case cstring: name = string(s)
}
opt_write_key(w, opt, name) or_return
case runtime.Type_Info_Integer:
case ^runtime.Type_Info_Integer:
buf: [40]byte
u := cast_any_int_to_u128(ka)
name = strconv.append_bits_128(buf[:], u, 10, info.signed, 8*kti.size, "0123456789", nil)
@@ -318,7 +318,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
ka := any{kv.data, kti.id}
#partial switch info in kti.variant {
case runtime.Type_Info_String:
case ^runtime.Type_Info_String:
switch s in ka {
case string: name = s
case cstring: name = string(s)
@@ -343,7 +343,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
opt_write_end(w, opt, '}') or_return
case runtime.Type_Info_Struct:
case ^runtime.Type_Info_Struct:
is_omitempty :: proc(v: any) -> bool {
v := v
if v == nil {
@@ -351,30 +351,30 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
}
ti := runtime.type_info_core(type_info_of(v.id))
#partial switch info in ti.variant {
case runtime.Type_Info_String:
case ^runtime.Type_Info_String:
switch x in v {
case string:
return x == ""
case cstring:
return x == nil || x == ""
}
case runtime.Type_Info_Any:
case ^runtime.Type_Info_Any:
return v.(any) == nil
case runtime.Type_Info_Type_Id:
case ^runtime.Type_Info_Type_Id:
return v.(typeid) == nil
case runtime.Type_Info_Pointer,
runtime.Type_Info_Multi_Pointer,
runtime.Type_Info_Procedure:
case ^runtime.Type_Info_Pointer,
^runtime.Type_Info_Multi_Pointer,
^runtime.Type_Info_Procedure:
return (^rawptr)(v.data)^ == nil
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
return (^runtime.Raw_Dynamic_Array)(v.data).len == 0
case runtime.Type_Info_Slice:
case ^runtime.Type_Info_Slice:
return (^runtime.Raw_Slice)(v.data).len == 0
case runtime.Type_Info_Union,
runtime.Type_Info_Bit_Set,
runtime.Type_Info_Soa_Pointer:
case ^runtime.Type_Info_Union,
^runtime.Type_Info_Bit_Set,
^runtime.Type_Info_Soa_Pointer:
return reflect.is_nil(v)
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
return (^runtime.Raw_Map)(v.data).len == 0
}
return false
@@ -382,7 +382,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
marshal_struct_fields :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: Marshal_Error) {
ti := runtime.type_info_base(type_info_of(v.id))
info := ti.variant.(runtime.Type_Info_Struct)
info := ti.variant.(^runtime.Type_Info_Struct)
first_iteration := true
for name, i in info.names[:info.field_count] {
omitempty := false
@@ -432,7 +432,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
marshal_struct_fields(w, v, opt) or_return
opt_write_end(w, opt, '}') or_return
case runtime.Type_Info_Union:
case ^runtime.Type_Info_Union:
if len(info.variants) == 0 || v.data == nil {
io.write_string(w, "null") or_return
return nil
@@ -464,7 +464,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
id := info.variants[tag].id
return marshal_to_writer(w, any{v.data, id}, opt)
case runtime.Type_Info_Enum:
case ^runtime.Type_Info_Enum:
if !opt.use_enum_names || len(info.names) == 0 {
return marshal_to_writer(w, any{v.data, info.base.id}, opt)
} else {
@@ -476,14 +476,14 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
}
}
case runtime.Type_Info_Bit_Set:
case ^runtime.Type_Info_Bit_Set:
is_bit_set_different_endian_to_platform :: proc(ti: ^runtime.Type_Info) -> bool {
if ti == nil {
return false
}
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

@@ -43,7 +43,7 @@ unmarshal_any :: proc(data: []byte, v: any, spec := DEFAULT_SPECIFICATION, alloc
}
p := make_parser(data, spec, PARSE_INTEGERS, allocator)
data := any{(^rawptr)(v.data)^, ti.variant.(reflect.Type_Info_Pointer).elem.id}
data := any{(^rawptr)(v.data)^, ti.variant.(^reflect.Type_Info_Pointer).elem.id}
if v.data == nil {
return .Invalid_Parameter
}
@@ -118,7 +118,7 @@ assign_int :: proc(val: any, i: $T) -> bool {
case uintptr: dst = uintptr(i)
case:
ti := type_info_of(v.id)
if _, ok := ti.variant.(runtime.Type_Info_Bit_Set); ok {
if _, ok := ti.variant.(^runtime.Type_Info_Bit_Set); ok {
do_byte_swap := !reflect.bit_set_is_big_endian(v)
switch ti.size * 8 {
case 0: // no-op.
@@ -202,7 +202,7 @@ unmarshal_string_token :: proc(p: ^Parser, val: any, str: string, ti: ^reflect.T
}
#partial switch variant in ti.variant {
case reflect.Type_Info_Enum:
case ^reflect.Type_Info_Enum:
for name, i in variant.names {
if name == str {
assign_int(val, variant.values[i])
@@ -212,7 +212,7 @@ unmarshal_string_token :: proc(p: ^Parser, val: any, str: string, ti: ^reflect.T
// TODO(bill): should this be an error or not?
return true, nil
case reflect.Type_Info_Integer:
case ^reflect.Type_Info_Integer:
i, pok := strconv.parse_i128(str)
if !pok {
return false, nil
@@ -223,7 +223,7 @@ unmarshal_string_token :: proc(p: ^Parser, val: any, str: string, ti: ^reflect.T
if assign_float(val, i) {
return true, nil
}
case reflect.Type_Info_Float:
case ^reflect.Type_Info_Float:
f, pok := strconv.parse_f64(str)
if !pok {
return false, nil
@@ -247,7 +247,7 @@ unmarshal_value :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) {
v := v
ti := reflect.type_info_base(type_info_of(v.id))
if u, ok := ti.variant.(reflect.Type_Info_Union); ok && token.kind != .Null {
if u, ok := ti.variant.(^reflect.Type_Info_Union); ok && token.kind != .Null {
// NOTE: If it's a union with only one variant, then treat it as that variant
if len(u.variants) == 1 {
variant := u.variants[0]
@@ -413,8 +413,8 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
ti := reflect.type_info_base(type_info_of(v.id))
#partial switch t in ti.variant {
case reflect.Type_Info_Struct:
if .raw_union in t.flags {
case ^reflect.Type_Info_Struct:
if .raw_union in t.struct_flags {
return UNSUPPORTED_TYPE
}
@@ -520,7 +520,7 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
}
}
case reflect.Type_Info_Map:
case ^reflect.Type_Info_Map:
if !reflect.is_string(t.key) && !reflect.is_integer(t.key) {
return UNSUPPORTED_TYPE
}
@@ -548,14 +548,14 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
key_ptr: rawptr
#partial switch tk in t.key.variant {
case runtime.Type_Info_String:
case ^runtime.Type_Info_String:
key_ptr = rawptr(&key)
key_cstr: cstring
if reflect.is_cstring(t.key) {
key_cstr = cstring(raw_data(key))
key_ptr = &key_cstr
}
case runtime.Type_Info_Integer:
case ^runtime.Type_Info_Integer:
i, ok := strconv.parse_i128(key)
if !ok { return UNSUPPORTED_TYPE }
key_ptr = rawptr(&i)
@@ -577,9 +577,9 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
}
}
case reflect.Type_Info_Enumerated_Array:
case ^reflect.Type_Info_Enumerated_Array:
index_type := reflect.type_info_base(t.index)
enum_type := index_type.variant.(reflect.Type_Info_Enum)
enum_type := index_type.variant.(^reflect.Type_Info_Enum)
enumerated_array_loop: for p.curr_token.kind != end_token {
key, _ := parse_object_key(p, p.allocator)
@@ -666,7 +666,7 @@ unmarshal_array :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) {
length := unmarshal_count_array(p)
#partial switch t in ti.variant {
case reflect.Type_Info_Slice:
case ^reflect.Type_Info_Slice:
raw := (^mem.Raw_Slice)(v.data)
data := bytes_make(t.elem.size * int(length), t.elem.align, p.allocator) or_return
raw.data = raw_data(data)
@@ -674,7 +674,7 @@ unmarshal_array :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) {
return assign_array(p, raw.data, t.elem, length)
case reflect.Type_Info_Dynamic_Array:
case ^reflect.Type_Info_Dynamic_Array:
raw := (^mem.Raw_Dynamic_Array)(v.data)
data := bytes_make(t.elem.size * int(length), t.elem.align, p.allocator) or_return
raw.data = raw_data(data)
@@ -684,7 +684,7 @@ unmarshal_array :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) {
return assign_array(p, raw.data, t.elem, length)
case reflect.Type_Info_Array:
case ^reflect.Type_Info_Array:
// NOTE(bill): Allow lengths which are less than the dst array
if int(length) > t.count {
return UNSUPPORTED_TYPE
@@ -692,7 +692,7 @@ unmarshal_array :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) {
return assign_array(p, v.data, t.elem, length)
case reflect.Type_Info_Enumerated_Array:
case ^reflect.Type_Info_Enumerated_Array:
// NOTE(bill): Allow lengths which are less than the dst array
if int(length) > t.count {
return UNSUPPORTED_TYPE
@@ -700,7 +700,7 @@ unmarshal_array :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) {
return assign_array(p, v.data, t.elem, length)
case reflect.Type_Info_Complex:
case ^reflect.Type_Info_Complex:
// NOTE(bill): Allow lengths which are less than the dst array
if int(length) > 2 {
return UNSUPPORTED_TYPE

View File

@@ -85,7 +85,7 @@ set_odin_flag :: proc(model: ^$T, parser: ^Parser, name: string) -> (error: Erro
field, index := get_field_by_name(model, name) or_return
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Boolean:
case ^runtime.Type_Info_Boolean:
ptr := cast(^bool)(cast(uintptr)model + field.offset)
ptr^ = true
case:
@@ -111,10 +111,10 @@ set_unix_flag :: proc(model: ^$T, parser: ^Parser, name: string) -> (future_args
field, index := get_field_by_name(model, name) or_return
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Boolean:
case ^runtime.Type_Info_Boolean:
ptr := cast(^bool)(cast(uintptr)model + field.offset)
ptr^ = true
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
future_args = 1
if tag, ok := reflect.struct_tag_lookup(field.tag, TAG_ARGS); ok {
if length, is_variadic := get_struct_subtag(tag, SUBTAG_VARIADIC); is_variadic {
@@ -150,7 +150,7 @@ set_option :: proc(model: ^$T, parser: ^Parser, name, option: string) -> (error:
// Guard against incorrect syntax.
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
return Parse_Error {
.No_Value,
fmt.tprintf("Unable to set `%s` of type %v to `%s`. Are you missing an `=`? The correct format is `map:key=value`.", name, field.type, option),
@@ -181,7 +181,7 @@ set_key_value :: proc(model: ^$T, parser: ^Parser, name, key, value: string) ->
field, index := get_field_by_name(model, name) or_return
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
key := key
key_ptr := cast(rawptr)&key
key_cstr: cstring

View File

@@ -41,7 +41,7 @@ parse_and_set_pointer_by_base_type :: proc(ptr: rawptr, str: string, type_info:
// This seems to be the smallest way for now.
#partial switch specific_type_info in type_info.variant {
case runtime.Type_Info_Integer:
case ^runtime.Type_Info_Integer:
if specific_type_info.signed {
value := strconv.parse_i128(str) or_return
switch type_info.id {
@@ -87,14 +87,14 @@ parse_and_set_pointer_by_base_type :: proc(ptr: rawptr, str: string, type_info:
}
}
case runtime.Type_Info_Rune:
case ^runtime.Type_Info_Rune:
if utf8.rune_count_in_string(str) != 1 {
return false
}
(^rune)(ptr)^ = utf8.rune_at_pos(str, 0)
case runtime.Type_Info_Float:
case ^runtime.Type_Info_Float:
value := strconv.parse_f64(str) or_return
switch type_info.id {
case f16: (^f16) (ptr)^ = cast(f16) value
@@ -110,7 +110,7 @@ parse_and_set_pointer_by_base_type :: proc(ptr: rawptr, str: string, type_info:
case f64be: (^f64be)(ptr)^ = cast(f64be) value
}
case runtime.Type_Info_Complex:
case ^runtime.Type_Info_Complex:
value := strconv.parse_complex128(str) or_return
switch type_info.id {
case complex32: (^complex32) (ptr)^ = (complex32)(value)
@@ -118,7 +118,7 @@ parse_and_set_pointer_by_base_type :: proc(ptr: rawptr, str: string, type_info:
case complex128: (^complex128)(ptr)^ = value
}
case runtime.Type_Info_Quaternion:
case ^runtime.Type_Info_Quaternion:
value := strconv.parse_quaternion256(str) or_return
switch type_info.id {
case quaternion64: (^quaternion64) (ptr)^ = (quaternion64)(value)
@@ -126,7 +126,7 @@ parse_and_set_pointer_by_base_type :: proc(ptr: rawptr, str: string, type_info:
case quaternion256: (^quaternion256)(ptr)^ = value
}
case runtime.Type_Info_String:
case ^runtime.Type_Info_String:
if specific_type_info.is_cstring {
cstr_ptr := (^cstring)(ptr)
if cstr_ptr != nil {
@@ -138,7 +138,7 @@ parse_and_set_pointer_by_base_type :: proc(ptr: rawptr, str: string, type_info:
(^string)(ptr)^ = str
}
case runtime.Type_Info_Boolean:
case ^runtime.Type_Info_Boolean:
value := strconv.parse_bool(str) or_return
switch type_info.id {
case bool: (^bool)(ptr)^ = value
@@ -148,7 +148,7 @@ parse_and_set_pointer_by_base_type :: proc(ptr: rawptr, str: string, type_info:
case b64: (^b64) (ptr)^ = b64(value)
}
case runtime.Type_Info_Bit_Set:
case ^runtime.Type_Info_Bit_Set:
// Parse a string of 1's and 0's, from left to right,
// least significant bit to most significant bit.
value: u128
@@ -370,7 +370,7 @@ set_unbounded_integer_by_type :: proc(ptr: rawptr, value: $T, data_type: typeid)
@(optimization_mode="favor_size")
parse_and_set_pointer_by_type :: proc(ptr: rawptr, str: string, type_info: ^runtime.Type_Info, arg_tag: string) -> (error: Error) {
#partial switch specific_type_info in type_info.variant {
case runtime.Type_Info_Named:
case ^runtime.Type_Info_Named:
if global_custom_type_setter != nil {
// The program gets to go first.
error_message, handled, alloc_error := global_custom_type_setter(ptr, type_info.id, str, arg_tag)
@@ -399,7 +399,7 @@ parse_and_set_pointer_by_type :: proc(ptr: rawptr, str: string, type_info: ^runt
}
// Might be a named enum. Need to check here first, since we handle all enums.
if enum_type_info, is_enum := specific_type_info.base.variant.(runtime.Type_Info_Enum); is_enum {
if enum_type_info, is_enum := specific_type_info.base.variant.(^runtime.Type_Info_Enum); is_enum {
if value, ok := reflect.enum_from_name_any(type_info.id, str); ok {
set_unbounded_integer_by_type(ptr, value, enum_type_info.base.id)
} else {
@@ -420,7 +420,7 @@ parse_and_set_pointer_by_type :: proc(ptr: rawptr, str: string, type_info: ^runt
}
}
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
ptr := cast(^runtime.Raw_Dynamic_Array)ptr
// Try to convert the value first.
@@ -448,7 +448,7 @@ parse_and_set_pointer_by_type :: proc(ptr: rawptr, str: string, type_info: ^runt
uintptr((ptr.len - 1) * specific_type_info.elem.size))
mem.copy(subptr, raw_data(elem_backing), len(elem_backing))
case runtime.Type_Info_Enum:
case ^runtime.Type_Info_Enum:
// This is a nameless enum.
// The code here is virtually the same as above for named enums.
if value, ok := reflect.enum_from_name_any(type_info.id, str); ok {

View File

@@ -19,7 +19,7 @@ validate_structure :: proc(model_type: $T, style: Parsing_Style, loc := #caller_
check_fields: for field in reflect.struct_fields_zipped(T) {
if style == .Unix {
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
fmt.panicf("%T.%s is a map type, and these are not supported in UNIX-style parsing mode.",
model_type, field.name, loc = loc)
}
@@ -61,7 +61,7 @@ validate_structure :: proc(model_type: $T, style: Parsing_Style, loc := #caller_
if pos_str, has_pos := get_struct_subtag(args_tag, SUBTAG_POS); has_pos {
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
fmt.panicf("%T.%s has `%s` defined, and this does not make sense on a map type.",
model_type, field.name, SUBTAG_POS, loc = loc)
}
@@ -85,7 +85,7 @@ validate_structure :: proc(model_type: $T, style: Parsing_Style, loc := #caller_
if len(requirement) > 0 {
if required_min, required_max, ok = parse_requirements(requirement); ok {
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
fmt.assertf(required_min != required_max, "%T.%s has `%s` defined as %q, but the minimum and maximum are the same. Increase the maximum by 1 for an exact number of arguments: (%i<%i)",
model_type,
field.name,
@@ -120,7 +120,7 @@ validate_structure :: proc(model_type: $T, style: Parsing_Style, loc := #caller_
}
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
fmt.assertf(style != .Odin,
"%T.%s has `%s` defined, but this only makes sense in UNIX-style parsing mode.",
model_type, field.name, SUBTAG_VARIADIC, loc = loc)
@@ -132,9 +132,9 @@ validate_structure :: proc(model_type: $T, style: Parsing_Style, loc := #caller_
allowed_to_define_file_perms: bool = ---
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
allowed_to_define_file_perms = specific_type_info.value.id == os.Handle
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
allowed_to_define_file_perms = specific_type_info.elem.id == os.Handle
case:
allowed_to_define_file_perms = field.type.id == os.Handle
@@ -151,7 +151,7 @@ validate_structure :: proc(model_type: $T, style: Parsing_Style, loc := #caller_
}
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
fmt.assertf(reflect.is_string(specific_type_info.key), "%T.%s is defined as a map[%T]. Only string types are currently supported as map keys.",
model_type,
field.name,
@@ -182,7 +182,7 @@ validate_arguments :: proc(model: ^$T, parser: ^Parser) -> Error {
is_required = false
}
if _, is_array := field.type.variant.(runtime.Type_Info_Dynamic_Array); is_array && has_requirements {
if _, is_array := field.type.variant.(^runtime.Type_Info_Dynamic_Array); is_array && has_requirements {
// If it's an array, make sure it meets the required number of arguments.
ptr := cast(^runtime.Raw_Dynamic_Array)(cast(uintptr)model + field.offset)
if required_min == required_max - 1 && ptr.len != required_min {

View File

@@ -138,13 +138,13 @@ write_usage :: proc(out: io.Writer, data_type: typeid, program: string = "", sty
}
#partial switch specific_type_info in field.type.variant {
case runtime.Type_Info_Map:
case ^runtime.Type_Info_Map:
flag.type_description = fmt.tprintf("<%v>=<%v>%s",
specific_type_info.key.id,
specific_type_info.value.id,
", required" if flag.is_required else "")
case runtime.Type_Info_Dynamic_Array:
case ^runtime.Type_Info_Dynamic_Array:
requirement_spec := describe_array_requirements(flag)
if flag.is_variadic || flag.name == INTERNAL_VARIADIC_FLAG {

View File

@@ -659,7 +659,7 @@ choice_enum :: proc($T: typeid, gen := context.random_generator) -> T where intr
return T(i)
}
} else {
values := runtime.type_info_base(type_info_of(T)).variant.(runtime.Type_Info_Enum).values
values := runtime.type_info_base(type_info_of(T)).variant.(^runtime.Type_Info_Enum).values
return T(choice(values))
}
}

View File

@@ -81,7 +81,7 @@ clone_node :: proc(node: ^Node) -> ^Node {
align := align_of(Node)
ti := reflect.union_variant_type_info(node.derived)
if ti != nil {
elem := ti.variant.(reflect.Type_Info_Pointer).elem
elem := ti.variant.(^reflect.Type_Info_Pointer).elem
size = elem.size
align = elem.align
}

View File

@@ -16,7 +16,7 @@ _error_string :: proc(errno: i32) -> string {
err := runtime.Type_Info_Enum_Value(e)
ti := &runtime.type_info_base(type_info_of(wasi.errno_t)).variant.(runtime.Type_Info_Enum)
ti := &runtime.type_info_base(type_info_of(wasi.errno_t)).variant.(^runtime.Type_Info_Enum)
if idx, ok := slice.binary_search(ti.values, err); ok {
return ti.names[idx]
}

View File

@@ -15,7 +15,7 @@ _error_string :: proc(errno: i32) -> string {
err := runtime.Type_Info_Enum_Value(e)
ti := &runtime.type_info_base(type_info_of(win32.System_Error)).variant.(runtime.Type_Info_Enum)
ti := &runtime.type_info_base(type_info_of(win32.System_Error)).variant.(^runtime.Type_Info_Enum)
if idx, ok := slice.binary_search(ti.values, err); ok {
return ti.names[idx]
}

View File

@@ -52,7 +52,7 @@ map_entry_infos :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (ent
m := m
rm := (^runtime.Raw_Map)(&m)
info := runtime.type_info_base(type_info_of(M)).variant.(runtime.Type_Info_Map)
info := runtime.type_info_base(type_info_of(M)).variant.(^runtime.Type_Info_Map)
if info.map_info != nil {
entries = make(type_of(entries), len(m), allocator) or_return