LibJS+LibWeb: Move headers around to allow including Value from Cell
The goal here is to allow Cell::initialize to return a ThrowCompletion, to handle OOM for example. Cell.h will then need to include Completion.h which must include Value.h. This currently can't happen because Value.h includes BigInt.h, which in turn includes Cell.h. So we would have an include cycle. This removes BigInt.h from Value.h, as it is forward-declarable (it is only referred to with a reference or pointer). Then the Value overload for Cell::Visitor::visit is moved to Cell.h, and missing BigInt.h includes as peppered as needed.
This commit is contained in:
parent
b0a4df76de
commit
1c1b902a6a
Notes:
sideshowbarker
2024-07-17 01:01:33 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/1c1b902a6a Pull-request: https://github.com/SerenityOS/serenity/pull/17220 Reviewed-by: https://github.com/linusg ✅
11 changed files with 19 additions and 8 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
@ -53,22 +54,30 @@ public:
|
|||
if (cell)
|
||||
visit_impl(*cell);
|
||||
}
|
||||
|
||||
void visit(Cell& cell)
|
||||
{
|
||||
visit_impl(cell);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void visit(GCPtr<T> cell)
|
||||
{
|
||||
if (cell)
|
||||
visit_impl(*cell.ptr());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void visit(NonnullGCPtr<T> cell)
|
||||
{
|
||||
visit_impl(*cell.ptr());
|
||||
}
|
||||
void visit(Value);
|
||||
|
||||
void visit(Value value)
|
||||
{
|
||||
if (value.is_cell())
|
||||
visit_impl(value.as_cell());
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void visit_impl(Cell&) = 0;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibJS/Runtime/BigInt.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||
#include <LibJS/Runtime/BigInt.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace JS::Intl {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/Math.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/BigInt.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/NumberConstructor.h>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <AK/Types.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Runtime/BigInt.h>
|
||||
#include <math.h>
|
||||
|
||||
// 2 ** 53 - 1
|
||||
|
@ -526,12 +525,6 @@ inline Value js_negative_infinity()
|
|||
return Value(-INFINITY);
|
||||
}
|
||||
|
||||
inline void Cell::Visitor::visit(Value value)
|
||||
{
|
||||
if (value.is_cell())
|
||||
visit_impl(value.as_cell());
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> greater_than(VM&, Value lhs, Value rhs);
|
||||
ThrowCompletionOr<Value> greater_than_equals(VM&, Value lhs, Value rhs);
|
||||
ThrowCompletionOr<Value> less_than(VM&, Value lhs, Value rhs);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/BigInt.h>
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/TypeCasts.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/CSS/ComputedValues.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue