diff options
| author | gingerBill <bill@gingerbill.org> | 2018-08-25 12:11:48 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-08-25 12:11:48 +0100 |
| commit | 3365baee8f97bcabe462e4a6d0f46a76dd1ce7b3 (patch) | |
| tree | 5c2e9013fc1181d274f8d254a4228c7d7e4d54ae /core/runtime | |
| parent | cc88dd0b71c831fdabb4378930da2f074ff11a17 (diff) | |
`runtime.Typeid_Bit_Field` layout to store more information into the typeid
Diffstat (limited to 'core/runtime')
| -rw-r--r-- | core/runtime/core.odin | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/core/runtime/core.odin b/core/runtime/core.odin index db908530e..c6ccb7bf4 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -135,6 +135,39 @@ Type_Info :: struct { }, } +// NOTE(bill): This must match the compiler's +Typeid_Kind :: enum u8 { + Invalid, + Integer, + Rune, + Float, + Complex, + String, + Boolean, + Any, + Type_Id, + Pointer, + Procedure, + Array, + Dynamic_Array, + Slice, + Tuple, + Struct, + Union, + Enum, + Map, + Bit_Field, + Bit_Set, +} + +Typeid_Bit_Field :: bit_field #align align_of(uintptr) { + index: 8*size_of(align_of(uintptr)) - 8, + kind: 5, // Typeid_Kind + named: 1, + special: 1, // signed, cstring, etc + reserved: 1, +} + // NOTE(bill): only the ones that are needed (not all types) // This will be set by the compiler type_table: []Type_Info; @@ -233,7 +266,8 @@ __typeid_of :: proc "contextless" (ti: ^Type_Info) -> typeid { return ti.id; } __type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info { - n := int(transmute(uintptr)id); + data := transmute(Typeid_Bit_Field)id; + n := int(data.index); if n < 0 || n >= len(type_table) { n = 0; } |