mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-29 19:00:06 +00:00
Fix issue #130; allow conversion from any pointer to uintptr and vice versa
This commit is contained in:
+5
-5
@@ -438,10 +438,10 @@ __get_map_header :: proc "contextless" (m: ^$T/map[$K]$V) -> __Map_Header {
|
|||||||
|
|
||||||
_, is_string := type_info_base(type_info_of(K)).variant.(Type_Info_String);
|
_, is_string := type_info_base(type_info_of(K)).variant.(Type_Info_String);
|
||||||
header.is_key_string = is_string;
|
header.is_key_string = is_string;
|
||||||
header.entry_size = size_of(Entry);
|
header.entry_size = int(size_of(Entry));
|
||||||
header.entry_align = align_of(Entry);
|
header.entry_align = int(align_of(Entry));
|
||||||
header.value_offset = offset_of(Entry, value);
|
header.value_offset = int(offset_of(Entry, value));
|
||||||
header.value_size = size_of(V);
|
header.value_size = int(size_of(V));
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +461,7 @@ __get_map_key :: proc "contextless" (key: $K) -> __Map_Key {
|
|||||||
case Type_Info_Rune:
|
case Type_Info_Rune:
|
||||||
map_key.hash = u128((cast(^rune)&key)^);
|
map_key.hash = u128((cast(^rune)&key)^);
|
||||||
case Type_Info_Pointer:
|
case Type_Info_Pointer:
|
||||||
map_key.hash = u128(uint((^rawptr)(&key)^));
|
map_key.hash = u128(uintptr((^rawptr)(&key)^));
|
||||||
case Type_Info_Float:
|
case Type_Info_Float:
|
||||||
switch 8*size_of(key) {
|
switch 8*size_of(key) {
|
||||||
case 32: map_key.hash = u128((^u32)(&key)^);
|
case 32: map_key.hash = u128((^u32)(&key)^);
|
||||||
|
|||||||
+3
-3
@@ -1759,11 +1759,11 @@ bool check_is_castable_to(Checker *c, Operand *operand, Type *y) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (u)int <-> rawptr
|
// (u)int <-> pointer
|
||||||
if (is_type_uintptr(src) && is_type_rawptr(dst)) {
|
if (is_type_uintptr(src) && is_type_pointer(dst)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (is_type_rawptr(src) && is_type_uintptr(dst)) {
|
if (is_type_pointer(src) && is_type_uintptr(dst)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user