mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Fix typeid information for enumerated arrays
This commit is contained in:
@@ -192,6 +192,7 @@ Typeid_Kind :: enum u8 {
|
|||||||
Pointer,
|
Pointer,
|
||||||
Procedure,
|
Procedure,
|
||||||
Array,
|
Array,
|
||||||
|
Enumerated_Array,
|
||||||
Dynamic_Array,
|
Dynamic_Array,
|
||||||
Slice,
|
Slice,
|
||||||
Tuple,
|
Tuple,
|
||||||
@@ -280,10 +281,10 @@ Logger :: struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Context :: struct {
|
Context :: struct {
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
temp_allocator: Allocator,
|
temp_allocator: Allocator,
|
||||||
assertion_failure_proc: Assertion_Failure_Proc,
|
assertion_failure_proc: Assertion_Failure_Proc,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
|
|
||||||
stdin: os.Handle,
|
stdin: os.Handle,
|
||||||
stdout: os.Handle,
|
stdout: os.Handle,
|
||||||
@@ -294,8 +295,6 @@ Context :: struct {
|
|||||||
user_data: any,
|
user_data: any,
|
||||||
user_ptr: rawptr,
|
user_ptr: rawptr,
|
||||||
user_index: int,
|
user_index: int,
|
||||||
|
|
||||||
derived: any, // May be used for derived data types
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -488,14 +487,14 @@ default_assertion_failure_proc :: proc(prefix, message: string, loc: Source_Code
|
|||||||
@builtin
|
@builtin
|
||||||
copy_slice :: proc "contextless" (dst, src: $T/[]$E) -> int {
|
copy_slice :: proc "contextless" (dst, src: $T/[]$E) -> int {
|
||||||
n := max(0, min(len(dst), len(src)));
|
n := max(0, min(len(dst), len(src)));
|
||||||
if n > 0 do mem_copy(&dst[0], &src[0], n*size_of(E));
|
#no_bounds_check if n > 0 do mem_copy(&dst[0], &src[0], n*size_of(E));
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@builtin
|
@builtin
|
||||||
copy_from_string :: proc "contextless" (dst: $T/[]$E/u8, src: $S/string) -> int {
|
copy_from_string :: proc "contextless" (dst: $T/[]$E/u8, src: $S/string) -> int {
|
||||||
n := max(0, min(len(dst), len(src)));
|
n := max(0, min(len(dst), len(src)));
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
d := &dst[0];
|
d := (transmute(Raw_Slice)dst).data;
|
||||||
s := (transmute(Raw_String)src).data;
|
s := (transmute(Raw_String)src).data;
|
||||||
mem_copy(d, s, n);
|
mem_copy(d, s, n);
|
||||||
}
|
}
|
||||||
@@ -511,7 +510,7 @@ copy :: proc{copy_slice, copy_from_string};
|
|||||||
pop :: proc "contextless" (array: ^$T/[dynamic]$E) -> E {
|
pop :: proc "contextless" (array: ^$T/[dynamic]$E) -> E {
|
||||||
if array == nil do return E{};
|
if array == nil do return E{};
|
||||||
assert(len(array) > 0);
|
assert(len(array) > 0);
|
||||||
res := array[len(array)-1];
|
res := #no_bounds_check array[len(array)-1];
|
||||||
(^Raw_Dynamic_Array)(array).len -= 1;
|
(^Raw_Dynamic_Array)(array).len -= 1;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-12
@@ -5853,6 +5853,7 @@ enum Typeid_Kind : u8 {
|
|||||||
Typeid_Pointer,
|
Typeid_Pointer,
|
||||||
Typeid_Procedure,
|
Typeid_Procedure,
|
||||||
Typeid_Array,
|
Typeid_Array,
|
||||||
|
Typeid_Enumerated_Array,
|
||||||
Typeid_Dynamic_Array,
|
Typeid_Dynamic_Array,
|
||||||
Typeid_Slice,
|
Typeid_Slice,
|
||||||
Typeid_Tuple,
|
Typeid_Tuple,
|
||||||
@@ -5890,18 +5891,19 @@ irValue *ir_typeid(irModule *m, Type *type) {
|
|||||||
if (flags & BasicFlag_String) kind = Typeid_String;
|
if (flags & BasicFlag_String) kind = Typeid_String;
|
||||||
if (flags & BasicFlag_Rune) kind = Typeid_Rune;
|
if (flags & BasicFlag_Rune) kind = Typeid_Rune;
|
||||||
} break;
|
} break;
|
||||||
case Type_Pointer: kind = Typeid_Pointer; break;
|
case Type_Pointer: kind = Typeid_Pointer; break;
|
||||||
case Type_Array: kind = Typeid_Array; break;
|
case Type_Array: kind = Typeid_Array; break;
|
||||||
case Type_Slice: kind = Typeid_Slice; break;
|
case Type_EnumeratedArray: kind = Typeid_Enumerated_Array; break;
|
||||||
case Type_DynamicArray: kind = Typeid_Dynamic_Array; break;
|
case Type_Slice: kind = Typeid_Slice; break;
|
||||||
case Type_Map: kind = Typeid_Map; break;
|
case Type_DynamicArray: kind = Typeid_Dynamic_Array; break;
|
||||||
case Type_Struct: kind = Typeid_Struct; break;
|
case Type_Map: kind = Typeid_Map; break;
|
||||||
case Type_Enum: kind = Typeid_Enum; break;
|
case Type_Struct: kind = Typeid_Struct; break;
|
||||||
case Type_Union: kind = Typeid_Union; break;
|
case Type_Enum: kind = Typeid_Enum; break;
|
||||||
case Type_Tuple: kind = Typeid_Tuple; break;
|
case Type_Union: kind = Typeid_Union; break;
|
||||||
case Type_Proc: kind = Typeid_Procedure; break;
|
case Type_Tuple: kind = Typeid_Tuple; break;
|
||||||
case Type_BitField: kind = Typeid_Bit_Field; break;
|
case Type_Proc: kind = Typeid_Procedure; break;
|
||||||
case Type_BitSet: kind = Typeid_Bit_Set; break;
|
case Type_BitField: kind = Typeid_Bit_Field; break;
|
||||||
|
case Type_BitSet: kind = Typeid_Bit_Set; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_type_cstring(type)) {
|
if (is_type_cstring(type)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user