fix 32bits

This commit is contained in:
blueloveTH 2023-03-09 22:37:49 +08:00
parent 2475fcda77
commit 75d83787f4
2 changed files with 4 additions and 0 deletions

View File

@ -35,6 +35,7 @@ typedef int32_t i64;
typedef float f64; typedef float f64;
#define S_TO_INT std::stoi #define S_TO_INT std::stoi
#define S_TO_FLOAT std::stof #define S_TO_FLOAT std::stof
#define PKPY_USE_32_BITS
#else #else
typedef int64_t i64; typedef int64_t i64;
typedef double f64; typedef double f64;

View File

@ -388,6 +388,8 @@ template<> i64 py_cast<i64>(VM* vm, const PyVar& obj){
template<> i64 _py_cast<i64>(VM* vm, const PyVar& obj){ template<> i64 _py_cast<i64>(VM* vm, const PyVar& obj){
return obj.bits >> 2; return obj.bits >> 2;
} }
#ifndef PKPY_USE_32_BITS
template<> int py_cast<int>(VM* vm, const PyVar& obj){ template<> int py_cast<int>(VM* vm, const PyVar& obj){
vm->check_type(obj, vm->tp_int); vm->check_type(obj, vm->tp_int);
return obj.bits >> 2; return obj.bits >> 2;
@ -395,6 +397,7 @@ template<> int py_cast<int>(VM* vm, const PyVar& obj){
template<> int _py_cast<int>(VM* vm, const PyVar& obj){ template<> int _py_cast<int>(VM* vm, const PyVar& obj){
return obj.bits >> 2; return obj.bits >> 2;
} }
#endif
template<> f64 py_cast<f64>(VM* vm, const PyVar& obj){ template<> f64 py_cast<f64>(VM* vm, const PyVar& obj){
vm->check_type(obj, vm->tp_float); vm->check_type(obj, vm->tp_float);