mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-30 11:20:08 +00:00
Use __type_info_of internally
This commit is contained in:
+10
-1
@@ -244,9 +244,18 @@ __typeid_of :: proc "contextless" (ti: ^Type_Info) -> typeid {
|
||||
start := uintptr(&__type_table[0]);
|
||||
end := uintptr(ti);
|
||||
id := (end-start)/size_of(Type_Info);
|
||||
if uintptr(len(__type_table)) < id {
|
||||
return nil;
|
||||
}
|
||||
return transmute(typeid)id;
|
||||
}
|
||||
|
||||
__type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info {
|
||||
n := int(transmute(uintptr)id);
|
||||
if n < 0 || n >= len(__type_table) {
|
||||
n = 0;
|
||||
}
|
||||
return &__type_table[n];
|
||||
}
|
||||
|
||||
typeid_base :: proc "contextless" (id: typeid) -> typeid {
|
||||
ti := type_info_of(id);
|
||||
|
||||
+2
-4
@@ -755,8 +755,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
|
||||
write_string(fi.buf, "any{}");
|
||||
} else {
|
||||
data := rawptr(uintptr(v.data) + b.offsets[i]);
|
||||
id := typeid_of(t);
|
||||
fmt_arg(fi, any{data, id}, 'v');
|
||||
fmt_arg(fi, any{data, typeid_of(t)}, 'v');
|
||||
}
|
||||
|
||||
if hash do write_string(fi.buf, ",\n");
|
||||
@@ -884,8 +883,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
|
||||
write_string(fi.buf, "any{}");
|
||||
} else {
|
||||
data := uintptr(v.data) + info.offsets[i];
|
||||
id := typeid_of(t);
|
||||
fmt_arg(fi, any{rawptr(data), id}, 'v');
|
||||
fmt_arg(fi, any{rawptr(data), typeid_of(t)}, 'v');
|
||||
}
|
||||
if hash do write_string(fi.buf, ",\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user