aboutsummaryrefslogtreecommitdiff
path: root/core/_preload.odin
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-05-13 10:09:21 +0100
committergingerBill <bill@gingerbill.org>2018-05-13 10:09:21 +0100
commit61906613b0bccf7b6d542acfbc545213c810c910 (patch)
tree2993ed252b168a6908e9aeda967ee56c77d0a766 /core/_preload.odin
parent3b48fa8e7d87c9a6270cf1e59c67c66c3f3f9410 (diff)
Add `typeid` to `Type_Info` struct
Diffstat (limited to 'core/_preload.odin')
-rw-r--r--core/_preload.odin12
1 files changed, 3 insertions, 9 deletions
diff --git a/core/_preload.odin b/core/_preload.odin
index baccecebb..b67736791 100644
--- a/core/_preload.odin
+++ b/core/_preload.odin
@@ -105,6 +105,7 @@ Type_Info_Bit_Field :: struct {
Type_Info :: struct {
size: int,
align: int,
+ id: typeid,
variant: union {
Type_Info_Named,
@@ -241,13 +242,7 @@ type_info_base_without_enum :: proc "contextless" (info: ^Type_Info) -> ^Type_In
__typeid_of :: proc "contextless" (ti: ^Type_Info) -> typeid {
if ti == nil do return nil;
- 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;
+ return ti.id;
}
__type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info {
n := int(transmute(uintptr)id);
@@ -263,8 +258,7 @@ typeid_base :: proc "contextless" (id: typeid) -> typeid {
return typeid_of(ti);
}
typeid_base_without_enum :: proc "contextless" (id: typeid) -> typeid {
- ti := type_info_of(id);
- ti = type_info_base_without_enum(ti);
+ ti := type_info_base_without_enum(type_info_of(id));
return typeid_of(ti);
}