mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Fix cyclic check in is_type_polymorphic
This commit is contained in:
@@ -114,7 +114,7 @@ type_is_ordered_numeric :: proc($T: typeid) -> bool ---
|
|||||||
type_is_indexable :: proc($T: typeid) -> bool ---
|
type_is_indexable :: proc($T: typeid) -> bool ---
|
||||||
type_is_sliceable :: proc($T: typeid) -> bool ---
|
type_is_sliceable :: proc($T: typeid) -> bool ---
|
||||||
type_is_comparable :: proc($T: typeid) -> bool ---
|
type_is_comparable :: proc($T: typeid) -> bool ---
|
||||||
type_is_simple_compare :: proc($T: typeid) -> bool --- // easily compared using memcmp
|
type_is_simple_compare :: proc($T: typeid) -> bool --- // easily compared using memcmp (== and !=)
|
||||||
type_is_dereferenceable :: proc($T: typeid) -> bool ---
|
type_is_dereferenceable :: proc($T: typeid) -> bool ---
|
||||||
type_is_valid_map_key :: proc($T: typeid) -> bool ---
|
type_is_valid_map_key :: proc($T: typeid) -> bool ---
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ package runtime
|
|||||||
|
|
||||||
foreign import kernel32 "system:Kernel32.lib"
|
foreign import kernel32 "system:Kernel32.lib"
|
||||||
|
|
||||||
windows_trap_array_bounds :: proc "contextless" () -> ! {
|
@(private)
|
||||||
DWORD :: u32;
|
foreign kernel32 {
|
||||||
ULONG_PTR :: uint;
|
RaiseException :: proc "stdcall" (dwExceptionCode, dwExceptionFlags, nNumberOfArguments: u32, lpArguments: ^uint) -> ! ---
|
||||||
|
}
|
||||||
|
|
||||||
|
windows_trap_array_bounds :: proc "contextless" () -> ! {
|
||||||
EXCEPTION_ARRAY_BOUNDS_EXCEEDED :: 0xC000008C;
|
EXCEPTION_ARRAY_BOUNDS_EXCEEDED :: 0xC000008C;
|
||||||
|
|
||||||
foreign kernel32 {
|
|
||||||
RaiseException :: proc "stdcall" (dwExceptionCode, dwExceptionFlags, nNumberOfArguments: DWORD, lpArguments: ^ULONG_PTR) -> ! ---
|
|
||||||
}
|
|
||||||
|
|
||||||
RaiseException(EXCEPTION_ARRAY_BOUNDS_EXCEEDED, 0, 0, nil);
|
RaiseException(EXCEPTION_ARRAY_BOUNDS_EXCEEDED, 0, 0, nil);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-1
@@ -323,6 +323,7 @@ String const type_strings[] = {
|
|||||||
enum TypeFlag : u32 {
|
enum TypeFlag : u32 {
|
||||||
TypeFlag_Polymorphic = 1<<1,
|
TypeFlag_Polymorphic = 1<<1,
|
||||||
TypeFlag_PolySpecialized = 1<<2,
|
TypeFlag_PolySpecialized = 1<<2,
|
||||||
|
TypeFlag_InProcessOfCheckingPolymorphic = 1<<3,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Type {
|
struct Type {
|
||||||
@@ -1695,12 +1696,23 @@ TypeTuple *get_record_polymorphic_params(Type *t) {
|
|||||||
|
|
||||||
|
|
||||||
bool is_type_polymorphic(Type *t, bool or_specialized=false) {
|
bool is_type_polymorphic(Type *t, bool or_specialized=false) {
|
||||||
|
if (t->flags & TypeFlag_InProcessOfCheckingPolymorphic) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (t->kind) {
|
switch (t->kind) {
|
||||||
case Type_Generic:
|
case Type_Generic:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Type_Named:
|
case Type_Named:
|
||||||
return is_type_polymorphic(t->Named.base, or_specialized);
|
{
|
||||||
|
u32 flags = t->flags;
|
||||||
|
t->flags |= TypeFlag_InProcessOfCheckingPolymorphic;
|
||||||
|
bool ok = is_type_polymorphic(t->Named.base, or_specialized);
|
||||||
|
t->flags = flags;
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
case Type_Opaque:
|
case Type_Opaque:
|
||||||
return is_type_polymorphic(t->Opaque.elem, or_specialized);
|
return is_type_polymorphic(t->Opaque.elem, or_specialized);
|
||||||
case Type_Pointer:
|
case Type_Pointer:
|
||||||
|
|||||||
Reference in New Issue
Block a user