mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 20:10:17 +00:00
fix compile warnings
This commit is contained in:
parent
6ed8a262a8
commit
635aae921f
5
build_with_warnings.sh
Normal file
5
build_with_warnings.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
SRC=$(find src/ -name "*.cpp")
|
||||||
|
|
||||||
|
FLAGS="-std=c++17 -O1 -stdlib=libc++ -Iinclude -W -Wno-unused-parameter -Wno-sign-compare"
|
||||||
|
|
||||||
|
clang++ $FLAGS -o main -O1 src2/main.cpp $SRC
|
@ -27,13 +27,11 @@ struct Expr{
|
|||||||
|
|
||||||
// for OP_DELETE_XXX
|
// for OP_DELETE_XXX
|
||||||
[[nodiscard]] virtual bool emit_del(CodeEmitContext* ctx) {
|
[[nodiscard]] virtual bool emit_del(CodeEmitContext* ctx) {
|
||||||
PK_UNUSED(ctx);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for OP_STORE_XXX
|
// for OP_STORE_XXX
|
||||||
[[nodiscard]] virtual bool emit_store(CodeEmitContext* ctx) {
|
[[nodiscard]] virtual bool emit_store(CodeEmitContext* ctx) {
|
||||||
PK_UNUSED(ctx);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,6 @@ struct FastLocals{
|
|||||||
PyObject* operator[](int i) const { return a[i]; }
|
PyObject* operator[](int i) const { return a[i]; }
|
||||||
|
|
||||||
FastLocals(const CodeObject* co, PyObject** a): varnames_inv(&co->varnames_inv), a(a) {}
|
FastLocals(const CodeObject* co, PyObject** a): varnames_inv(&co->varnames_inv), a(a) {}
|
||||||
FastLocals(const FastLocals& other): varnames_inv(other.varnames_inv), a(other.a) {}
|
|
||||||
|
|
||||||
PyObject** try_get_name(StrName name);
|
PyObject** try_get_name(StrName name);
|
||||||
NameDict_ to_namedict();
|
NameDict_ to_namedict();
|
||||||
|
@ -10,7 +10,6 @@ struct Vec2{
|
|||||||
float x, y;
|
float x, y;
|
||||||
Vec2() : x(0.0f), y(0.0f) {}
|
Vec2() : x(0.0f), y(0.0f) {}
|
||||||
Vec2(float x, float y) : x(x), y(y) {}
|
Vec2(float x, float y) : x(x), y(y) {}
|
||||||
Vec2(const Vec2& v) = default;
|
|
||||||
|
|
||||||
Vec2 operator+(const Vec2& v) const { return Vec2(x + v.x, y + v.y); }
|
Vec2 operator+(const Vec2& v) const { return Vec2(x + v.x, y + v.y); }
|
||||||
Vec2 operator-(const Vec2& v) const { return Vec2(x - v.x, y - v.y); }
|
Vec2 operator-(const Vec2& v) const { return Vec2(x - v.x, y - v.y); }
|
||||||
@ -34,7 +33,6 @@ struct Vec3{
|
|||||||
float x, y, z;
|
float x, y, z;
|
||||||
Vec3() : x(0.0f), y(0.0f), z(0.0f) {}
|
Vec3() : x(0.0f), y(0.0f), z(0.0f) {}
|
||||||
Vec3(float x, float y, float z) : x(x), y(y), z(z) {}
|
Vec3(float x, float y, float z) : x(x), y(y), z(z) {}
|
||||||
Vec3(const Vec3& v) = default;
|
|
||||||
|
|
||||||
Vec3 operator+(const Vec3& v) const { return Vec3(x + v.x, y + v.y, z + v.z); }
|
Vec3 operator+(const Vec3& v) const { return Vec3(x + v.x, y + v.y, z + v.z); }
|
||||||
Vec3 operator-(const Vec3& v) const { return Vec3(x - v.x, y - v.y, z - v.z); }
|
Vec3 operator-(const Vec3& v) const { return Vec3(x - v.x, y - v.y, z - v.z); }
|
||||||
@ -57,7 +55,6 @@ struct Vec4{
|
|||||||
float x, y, z, w;
|
float x, y, z, w;
|
||||||
Vec4() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {}
|
Vec4() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {}
|
||||||
Vec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
|
Vec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
|
||||||
Vec4(const Vec4& v) = default;
|
|
||||||
|
|
||||||
Vec4 operator+(const Vec4& v) const { return Vec4(x + v.x, y + v.y, z + v.z, w + v.w); }
|
Vec4 operator+(const Vec4& v) const { return Vec4(x + v.x, y + v.y, z + v.z, w + v.w); }
|
||||||
Vec4 operator-(const Vec4& v) const { return Vec4(x - v.x, y - v.y, z - v.z, w - v.w); }
|
Vec4 operator-(const Vec4& v) const { return Vec4(x - v.x, y - v.y, z - v.z, w - v.w); }
|
||||||
@ -88,7 +85,6 @@ struct Mat3x3{
|
|||||||
|
|
||||||
Mat3x3();
|
Mat3x3();
|
||||||
Mat3x3(float, float, float, float, float, float, float, float, float);
|
Mat3x3(float, float, float, float, float, float, float, float, float);
|
||||||
Mat3x3(const Mat3x3& other) = default;
|
|
||||||
|
|
||||||
static Mat3x3 zeros();
|
static Mat3x3 zeros();
|
||||||
static Mat3x3 ones();
|
static Mat3x3 ones();
|
||||||
@ -122,7 +118,6 @@ struct PyVec2: Vec2 {
|
|||||||
|
|
||||||
PyVec2() : Vec2() {}
|
PyVec2() : Vec2() {}
|
||||||
PyVec2(const Vec2& v) : Vec2(v) {}
|
PyVec2(const Vec2& v) : Vec2(v) {}
|
||||||
PyVec2(const PyVec2& v) = default;
|
|
||||||
Vec2* _() { return this; }
|
Vec2* _() { return this; }
|
||||||
|
|
||||||
static void _register(VM* vm, PyObject* mod, PyObject* type);
|
static void _register(VM* vm, PyObject* mod, PyObject* type);
|
||||||
@ -133,7 +128,6 @@ struct PyVec3: Vec3 {
|
|||||||
|
|
||||||
PyVec3() : Vec3() {}
|
PyVec3() : Vec3() {}
|
||||||
PyVec3(const Vec3& v) : Vec3(v) {}
|
PyVec3(const Vec3& v) : Vec3(v) {}
|
||||||
PyVec3(const PyVec3& v) = default;
|
|
||||||
Vec3* _() { return this; }
|
Vec3* _() { return this; }
|
||||||
|
|
||||||
static void _register(VM* vm, PyObject* mod, PyObject* type);
|
static void _register(VM* vm, PyObject* mod, PyObject* type);
|
||||||
@ -144,7 +138,6 @@ struct PyVec4: Vec4{
|
|||||||
|
|
||||||
PyVec4(): Vec4(){}
|
PyVec4(): Vec4(){}
|
||||||
PyVec4(const Vec4& v): Vec4(v){}
|
PyVec4(const Vec4& v): Vec4(v){}
|
||||||
PyVec4(const PyVec4& v) = default;
|
|
||||||
Vec4* _(){ return this; }
|
Vec4* _(){ return this; }
|
||||||
|
|
||||||
static void _register(VM* vm, PyObject* mod, PyObject* type);
|
static void _register(VM* vm, PyObject* mod, PyObject* type);
|
||||||
@ -155,7 +148,6 @@ struct PyMat3x3: Mat3x3{
|
|||||||
|
|
||||||
PyMat3x3(): Mat3x3(){}
|
PyMat3x3(): Mat3x3(){}
|
||||||
PyMat3x3(const Mat3x3& other): Mat3x3(other){}
|
PyMat3x3(const Mat3x3& other): Mat3x3(other){}
|
||||||
PyMat3x3(const PyMat3x3& other) = default;
|
|
||||||
Mat3x3* _(){ return this; }
|
Mat3x3* _(){ return this; }
|
||||||
|
|
||||||
static void _register(VM* vm, PyObject* mod, PyObject* type);
|
static void _register(VM* vm, PyObject* mod, PyObject* type);
|
||||||
|
@ -32,7 +32,6 @@ namespace pkpy{
|
|||||||
return PK_OBJ_GET(ctype, obj); \
|
return PK_OBJ_GET(ctype, obj); \
|
||||||
} \
|
} \
|
||||||
template<> inline ctype _py_cast<ctype>(VM* vm, PyObject* obj) { \
|
template<> inline ctype _py_cast<ctype>(VM* vm, PyObject* obj) { \
|
||||||
PK_UNUSED(vm); \
|
|
||||||
return PK_OBJ_GET(ctype, obj); \
|
return PK_OBJ_GET(ctype, obj); \
|
||||||
} \
|
} \
|
||||||
template<> inline ctype& py_cast<ctype&>(VM* vm, PyObject* obj) { \
|
template<> inline ctype& py_cast<ctype&>(VM* vm, PyObject* obj) { \
|
||||||
@ -40,7 +39,6 @@ namespace pkpy{
|
|||||||
return PK_OBJ_GET(ctype, obj); \
|
return PK_OBJ_GET(ctype, obj); \
|
||||||
} \
|
} \
|
||||||
template<> inline ctype& _py_cast<ctype&>(VM* vm, PyObject* obj) { \
|
template<> inline ctype& _py_cast<ctype&>(VM* vm, PyObject* obj) { \
|
||||||
PK_UNUSED(vm); \
|
|
||||||
return PK_OBJ_GET(ctype, obj); \
|
return PK_OBJ_GET(ctype, obj); \
|
||||||
} \
|
} \
|
||||||
inline PyObject* py_var(VM* vm, const ctype& value) { return vm->heap.gcnew<ctype>(vm->ptype, value);} \
|
inline PyObject* py_var(VM* vm, const ctype& value) { return vm->heap.gcnew<ctype>(vm->ptype, value);} \
|
||||||
@ -56,7 +54,7 @@ struct PyTypeInfo{
|
|||||||
StrName name;
|
StrName name;
|
||||||
bool subclass_enabled;
|
bool subclass_enabled;
|
||||||
|
|
||||||
std::vector<StrName> annotated_fields;
|
std::vector<StrName> annotated_fields = {};
|
||||||
|
|
||||||
// cached special methods
|
// cached special methods
|
||||||
// unary operators
|
// unary operators
|
||||||
@ -316,7 +314,6 @@ public:
|
|||||||
template<typename T, typename __T>
|
template<typename T, typename __T>
|
||||||
PyObject* bind_notimplemented_constructor(__T&& type) {
|
PyObject* bind_notimplemented_constructor(__T&& type) {
|
||||||
return bind_constructor<-1>(std::forward<__T>(type), [](VM* vm, ArgsView args){
|
return bind_constructor<-1>(std::forward<__T>(type), [](VM* vm, ArgsView args){
|
||||||
PK_UNUSED(args);
|
|
||||||
vm->NotImplementedError();
|
vm->NotImplementedError();
|
||||||
return vm->None;
|
return vm->None;
|
||||||
});
|
});
|
||||||
@ -473,7 +470,6 @@ template<> inline T py_cast<T>(VM* vm, PyObject* obj){ \
|
|||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
template<> inline T _py_cast<T>(VM* vm, PyObject* obj){ \
|
template<> inline T _py_cast<T>(VM* vm, PyObject* obj){ \
|
||||||
PK_UNUSED(vm); \
|
|
||||||
if(is_small_int(obj)) return (T)(PK_BITS(obj) >> 2); \
|
if(is_small_int(obj)) return (T)(PK_BITS(obj) >> 2); \
|
||||||
return (T)PK_OBJ_GET(i64, obj); \
|
return (T)PK_OBJ_GET(i64, obj); \
|
||||||
}
|
}
|
||||||
@ -534,12 +530,10 @@ PY_VAR_INT(unsigned long long)
|
|||||||
#undef PY_VAR_INT
|
#undef PY_VAR_INT
|
||||||
|
|
||||||
inline PyObject* py_var(VM* vm, float _val){
|
inline PyObject* py_var(VM* vm, float _val){
|
||||||
PK_UNUSED(vm);
|
|
||||||
return tag_float(static_cast<f64>(_val));
|
return tag_float(static_cast<f64>(_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PyObject* py_var(VM* vm, double _val){
|
inline PyObject* py_var(VM* vm, double _val){
|
||||||
PK_UNUSED(vm);
|
|
||||||
return tag_float(static_cast<f64>(_val));
|
return tag_float(static_cast<f64>(_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,7 +585,6 @@ inline PyObject* py_var(VM* vm, std::string_view val){
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline PyObject* py_var(VM* vm, NoReturn val){
|
inline PyObject* py_var(VM* vm, NoReturn val){
|
||||||
PK_UNUSED(val);
|
|
||||||
return vm->None;
|
return vm->None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ unsigned char* _default_import_handler(const char* name_p, int name_size, int* o
|
|||||||
unsigned char* buffer = new unsigned char[buffer_size];
|
unsigned char* buffer = new unsigned char[buffer_size];
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
size_t sz = io_fread(buffer, 1, buffer_size, fp);
|
size_t sz = io_fread(buffer, 1, buffer_size, fp);
|
||||||
PK_UNUSED(sz);
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
*out_size = buffer_size;
|
*out_size = buffer_size;
|
||||||
return buffer;
|
return buffer;
|
||||||
|
@ -64,11 +64,11 @@ static bool is_unicode_Lo_char(uint32_t c) {
|
|||||||
// https://docs.python.org/3/reference/lexical_analysis.html#indentation
|
// https://docs.python.org/3/reference/lexical_analysis.html#indentation
|
||||||
if(spaces > indents.top()){
|
if(spaces > indents.top()){
|
||||||
indents.push(spaces);
|
indents.push(spaces);
|
||||||
nexts.push_back(Token{TK("@indent"), token_start, 0, current_line, brackets_level});
|
nexts.push_back(Token{TK("@indent"), token_start, 0, current_line, brackets_level, {}});
|
||||||
} else if(spaces < indents.top()){
|
} else if(spaces < indents.top()){
|
||||||
while(spaces < indents.top()){
|
while(spaces < indents.top()){
|
||||||
indents.pop();
|
indents.pop();
|
||||||
nexts.push_back(Token{TK("@dedent"), token_start, 0, current_line, brackets_level});
|
nexts.push_back(Token{TK("@dedent"), token_start, 0, current_line, brackets_level, {}});
|
||||||
}
|
}
|
||||||
if(spaces != indents.top()){
|
if(spaces != indents.top()){
|
||||||
return false;
|
return false;
|
||||||
@ -467,7 +467,7 @@ static bool is_unicode_Lo_char(uint32_t c) {
|
|||||||
Lexer::Lexer(VM* vm, std::shared_ptr<SourceData> src) : vm(vm), src(src) {
|
Lexer::Lexer(VM* vm, std::shared_ptr<SourceData> src) : vm(vm), src(src) {
|
||||||
this->token_start = src->source.c_str();
|
this->token_start = src->source.c_str();
|
||||||
this->curr_char = src->source.c_str();
|
this->curr_char = src->source.c_str();
|
||||||
this->nexts.push_back(Token{TK("@sof"), token_start, 0, current_line, brackets_level});
|
this->nexts.push_back(Token{TK("@sof"), token_start, 0, current_line, brackets_level, {}});
|
||||||
this->indents.push(0);
|
this->indents.push(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,19 +422,16 @@ static Vec2 SmoothDamp(Vec2 current, Vec2 target, PyVec2& currentVelocity, float
|
|||||||
|
|
||||||
// @staticmethod
|
// @staticmethod
|
||||||
vm->bind(type, "zeros()", [](VM* vm, ArgsView args){
|
vm->bind(type, "zeros()", [](VM* vm, ArgsView args){
|
||||||
PK_UNUSED(args);
|
|
||||||
return VAR_T(PyMat3x3, Mat3x3::zeros());
|
return VAR_T(PyMat3x3, Mat3x3::zeros());
|
||||||
}, {}, BindType::STATICMETHOD);
|
}, {}, BindType::STATICMETHOD);
|
||||||
|
|
||||||
// @staticmethod
|
// @staticmethod
|
||||||
vm->bind(type, "ones()", [](VM* vm, ArgsView args){
|
vm->bind(type, "ones()", [](VM* vm, ArgsView args){
|
||||||
PK_UNUSED(args);
|
|
||||||
return VAR_T(PyMat3x3, Mat3x3::ones());
|
return VAR_T(PyMat3x3, Mat3x3::ones());
|
||||||
}, {}, BindType::STATICMETHOD);
|
}, {}, BindType::STATICMETHOD);
|
||||||
|
|
||||||
// @staticmethod
|
// @staticmethod
|
||||||
vm->bind(type, "identity()", [](VM* vm, ArgsView args){
|
vm->bind(type, "identity()", [](VM* vm, ArgsView args){
|
||||||
PK_UNUSED(args);
|
|
||||||
return VAR_T(PyMat3x3, Mat3x3::identity());
|
return VAR_T(PyMat3x3, Mat3x3::identity());
|
||||||
}, {}, BindType::STATICMETHOD);
|
}, {}, BindType::STATICMETHOD);
|
||||||
|
|
||||||
|
@ -1460,7 +1460,6 @@ void VM::post_init(){
|
|||||||
|
|
||||||
// type
|
// type
|
||||||
bind__getitem__(tp_type, [](VM* vm, PyObject* self, PyObject* _){
|
bind__getitem__(tp_type, [](VM* vm, PyObject* self, PyObject* _){
|
||||||
PK_UNUSED(_);
|
|
||||||
return self; // for generics
|
return self; // for generics
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -79,9 +79,6 @@ namespace pkpy{
|
|||||||
_main = nullptr;
|
_main = nullptr;
|
||||||
_last_exception = nullptr;
|
_last_exception = nullptr;
|
||||||
_import_handler = [](const char* name_p, int name_size, int* out_size) -> unsigned char*{
|
_import_handler = [](const char* name_p, int name_size, int* out_size) -> unsigned char*{
|
||||||
PK_UNUSED(name_p);
|
|
||||||
PK_UNUSED(name_size);
|
|
||||||
PK_UNUSED(out_size);
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
init_builtin_types();
|
init_builtin_types();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user