1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

LibJS: Resolve a circular include problem between HeapBlock and Cell

Cell::heap() and Cell::vm() needed to access member functions from
HeapBlock, and wanted to be inline, so they were moved to VM.h.
That approach will no longer work with VM.h not being included in every
file (starting from the next commit), so this commit fixes that circular
import issue by introducing secondary base classes to host the
references to Heap and VM, respectively.
This commit is contained in:
Ali Mohammad Pur 2023-07-09 20:05:02 +03:30 committed by Ali Mohammad Pur
parent 41f9dcd89b
commit 392b5c3b19
7 changed files with 64 additions and 25 deletions

View file

@ -13,6 +13,7 @@
#include <AK/StringView.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibJS/Heap/Internals.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Value.h>
@ -105,8 +106,8 @@ public:
bool overrides_must_survive_garbage_collection(Badge<Heap>) const { return m_overrides_must_survive_garbage_collection; }
Heap& heap() const;
VM& vm() const;
ALWAYS_INLINE Heap& heap() const { return HeapBlockBase::from_cell(this)->heap(); }
ALWAYS_INLINE VM& vm() const { return bit_cast<HeapBase*>(&heap())->vm(); }
protected:
Cell() = default;