mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 20:40:18 +00:00
some fix
This commit is contained in:
parent
ff52c52349
commit
2868a955bb
@ -102,12 +102,14 @@ struct Slice {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct PyObject final{
|
struct PyObject final{
|
||||||
|
static constexpr int FIXED_SIZE = 16;
|
||||||
|
|
||||||
bool gc_marked; // whether this object is marked
|
bool gc_marked; // whether this object is marked
|
||||||
Type type; // we have a duplicated type here for saving memory
|
Type type; // we have a duplicated type here for saving memory
|
||||||
NameDict* _attr;
|
NameDict* _attr;
|
||||||
|
|
||||||
bool is_attr_valid() const noexcept { return _attr != nullptr; }
|
bool is_attr_valid() const noexcept { return _attr != nullptr; }
|
||||||
void* _value_ptr() noexcept { return 1 + &_attr; }
|
void* _value_ptr() noexcept { return (char*)this + FIXED_SIZE; }
|
||||||
|
|
||||||
NameDict& attr() {
|
NameDict& attr() {
|
||||||
PK_DEBUG_ASSERT(is_attr_valid())
|
PK_DEBUG_ASSERT(is_attr_valid())
|
||||||
@ -144,10 +146,9 @@ struct PyObject final{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(PyObject) <= PyObject::FIXED_SIZE);
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline constexpr int py_sizeof = sizeof(PyObject) + sizeof(T);
|
inline constexpr int py_sizeof = PyObject::FIXED_SIZE + sizeof(T);
|
||||||
|
|
||||||
static_assert(sizeof(PyObject) <= 16);
|
|
||||||
|
|
||||||
const int kTpIntIndex = 3;
|
const int kTpIntIndex = 3;
|
||||||
const int kTpFloatIndex = 4;
|
const int kTpFloatIndex = 4;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user