blueloveTH 2 년 전
부모
커밋
ea8d982866
4개의 변경된 파일14개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      src/ceval.h
  2. 3 3
      src/obj.h
  3. 1 0
      src/str.h
  4. 9 0
      src/tuplelist.h

+ 1 - 1
src/ceval.h

@@ -87,7 +87,7 @@ PyVar VM::run_frame(Frame* frame){
             PyVar clsBase = frame->pop_value(this);
             PyVar clsBase = frame->pop_value(this);
             if(clsBase == None) clsBase = _t(tp_object);
             if(clsBase == None) clsBase = _t(tp_object);
             check_type(clsBase, tp_type);
             check_type(clsBase, tp_type);
-            PyVar cls = new_type_object(frame->_module, name.first, clsBase);
+            PyVar cls = new_type_object(frame->_module, name.first, OBJ_GET(Type, clsBase));
             frame->push(cls);
             frame->push(cls);
         } continue;
         } continue;
         case OP_END_CLASS: {
         case OP_END_CLASS: {

+ 3 - 3
src/obj.h

@@ -153,12 +153,12 @@ inline bool is_float(const PyVar& obj) noexcept {
 
 
 #define PY_CLASS(T, mod, name) \
 #define PY_CLASS(T, mod, name) \
     static Type _type(VM* vm) {  \
     static Type _type(VM* vm) {  \
-        static StrName __x0(#mod);      \
-        static StrName __x1(#name);     \
+        static const StrName __x0(#mod);      \
+        static const StrName __x1(#name);     \
         return OBJ_GET(Type, vm->_modules[__x0]->attr(__x1));               \
         return OBJ_GET(Type, vm->_modules[__x0]->attr(__x1));               \
     }                                                                       \
     }                                                                       \
     static PyVar register_class(VM* vm, PyVar mod) {                        \
     static PyVar register_class(VM* vm, PyVar mod) {                        \
-        PyVar type = vm->new_type_object(mod, #name, vm->_t(vm->tp_object));\
+        PyVar type = vm->new_type_object(mod, #name, vm->tp_object);        \
         if(OBJ_NAME(mod) != #mod) UNREACHABLE();                            \
         if(OBJ_NAME(mod) != #mod) UNREACHABLE();                            \
         T::_register(vm, mod, type);                                        \
         T::_register(vm, mod, type);                                        \
         type->attr()._try_perfect_rehash();                                 \
         type->attr()._try_perfect_rehash();                                 \

+ 1 - 0
src/str.h

@@ -202,6 +202,7 @@ const StrName __json__ = StrName::get("__json__");
 const StrName __name__ = StrName::get("__name__");
 const StrName __name__ = StrName::get("__name__");
 const StrName __len__ = StrName::get("__len__");
 const StrName __len__ = StrName::get("__len__");
 const StrName __get__ = StrName::get("__get__");
 const StrName __get__ = StrName::get("__get__");
+const StrName __set__ = StrName::get("__set__");
 const StrName __getattr__ = StrName::get("__getattr__");
 const StrName __getattr__ = StrName::get("__getattr__");
 const StrName __setattr__ = StrName::get("__setattr__");
 const StrName __setattr__ = StrName::get("__setattr__");
 const StrName __call__ = StrName::get("__call__");
 const StrName __call__ = StrName::get("__call__");

+ 9 - 0
src/tuplelist.h

@@ -96,6 +96,15 @@ namespace pkpy {
         return ret;
         return ret;
     }
     }
 
 
+    template<typename T1, typename T2, typename T3>
+    Args three_args(T1&& a, T2&& b, T3&& c) {
+        Args ret(3);
+        ret[0] = std::forward<T1>(a);
+        ret[1] = std::forward<T2>(b);
+        ret[2] = std::forward<T3>(c);
+        return ret;
+    }
+
     typedef Args Tuple;
     typedef Args Tuple;
     THREAD_LOCAL SmallArrayPool<PyVar, 10> Args::_pool;
     THREAD_LOCAL SmallArrayPool<PyVar, 10> Args::_pool;
 }   // namespace pkpy
 }   // namespace pkpy