diff --git a/src/common.h b/src/common.h index e15ef490..90e404fa 100644 --- a/src/common.h +++ b/src/common.h @@ -1,13 +1,5 @@ #pragma once -#ifdef _MSC_VER -#pragma warning (disable:4267) -#pragma warning (disable:4101) -#pragma warning (disable:4244) -#define _CRT_NONSTDC_NO_DEPRECATE -#define strdup _strdup -#endif - #include #include @@ -29,16 +21,14 @@ #include #include -#include "config.h" - #define PK_VERSION "1.0.3" -/*******************************************************************************/ +#include "config.h" +/*******************************************************************************/ #if PK_ENABLE_STD_FUNCTION #include #endif - /*******************************************************************************/ #if PK_ENABLE_THREAD @@ -57,20 +47,6 @@ struct GIL { #define GLOBAL_SCOPE_LOCK() #endif -/*******************************************************************************/ -#if _MSC_VER -#define PK_ENABLE_COMPUTED_GOTO 0 -#define UNREACHABLE() __assume(0) -#else -#define PK_ENABLE_COMPUTED_GOTO 1 -#define UNREACHABLE() __builtin_unreachable() - -#if DEBUG_CEVAL_STEP -#undef PK_ENABLE_COMPUTED_GOTO -#endif - -#endif - /*******************************************************************************/ namespace pkpy{ diff --git a/src/config.h b/src/config.h index 4617a93d..db841f39 100644 --- a/src/config.h +++ b/src/config.h @@ -21,6 +21,21 @@ // but it's slower and may cause severe "code bloat", also needs more time to compile. #define PK_ENABLE_STD_FUNCTION 0 +/*************** debug settings ***************/ + +// Enable this may help you find bugs +#define DEBUG_EXTRA_CHECK 0 + +// Do not edit the following settings unless you know what you are doing +#define DEBUG_NO_BUILTIN_MODULES 0 +#define DEBUG_DIS_EXEC 0 +#define DEBUG_CEVAL_STEP 0 +#define DEBUG_FULL_EXCEPTION 0 +#define DEBUG_MEMORY_POOL 0 +#define DEBUG_NO_MEMORY_POOL 0 +#define DEBUG_NO_AUTO_GC 0 +#define DEBUG_GC_STATS 0 + /*************** internal settings ***************/ // This is the maximum size of the value stack in void* units @@ -44,19 +59,25 @@ inline const float kTypeAttrLoadFactor = 0.5f; inline const char kPlatformSep = '/'; #endif -/*************** debug settings ***************/ +#ifdef _MSC_VER +#pragma warning (disable:4267) +#pragma warning (disable:4101) +#pragma warning (disable:4244) +#define _CRT_NONSTDC_NO_DEPRECATE +#define strdup _strdup +#endif -// Enable this may help you find bugs -#define DEBUG_EXTRA_CHECK 0 +#ifdef _MSC_VER +#define PK_ENABLE_COMPUTED_GOTO 0 +#define UNREACHABLE() __assume(0) +#else +#define PK_ENABLE_COMPUTED_GOTO 1 +#define UNREACHABLE() __builtin_unreachable() +#endif -// Do not edit the following settings unless you know what you are doing -#define DEBUG_NO_BUILTIN_MODULES 0 -#define DEBUG_DIS_EXEC 0 -#define DEBUG_CEVAL_STEP 0 -#define DEBUG_FULL_EXCEPTION 0 -#define DEBUG_MEMORY_POOL 0 -#define DEBUG_NO_MEMORY_POOL 0 -#define DEBUG_NO_AUTO_GC 0 -#define DEBUG_GC_STATS 0 + +#if DEBUG_CEVAL_STEP && defined(PK_ENABLE_COMPUTED_GOTO) +#undef PK_ENABLE_COMPUTED_GOTO +#endif #endif \ No newline at end of file diff --git a/src/vm.h b/src/vm.h index 1d246222..f50d7dd0 100644 --- a/src/vm.h +++ b/src/vm.h @@ -1513,7 +1513,7 @@ PyObject* PyArrayGetItem(VM* vm, PyObject* obj, PyObject* index){ static_assert(std::is_same_v || std::is_same_v); const T& self = _CAST(T&, obj); - if(is_type(index, vm->tp_slice)){ + if(is_non_tagged_type(index, vm->tp_slice)){ const Slice& s = _CAST(Slice&, index); int start, stop, step; vm->parse_int_slice(s, self.size(), start, stop, step);