blueloveTH 2 лет назад
Родитель
Сommit
3738d07941
7 измененных файлов с 26 добавлено и 8 удалено
  1. 1 1
      build.py
  2. 2 2
      src/codeobject.h
  3. 2 0
      src/common.h
  4. 1 1
      src/error.h
  5. 1 1
      src/lexer.h
  6. 2 0
      src/obj.h
  7. 17 3
      src/vm.h

+ 1 - 1
build.py

@@ -9,7 +9,7 @@ os.system("python3 preprocess.py")
 def DONE(code=0):
     exit(code)
 
-linux_common = "-Wfatal-errors --std=c++17 -O2 -Wall -Wno-sign-compare -Wno-unused-variable -fno-rtti -stdlib=libc++"
+linux_common = "-Wfatal-errors --std=c++17 -O2 -Wall -fno-rtti -stdlib=libc++"
 linux_cmd = "clang++ -o pocketpy src/main.cpp " + linux_common
 linux_lib_cmd = "clang++ -fPIC -shared -o pocketpy.so src/tmp.cpp " + linux_common
 

+ 2 - 2
src/codeobject.h

@@ -189,8 +189,8 @@ struct CodeObject {
             }
         ss.write_end_mark();            // ]
         ss.write_begin_mark();          // [
-            for(StrName name: varnames){
-                ss.write_name(name);        // name
+            for(StrName vn: varnames){
+                ss.write_name(vn);        // name
             }
         ss.write_end_mark();            // ]
         ss.write_begin_mark();          // [

+ 2 - 0
src/common.h

@@ -48,6 +48,8 @@ struct GIL {
 
 /*******************************************************************************/
 
+#define PK_UNUSED(x) (void)(x)
+
 namespace pkpy{
 
 namespace std = ::std;

+ 1 - 1
src/error.h

@@ -84,7 +84,7 @@ class Exception {
     StackTrace stacktrace;
 public:
     Exception(StrName type, Str msg): type(type), msg(msg) {}
-    bool match_type(StrName type) const { return this->type == type;}
+    bool match_type(StrName t) const { return this->type == t;}
     bool is_re = true;
 
     void st_push(Str snapshot){

+ 1 - 1
src/lexer.h

@@ -381,7 +381,7 @@ struct Lexer {
             } else {
                 add_token(TK("@num"), Number::stoi(m[0], &size, base));
             }
-            PK_ASSERT(size == m.length());
+            PK_ASSERT((int)size == (int)m.length());
         }catch(std::exception& _){
             SyntaxError("invalid number literal");
         } 

+ 2 - 0
src/obj.h

@@ -406,6 +406,7 @@ struct Py_<Super> final: PyObject {
 template<>
 struct Py_<DummyInstance> final: PyObject {
     Py_(Type type, DummyInstance val): PyObject(type) {
+        PK_UNUSED(val);
         enable_instance_dict();
     }
     void _obj_gc_mark() override {}
@@ -423,6 +424,7 @@ struct Py_<Type> final: PyObject {
 template<>
 struct Py_<DummyModule> final: PyObject {
     Py_(Type type, DummyModule val): PyObject(type) {
+        PK_UNUSED(val);
         enable_instance_dict(kTypeAttrLoadFactor);
     }
     void _obj_gc_mark() override {}

+ 17 - 3
src/vm.h

@@ -31,6 +31,7 @@ namespace pkpy{
         return PK_OBJ_GET(ctype, obj);                                     \
     }                                                                   \
     template<> inline ctype _py_cast<ctype>(VM* vm, PyObject* obj) {    \
+        PK_UNUSED(vm);                                                  \
         return PK_OBJ_GET(ctype, obj);                                     \
     }                                                                   \
     template<> inline ctype& py_cast<ctype&>(VM* vm, PyObject* obj) {   \
@@ -38,6 +39,7 @@ namespace pkpy{
         return PK_OBJ_GET(ctype, obj);                                     \
     }                                                                   \
     template<> inline ctype& _py_cast<ctype&>(VM* vm, PyObject* obj) {  \
+        PK_UNUSED(vm);                                                  \
         return PK_OBJ_GET(ctype, obj);                                     \
     }                                                                   \
     inline PyObject* py_var(VM* vm, const ctype& value) { return vm->heap.gcnew(vm->ptype, value);}     \
@@ -147,12 +149,21 @@ public:
 
     VM(bool enable_os=true) : heap(this), enable_os(enable_os) {
         this->vm = this;
-        _stdout = [](VM* vm, const Str& s) { std::cout << s; };
-        _stderr = [](VM* vm, const Str& s) { std::cerr << s; };
+        _stdout = [](VM* vm, const Str& s) {
+            PK_UNUSED(vm);
+            std::cout << s;
+        };
+        _stderr = [](VM* vm, const Str& s) {
+            PK_UNUSED(vm);
+            std::cerr << s;
+        };
         callstack.reserve(8);
         _main = nullptr;
         _last_exception = nullptr;
-        _import_handler = [](const Str& name) { return Bytes(); };
+        _import_handler = [](const Str& name) {
+            PK_UNUSED(name);
+            return Bytes();
+        };
         init_builtin_types();
     }
 
@@ -706,6 +717,7 @@ template<> inline T py_cast<T>(VM* vm, PyObject* obj){  \
     return (T)(PK_BITS(obj) >> 2);                         \
 }                                                       \
 template<> inline T _py_cast<T>(VM* vm, PyObject* obj){ \
+    PK_UNUSED(vm);                                      \
     return (T)(PK_BITS(obj) >> 2);                         \
 }
 
@@ -810,10 +822,12 @@ inline PyObject* py_var(VM* vm, std::string_view val){
 }
 
 inline PyObject* py_var(VM* vm, NoReturn val){
+    PK_UNUSED(val);
     return vm->None;
 }
 
 inline PyObject* py_var(VM* vm, PyObject* val){
+    PK_UNUSED(vm);
     return val;
 }