mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibJS: Add Cell::interpreter() convenience helper
This allows you to go from any Cell* to the Interpreter.
This commit is contained in:
parent
fbefb19e10
commit
9b4358e150
3 changed files with 9 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <AK/LogStream.h>
|
#include <AK/LogStream.h>
|
||||||
#include <LibJS/Cell.h>
|
#include <LibJS/Cell.h>
|
||||||
|
#include <LibJS/Heap.h>
|
||||||
#include <LibJS/HeapBlock.h>
|
#include <LibJS/HeapBlock.h>
|
||||||
#include <LibJS/Object.h>
|
#include <LibJS/Object.h>
|
||||||
#include <LibJS/PrimitiveString.h>
|
#include <LibJS/PrimitiveString.h>
|
||||||
|
@ -44,6 +45,11 @@ Heap& Cell::heap()
|
||||||
return HeapBlock::from_cell(this)->heap();
|
return HeapBlock::from_cell(this)->heap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Interpreter& Cell::interpreter()
|
||||||
|
{
|
||||||
|
return heap().interpreter();
|
||||||
|
}
|
||||||
|
|
||||||
const LogStream& operator<<(const LogStream& stream, const Cell* cell)
|
const LogStream& operator<<(const LogStream& stream, const Cell* cell)
|
||||||
{
|
{
|
||||||
if (!cell)
|
if (!cell)
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
virtual void visit_children(Visitor&) {}
|
virtual void visit_children(Visitor&) {}
|
||||||
|
|
||||||
Heap& heap();
|
Heap& heap();
|
||||||
|
Interpreter& interpreter();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_mark { false };
|
bool m_mark { false };
|
||||||
|
|
|
@ -53,6 +53,8 @@ public:
|
||||||
|
|
||||||
void collect_garbage();
|
void collect_garbage();
|
||||||
|
|
||||||
|
Interpreter& interpreter() { return m_interpreter; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Cell* allocate_cell(size_t);
|
Cell* allocate_cell(size_t);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue