mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Relative pointers
This commit is contained in:
@@ -30,6 +30,8 @@ Type_Info_Bit_Field :: runtime.Type_Info_Bit_Field;
|
||||
Type_Info_Bit_Set :: runtime.Type_Info_Bit_Set;
|
||||
Type_Info_Opaque :: runtime.Type_Info_Opaque;
|
||||
Type_Info_Simd_Vector :: runtime.Type_Info_Simd_Vector;
|
||||
Type_Info_Relative_Pointer :: runtime.Type_Info_Relative_Pointer;
|
||||
Type_Info_Relative_Slice :: runtime.Type_Info_Relative_Slice;
|
||||
|
||||
|
||||
Type_Kind :: enum {
|
||||
@@ -60,6 +62,8 @@ Type_Kind :: enum {
|
||||
Bit_Set,
|
||||
Opaque,
|
||||
Simd_Vector,
|
||||
Relative_Pointer,
|
||||
Relative_Slice,
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +96,8 @@ type_kind :: proc(T: typeid) -> Type_Kind {
|
||||
case Type_Info_Bit_Set: return .Bit_Set;
|
||||
case Type_Info_Opaque: return .Opaque;
|
||||
case Type_Info_Simd_Vector: return .Simd_Vector;
|
||||
case Type_Info_Relative_Pointer: return .Relative_Pointer;
|
||||
case Type_Info_Relative_Slice: return .Relative_Slice;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -184,6 +184,16 @@ are_types_identical :: proc(a, b: ^Type_Info) -> bool {
|
||||
y, ok := b.variant.(Type_Info_Simd_Vector);
|
||||
if !ok do return false;
|
||||
return x.count == y.count && x.elem == y.elem;
|
||||
|
||||
case Type_Info_Relative_Pointer:
|
||||
y, ok := b.variant.(Type_Info_Relative_Pointer);
|
||||
if !ok do return false;
|
||||
return x.base_integer == y.base_integer && x.pointer == y.pointer;
|
||||
|
||||
case Type_Info_Relative_Slice:
|
||||
y, ok := b.variant.(Type_Info_Relative_Slice);
|
||||
if !ok do return false;
|
||||
return x.base_integer == y.base_integer && x.slice == y.slice;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -322,6 +332,16 @@ is_simd_vector :: proc(info: ^Type_Info) -> bool {
|
||||
_, ok := type_info_base(info).variant.(Type_Info_Simd_Vector);
|
||||
return ok;
|
||||
}
|
||||
is_relative_pointer :: proc(info: ^Type_Info) -> bool {
|
||||
if info == nil do return false;
|
||||
_, ok := type_info_base(info).variant.(Type_Info_Relative_Pointer);
|
||||
return ok;
|
||||
}
|
||||
is_relative_slice :: proc(info: ^Type_Info) -> bool {
|
||||
if info == nil do return false;
|
||||
_, ok := type_info_base(info).variant.(Type_Info_Relative_Slice);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -567,6 +587,19 @@ write_type :: proc(buf: ^strings.Builder, ti: ^Type_Info) {
|
||||
write_byte(buf, ']');
|
||||
write_type(buf, info.elem);
|
||||
}
|
||||
|
||||
case Type_Info_Relative_Pointer:
|
||||
write_string(buf, "#relative(");
|
||||
write_type(buf, info.base_integer);
|
||||
write_string(buf, ") ");
|
||||
write_type(buf, info.pointer);
|
||||
|
||||
case Type_Info_Relative_Slice:
|
||||
write_string(buf, "#relative(");
|
||||
write_type(buf, info.base_integer);
|
||||
write_string(buf, ") ");
|
||||
write_type(buf, info.slice);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user