diff --git a/src/ceval.h b/src/ceval.h index 2161117f..2eaed684 100644 --- a/src/ceval.h +++ b/src/ceval.h @@ -87,7 +87,7 @@ PyVar VM::run_frame(Frame* frame){ PyVar clsBase = frame->pop_value(this); if(clsBase == None) clsBase = _t(tp_object); 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); } continue; case OP_END_CLASS: { diff --git a/src/obj.h b/src/obj.h index 3b5d43a3..3454612c 100644 --- a/src/obj.h +++ b/src/obj.h @@ -153,12 +153,12 @@ inline bool is_float(const PyVar& obj) noexcept { #define PY_CLASS(T, mod, name) \ 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)); \ } \ 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(); \ T::_register(vm, mod, type); \ type->attr()._try_perfect_rehash(); \ diff --git a/src/str.h b/src/str.h index 0364eb0d..7c7ccd88 100644 --- a/src/str.h +++ b/src/str.h @@ -202,6 +202,7 @@ const StrName __json__ = StrName::get("__json__"); const StrName __name__ = StrName::get("__name__"); const StrName __len__ = StrName::get("__len__"); const StrName __get__ = StrName::get("__get__"); +const StrName __set__ = StrName::get("__set__"); const StrName __getattr__ = StrName::get("__getattr__"); const StrName __setattr__ = StrName::get("__setattr__"); const StrName __call__ = StrName::get("__call__"); diff --git a/src/tuplelist.h b/src/tuplelist.h index b2523d0d..5594a563 100644 --- a/src/tuplelist.h +++ b/src/tuplelist.h @@ -96,6 +96,15 @@ namespace pkpy { return ret; } + template + Args three_args(T1&& a, T2&& b, T3&& c) { + Args ret(3); + ret[0] = std::forward(a); + ret[1] = std::forward(b); + ret[2] = std::forward(c); + return ret; + } + typedef Args Tuple; THREAD_LOCAL SmallArrayPool Args::_pool; } // namespace pkpy \ No newline at end of file