mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
up
This commit is contained in:
parent
91d9032a4d
commit
353fedfbbe
@ -30,4 +30,7 @@
|
|||||||
#define UNREACHABLE() throw std::runtime_error( __FILE__ + std::string(":") + std::to_string(__LINE__) + " UNREACHABLE()!");
|
#define UNREACHABLE() throw std::runtime_error( __FILE__ + std::string(":") + std::to_string(__LINE__) + " UNREACHABLE()!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PK_VERSION "0.4.7"
|
#define PK_VERSION "0.4.8"
|
||||||
|
|
||||||
|
//#define PKPY_NO_TYPE_CHECK
|
||||||
|
//#define PKPY_NO_INDEX_CHECK
|
@ -13,10 +13,12 @@ class PyVarList: public std::vector<PyVar> {
|
|||||||
PyVar& at(size_t) = delete;
|
PyVar& at(size_t) = delete;
|
||||||
|
|
||||||
inline void __checkIndex(size_t i) const {
|
inline void __checkIndex(size_t i) const {
|
||||||
|
#ifndef PKPY_NO_INDEX_CHECK
|
||||||
if (i >= size()){
|
if (i >= size()){
|
||||||
auto msg = "std::vector index out of range, " + std::to_string(i) + " not in [0, " + std::to_string(size()) + ")";
|
auto msg = "std::vector index out of range, " + std::to_string(i) + " not in [0, " + std::to_string(size()) + ")";
|
||||||
throw std::out_of_range(msg);
|
throw std::out_of_range(msg);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
PyVar& operator[](size_t i) {
|
PyVar& operator[](size_t i) {
|
||||||
@ -40,6 +42,8 @@ class PyVarDict: public emhash8::HashMap<_Str, PyVar> {
|
|||||||
PyVar& at(const _Str&) = delete;
|
PyVar& at(const _Str&) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#ifndef PKPY_NO_INDEX_CHECK
|
||||||
PyVar& operator[](const _Str& key) {
|
PyVar& operator[](const _Str& key) {
|
||||||
return emhash8::HashMap<_Str, PyVar>::operator[](key);
|
return emhash8::HashMap<_Str, PyVar>::operator[](key);
|
||||||
}
|
}
|
||||||
@ -52,6 +56,7 @@ public:
|
|||||||
}
|
}
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
PyVarDict() : emhash8::HashMap<_Str, PyVar>(5) {}
|
PyVarDict() : emhash8::HashMap<_Str, PyVar>(5) {}
|
||||||
};
|
};
|
||||||
@ -66,10 +71,12 @@ namespace pkpy {
|
|||||||
uint8_t _size = 0;
|
uint8_t _size = 0;
|
||||||
|
|
||||||
inline void __checkIndex(uint8_t i) const {
|
inline void __checkIndex(uint8_t i) const {
|
||||||
|
#ifndef PKPY_NO_INDEX_CHECK
|
||||||
if (i >= _size){
|
if (i >= _size){
|
||||||
auto msg = "pkpy:ArgList index out of range, " + std::to_string(i) + " not in [0, " + std::to_string(size()) + ")";
|
auto msg = "pkpy:ArgList index out of range, " + std::to_string(i) + " not in [0, " + std::to_string(size()) + ")";
|
||||||
throw std::out_of_range(msg);
|
throw std::out_of_range(msg);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void __tryAlloc(uint8_t n){
|
void __tryAlloc(uint8_t n){
|
||||||
|
2
src/vm.h
2
src/vm.h
@ -919,7 +919,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void __checkType(const PyVar& obj, const PyVar& type){
|
inline void __checkType(const PyVar& obj, const PyVar& type){
|
||||||
|
#ifndef PKPY_NO_TYPE_CHECK
|
||||||
if(!obj->isType(type)) typeError("expected '" + UNION_TP_NAME(type) + "', but got '" + UNION_TP_NAME(obj) + "'");
|
if(!obj->isType(type)) typeError("expected '" + UNION_TP_NAME(type) + "', but got '" + UNION_TP_NAME(obj) + "'");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void __checkArgSize(const pkpy::ArgList& args, int size, bool method=false){
|
inline void __checkArgSize(const pkpy::ArgList& args, int size, bool method=false){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user