This commit is contained in:
blueloveTH 2023-06-11 20:37:38 +08:00
parent e6a57085ea
commit 2f5b34fe46
3 changed files with 36 additions and 39 deletions

View File

@ -1,13 +1,5 @@
#pragma once #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 <cmath> #include <cmath>
#include <cstring> #include <cstring>
@ -29,16 +21,14 @@
#include <variant> #include <variant>
#include <type_traits> #include <type_traits>
#include "config.h"
#define PK_VERSION "1.0.3" #define PK_VERSION "1.0.3"
/*******************************************************************************/ #include "config.h"
/*******************************************************************************/
#if PK_ENABLE_STD_FUNCTION #if PK_ENABLE_STD_FUNCTION
#include <functional> #include <functional>
#endif #endif
/*******************************************************************************/ /*******************************************************************************/
#if PK_ENABLE_THREAD #if PK_ENABLE_THREAD
@ -57,20 +47,6 @@ struct GIL {
#define GLOBAL_SCOPE_LOCK() #define GLOBAL_SCOPE_LOCK()
#endif #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{ namespace pkpy{

View File

@ -21,6 +21,21 @@
// but it's slower and may cause severe "code bloat", also needs more time to compile. // but it's slower and may cause severe "code bloat", also needs more time to compile.
#define PK_ENABLE_STD_FUNCTION 0 #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 ***************/ /*************** internal settings ***************/
// This is the maximum size of the value stack in void* units // 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 = '/'; inline const char kPlatformSep = '/';
#endif #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 #ifdef _MSC_VER
#define DEBUG_EXTRA_CHECK 0 #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 #if DEBUG_CEVAL_STEP && defined(PK_ENABLE_COMPUTED_GOTO)
#define DEBUG_DIS_EXEC 0 #undef PK_ENABLE_COMPUTED_GOTO
#define DEBUG_CEVAL_STEP 0 #endif
#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
#endif #endif

View File

@ -1513,7 +1513,7 @@ PyObject* PyArrayGetItem(VM* vm, PyObject* obj, PyObject* index){
static_assert(std::is_same_v<T, List> || std::is_same_v<T, Tuple>); static_assert(std::is_same_v<T, List> || std::is_same_v<T, Tuple>);
const T& self = _CAST(T&, obj); 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); const Slice& s = _CAST(Slice&, index);
int start, stop, step; int start, stop, step;
vm->parse_int_slice(s, self.size(), start, stop, step); vm->parse_int_slice(s, self.size(), start, stop, step);