mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:37:45 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
8639d8bc21
commit
d26aabff04
140 changed files with 1202 additions and 723 deletions
|
@ -192,19 +192,19 @@ private:
|
|||
};
|
||||
|
||||
template<typename Func, typename... Args>
|
||||
concept ThrowCompletionOrVoidFunction = requires(Func func, Args... args)
|
||||
{
|
||||
{
|
||||
func(args...)
|
||||
}
|
||||
-> SameAs<ThrowCompletionOr<void>>;
|
||||
};
|
||||
concept ThrowCompletionOrVoidFunction = requires(Func func, Args... args) {
|
||||
{
|
||||
func(args...)
|
||||
}
|
||||
-> SameAs<ThrowCompletionOr<void>>;
|
||||
};
|
||||
|
||||
template<typename... Args>
|
||||
class ThrowCompletionOrVoidCallback : public Function<ThrowCompletionOr<void>(Args...)> {
|
||||
public:
|
||||
template<typename CallableType>
|
||||
ThrowCompletionOrVoidCallback(CallableType&& callable) requires(VoidFunction<CallableType, Args...>)
|
||||
ThrowCompletionOrVoidCallback(CallableType&& callable)
|
||||
requires(VoidFunction<CallableType, Args...>)
|
||||
: Function<ThrowCompletionOr<void>(Args...)>([callable = forward<CallableType>(callable)](Args... args) {
|
||||
callable(args...);
|
||||
return ThrowCompletionOr<void> {};
|
||||
|
@ -213,7 +213,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename CallableType>
|
||||
ThrowCompletionOrVoidCallback(CallableType&& callable) requires(ThrowCompletionOrVoidFunction<CallableType, Args...>)
|
||||
ThrowCompletionOrVoidCallback(CallableType&& callable)
|
||||
requires(ThrowCompletionOrVoidFunction<CallableType, Args...>)
|
||||
: Function<ThrowCompletionOr<void>(Args...)>(forward<CallableType>(callable))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -173,7 +173,8 @@ public:
|
|||
LeaveVariableEnvironment,
|
||||
};
|
||||
template<typename OpType>
|
||||
void perform_needed_unwinds(bool is_break_node = false) requires(OpType::IsTerminator)
|
||||
void perform_needed_unwinds(bool is_break_node = false)
|
||||
requires(OpType::IsTerminator)
|
||||
{
|
||||
Optional<BlockBoundaryType> boundary_to_stop_at;
|
||||
if constexpr (IsSame<OpType, Bytecode::Op::Return> || IsSame<OpType, Bytecode::Op::Yield>)
|
||||
|
|
|
@ -104,26 +104,28 @@ private:
|
|||
O(RightShift, right_shift) \
|
||||
O(UnsignedRightShift, unsigned_right_shift)
|
||||
|
||||
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
explicit OpTitleCase(Register lhs_reg) \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
, m_lhs_reg(lhs_reg) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { } \
|
||||
void replace_references_impl(Register from, Register to) \
|
||||
{ \
|
||||
if (m_lhs_reg == from) \
|
||||
m_lhs_reg = to; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
Register m_lhs_reg; \
|
||||
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
explicit OpTitleCase(Register lhs_reg) \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
, m_lhs_reg(lhs_reg) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) \
|
||||
{ \
|
||||
} \
|
||||
void replace_references_impl(Register from, Register to) \
|
||||
{ \
|
||||
if (m_lhs_reg == from) \
|
||||
m_lhs_reg = to; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
Register m_lhs_reg; \
|
||||
};
|
||||
|
||||
JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
|
||||
|
@ -136,18 +138,22 @@ JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
|
|||
O(UnaryMinus, unary_minus) \
|
||||
O(Typeof, typeof_)
|
||||
|
||||
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
OpTitleCase() \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { } \
|
||||
void replace_references_impl(Register, Register) { } \
|
||||
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
OpTitleCase() \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) \
|
||||
{ \
|
||||
} \
|
||||
void replace_references_impl(Register, Register) \
|
||||
{ \
|
||||
} \
|
||||
};
|
||||
|
||||
JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
|
||||
|
|
|
@ -29,19 +29,22 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr(U& ptr) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr(U& ptr)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
: m_ptr(&static_cast<T&>(ptr))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr(U const& ptr) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr(U const& ptr)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
: m_ptr(&const_cast<T&>(static_cast<T const&>(ptr)))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr(NonnullGCPtr<U> ptr) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr(NonnullGCPtr<U> ptr)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
: m_ptr(ptr)
|
||||
{
|
||||
}
|
||||
|
@ -59,14 +62,16 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr& operator=(U const& other) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr& operator=(U const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = &const_cast<T&>(static_cast<T const&>(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr& operator=(NonnullGCPtr<U> const& other) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr& operator=(NonnullGCPtr<U> const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = const_cast<T*>(static_cast<T const*>(other.ptr()));
|
||||
return *this;
|
||||
|
@ -117,7 +122,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
GCPtr(NonnullGCPtr<U> ptr) requires(IsConvertible<U*, T*>)
|
||||
GCPtr(NonnullGCPtr<U> ptr)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
: m_ptr(ptr)
|
||||
{
|
||||
}
|
||||
|
@ -131,7 +137,8 @@ public:
|
|||
GCPtr& operator=(GCPtr const&) = default;
|
||||
|
||||
template<typename U>
|
||||
GCPtr& operator=(GCPtr<U> const& other) requires(IsConvertible<U*, T*>)
|
||||
GCPtr& operator=(GCPtr<U> const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = const_cast<T*>(static_cast<T const*>(other.ptr()));
|
||||
return *this;
|
||||
|
@ -144,7 +151,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
GCPtr& operator=(NonnullGCPtr<U> const& other) requires(IsConvertible<U*, T*>)
|
||||
GCPtr& operator=(NonnullGCPtr<U> const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = const_cast<T*>(static_cast<T const*>(other.ptr()));
|
||||
return *this;
|
||||
|
@ -157,7 +165,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
GCPtr& operator=(U const& other) requires(IsConvertible<U*, T*>)
|
||||
GCPtr& operator=(U const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = &const_cast<T&>(static_cast<T const&>(other));
|
||||
return *this;
|
||||
|
@ -170,7 +179,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
GCPtr& operator=(U const* other) requires(IsConvertible<U*, T*>)
|
||||
GCPtr& operator=(U const* other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = const_cast<T*>(static_cast<T const*>(other));
|
||||
return *this;
|
||||
|
|
|
@ -36,7 +36,8 @@ struct ExecutingASTNodeChain {
|
|||
class Interpreter : public Weakable<Interpreter> {
|
||||
public:
|
||||
template<typename GlobalObjectType, typename... Args>
|
||||
static NonnullOwnPtr<Interpreter> create(VM& vm, Args&&... args) requires(IsBaseOf<GlobalObject, GlobalObjectType>)
|
||||
static NonnullOwnPtr<Interpreter> create(VM& vm, Args&&... args)
|
||||
requires(IsBaseOf<GlobalObject, GlobalObjectType>)
|
||||
{
|
||||
DeferGC defer_gc(vm.heap());
|
||||
auto interpreter = adopt_own(*new Interpreter(vm));
|
||||
|
|
|
@ -363,7 +363,8 @@ ErrorOr<void> print_async_generator(JS::PrintContext& print_context, JS::AsyncGe
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
ErrorOr<void> print_number(JS::PrintContext& print_context, T number) requires IsArithmetic<T>
|
||||
ErrorOr<void> print_number(JS::PrintContext& print_context, T number)
|
||||
requires IsArithmetic<T>
|
||||
{
|
||||
TRY(js_out(print_context, "\033[35;1m"));
|
||||
TRY(js_out(print_context, "{}", number));
|
||||
|
|
|
@ -168,7 +168,8 @@ Vector<T> merge_lists(Vector<T> const& a, Vector<T> const& b)
|
|||
|
||||
// x modulo y, https://tc39.es/ecma262/#eqn-modulo
|
||||
template<typename T, typename U>
|
||||
auto modulo(T x, U y) requires(IsArithmetic<T>, IsArithmetic<U>)
|
||||
auto modulo(T x, U y)
|
||||
requires(IsArithmetic<T>, IsArithmetic<U>)
|
||||
{
|
||||
// The notation “x modulo y” (y must be finite and non-zero) computes a value k of the same sign as y (or zero) such that abs(k) < abs(y) and x - k = q × y for some integer q.
|
||||
VERIFY(y != 0);
|
||||
|
|
|
@ -148,7 +148,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U = JS::Completion>
|
||||
explicit(!IsConvertible<U&&, JS::Completion>) Optional(U&& value) requires(!IsSame<RemoveCVReference<U>, Optional<JS::Completion>> && IsConstructible<JS::Completion, U&&>)
|
||||
explicit(!IsConvertible<U&&, JS::Completion>) Optional(U&& value)
|
||||
requires(!IsSame<RemoveCVReference<U>, Optional<JS::Completion>> && IsConstructible<JS::Completion, U &&>)
|
||||
: m_value(forward<U>(value))
|
||||
{
|
||||
}
|
||||
|
@ -237,7 +238,8 @@ namespace JS {
|
|||
template<typename ValueType>
|
||||
class [[nodiscard]] ThrowCompletionOr {
|
||||
public:
|
||||
ThrowCompletionOr() requires(IsSame<ValueType, Empty>)
|
||||
ThrowCompletionOr()
|
||||
requires(IsSame<ValueType, Empty>)
|
||||
: m_value(Empty {})
|
||||
{
|
||||
}
|
||||
|
@ -266,7 +268,8 @@ public:
|
|||
// Most commonly: Value from Object* or similar, so we can omit the curly braces from "return { TRY(...) };".
|
||||
// Disabled for POD types to avoid weird conversion shenanigans.
|
||||
template<typename WrappedValueType>
|
||||
ThrowCompletionOr(WrappedValueType value) requires(!IsPOD<ValueType>)
|
||||
ThrowCompletionOr(WrappedValueType value)
|
||||
requires(!IsPOD<ValueType>)
|
||||
: m_value(move(value))
|
||||
{
|
||||
}
|
||||
|
@ -274,8 +277,16 @@ public:
|
|||
[[nodiscard]] bool is_throw_completion() const { return m_throw_completion.has_value(); }
|
||||
Completion const& throw_completion() const { return *m_throw_completion; }
|
||||
|
||||
[[nodiscard]] bool has_value() const requires(!IsSame<ValueType, Empty>) { return m_value.has_value(); }
|
||||
[[nodiscard]] ValueType const& value() const requires(!IsSame<ValueType, Empty>) { return *m_value; }
|
||||
[[nodiscard]] bool has_value() const
|
||||
requires(!IsSame<ValueType, Empty>)
|
||||
{
|
||||
return m_value.has_value();
|
||||
}
|
||||
[[nodiscard]] ValueType const& value() const
|
||||
requires(!IsSame<ValueType, Empty>)
|
||||
{
|
||||
return *m_value;
|
||||
}
|
||||
|
||||
// These are for compatibility with the TRY() macro in AK.
|
||||
[[nodiscard]] bool is_error() const { return m_throw_completion.has_value(); }
|
||||
|
|
|
@ -65,13 +65,15 @@ public:
|
|||
|
||||
private:
|
||||
friend class Map;
|
||||
IteratorImpl(Map const& map) requires(IsConst)
|
||||
IteratorImpl(Map const& map)
|
||||
requires(IsConst)
|
||||
: m_map(map)
|
||||
{
|
||||
ensure_index();
|
||||
}
|
||||
|
||||
IteratorImpl(Map& map) requires(!IsConst)
|
||||
IteratorImpl(Map& map)
|
||||
requires(!IsConst)
|
||||
: m_map(map)
|
||||
{
|
||||
ensure_index();
|
||||
|
|
|
@ -17,7 +17,10 @@ namespace JS {
|
|||
#define JS_PROTOTYPE_OBJECT(prototype_class, object_class, display_name_) \
|
||||
using Prototype = PrototypeObject<prototype_class, object_class>; \
|
||||
JS_OBJECT(prototype_class, Prototype) \
|
||||
static constexpr StringView display_name() { return #display_name_##sv; }
|
||||
static constexpr StringView display_name() \
|
||||
{ \
|
||||
return #display_name_##sv; \
|
||||
}
|
||||
|
||||
template<typename PrototypeType, typename ObjectType>
|
||||
class PrototypeObject : public Object {
|
||||
|
|
|
@ -601,7 +601,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U = JS::Value>
|
||||
explicit(!IsConvertible<U&&, JS::Value>) Optional(U&& value) requires(!IsSame<RemoveCVReference<U>, Optional<JS::Value>> && IsConstructible<JS::Value, U&&>)
|
||||
explicit(!IsConvertible<U&&, JS::Value>) Optional(U&& value)
|
||||
requires(!IsSame<RemoveCVReference<U>, Optional<JS::Value>> && IsConstructible<JS::Value, U &&>)
|
||||
: m_value(forward<U>(value))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -50,13 +50,15 @@ public:
|
|||
}
|
||||
|
||||
template<typename CallableType>
|
||||
SafeFunction(CallableType&& callable) requires((AK::IsFunctionObject<CallableType> && IsCallableWithArguments<CallableType, In...> && !IsSame<RemoveCVReference<CallableType>, SafeFunction>))
|
||||
SafeFunction(CallableType&& callable)
|
||||
requires((AK::IsFunctionObject<CallableType> && IsCallableWithArguments<CallableType, In...> && !IsSame<RemoveCVReference<CallableType>, SafeFunction>))
|
||||
{
|
||||
init_with_callable(forward<CallableType>(callable), CallableKind::FunctionObject);
|
||||
}
|
||||
|
||||
template<typename FunctionType>
|
||||
SafeFunction(FunctionType f) requires((AK::IsFunctionPointer<FunctionType> && IsCallableWithArguments<RemovePointer<FunctionType>, In...> && !IsSame<RemoveCVReference<FunctionType>, SafeFunction>))
|
||||
SafeFunction(FunctionType f)
|
||||
requires((AK::IsFunctionPointer<FunctionType> && IsCallableWithArguments<RemovePointer<FunctionType>, In...> && !IsSame<RemoveCVReference<FunctionType>, SafeFunction>))
|
||||
{
|
||||
init_with_callable(move(f), CallableKind::FunctionPointer);
|
||||
}
|
||||
|
@ -82,7 +84,8 @@ public:
|
|||
explicit operator bool() const { return !!callable_wrapper(); }
|
||||
|
||||
template<typename CallableType>
|
||||
SafeFunction& operator=(CallableType&& callable) requires((AK::IsFunctionObject<CallableType> && IsCallableWithArguments<CallableType, In...>))
|
||||
SafeFunction& operator=(CallableType&& callable)
|
||||
requires((AK::IsFunctionObject<CallableType> && IsCallableWithArguments<CallableType, In...>))
|
||||
{
|
||||
clear();
|
||||
init_with_callable(forward<CallableType>(callable));
|
||||
|
@ -90,7 +93,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename FunctionType>
|
||||
SafeFunction& operator=(FunctionType f) requires((AK::IsFunctionPointer<FunctionType> && IsCallableWithArguments<RemovePointer<FunctionType>, In...>))
|
||||
SafeFunction& operator=(FunctionType f)
|
||||
requires((AK::IsFunctionPointer<FunctionType> && IsCallableWithArguments<RemovePointer<FunctionType>, In...>))
|
||||
{
|
||||
clear();
|
||||
if (f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue