From bd5d8e9d3526c2038545ac2480af2fa7a5147afa Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 19 Feb 2023 22:07:52 +0100 Subject: LibJS: Make RefPtr and NonnullRefPtr usage const-correct This mainly affected the AST, which is now const throughout. --- Userland/Libraries/LibJS/AST.h | 338 ++++++++++++++++++++--------------------- 1 file changed, 168 insertions(+), 170 deletions(-) (limited to 'Userland/Libraries/LibJS/AST.h') diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h index a620205f7f..e73999e84a 100644 --- a/Userland/Libraries/LibJS/AST.h +++ b/Userland/Libraries/LibJS/AST.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, Andreas Kling + * Copyright (c) 2020-2023, Andreas Kling * Copyright (c) 2020-2022, Linus Groh * Copyright (c) 2021-2022, David Tuin * @@ -97,7 +97,7 @@ private: // NOTE: These members are carefully ordered so that `m_start_offset` is packed with the padding after RefCounted::m_ref_count. // This creates a 4-byte padding hole after `m_end_offset` which is used to pack subclasses better. u32 m_start_offset { 0 }; - RefPtr m_source_code; + RefPtr m_source_code; u32 m_end_offset { 0 }; }; @@ -152,7 +152,7 @@ public: // 14.13 Labelled Statements, https://tc39.es/ecma262/#sec-labelled-statements class LabelledStatement : public Statement { public: - LabelledStatement(SourceRange source_range, DeprecatedFlyString label, NonnullRefPtr labelled_item) + LabelledStatement(SourceRange source_range, DeprecatedFlyString label, NonnullRefPtr labelled_item) : Statement(source_range) , m_label(move(label)) , m_labelled_item(move(labelled_item)) @@ -166,14 +166,13 @@ public: DeprecatedFlyString const& label() const { return m_label; } DeprecatedFlyString& label() { return m_label; } - NonnullRefPtr const& labelled_item() const { return m_labelled_item; } - NonnullRefPtr& labelled_item() { return m_labelled_item; } + NonnullRefPtr const& labelled_item() const { return m_labelled_item; } private: virtual bool is_labelled_statement() const final { return true; } DeprecatedFlyString m_label; - NonnullRefPtr m_labelled_item; + NonnullRefPtr m_labelled_item; }; class LabelableStatement : public Statement { @@ -219,7 +218,7 @@ public: class ExpressionStatement final : public Statement { public: - ExpressionStatement(SourceRange source_range, NonnullRefPtr expression) + ExpressionStatement(SourceRange source_range, NonnullRefPtr expression) : Statement(source_range) , m_expression(move(expression)) { @@ -234,7 +233,7 @@ public: private: virtual bool is_expression_statement() const override { return true; } - NonnullRefPtr m_expression; + NonnullRefPtr m_expression; }; template @@ -275,7 +274,7 @@ public: m_children.append(move(child)); return static_cast(m_children.last()); } - void append(NonnullRefPtr child) + void append(NonnullRefPtr child) { m_children.append(move(child)); } @@ -288,15 +287,15 @@ public: m_functions_hoistable_with_annexB_extension.shrink_to_fit(); } - NonnullRefPtrVector const& children() const { return m_children; } + NonnullRefPtrVector const& children() const { return m_children; } virtual void dump(int indent) const override; virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; Completion evaluate_statements(Interpreter&) const; - void add_var_scoped_declaration(NonnullRefPtr variables); - void add_lexical_declaration(NonnullRefPtr variables); - void add_hoisted_function(NonnullRefPtr declaration); + void add_var_scoped_declaration(NonnullRefPtr variables); + void add_lexical_declaration(NonnullRefPtr variables); + void add_hoisted_function(NonnullRefPtr declaration); [[nodiscard]] bool has_lexical_declarations() const { return !m_lexical_declarations.is_empty(); } [[nodiscard]] bool has_var_declarations() const { return !m_var_declarations.is_empty(); } @@ -325,11 +324,11 @@ protected: private: virtual bool is_scope_node() const final { return true; } - NonnullRefPtrVector m_children; - NonnullRefPtrVector m_lexical_declarations; - NonnullRefPtrVector m_var_declarations; + NonnullRefPtrVector m_children; + NonnullRefPtrVector m_lexical_declarations; + NonnullRefPtrVector m_var_declarations; - NonnullRefPtrVector m_functions_hoistable_with_annexB_extension; + NonnullRefPtrVector m_functions_hoistable_with_annexB_extension; }; // ImportEntry Record, https://tc39.es/ecma262/#table-importentry-record-fields @@ -375,7 +374,6 @@ public: bool has_bound_name(DeprecatedFlyString const& name) const; Vector const& entries() const { return m_entries; } ModuleRequest const& module_request() const { return m_module_request; } - ModuleRequest& module_request() { return m_module_request; } private: ModuleRequest m_module_request; @@ -453,7 +451,7 @@ class ExportStatement final : public Statement { public: static DeprecatedFlyString local_name_for_default; - ExportStatement(SourceRange source_range, RefPtr statement, Vector entries, bool is_default_export, ModuleRequest module_request) + ExportStatement(SourceRange source_range, RefPtr statement, Vector entries, bool is_default_export, ModuleRequest module_request) : Statement(source_range) , m_statement(move(statement)) , m_entries(move(entries)) @@ -483,14 +481,14 @@ public: return *m_statement; } - ModuleRequest& module_request() + ModuleRequest const& module_request() const { VERIFY(!m_module_request.module_specifier.is_null()); return m_module_request; } private: - RefPtr m_statement; + RefPtr m_statement; Vector m_entries; bool m_is_default_export { false }; ModuleRequest m_module_request; @@ -516,23 +514,23 @@ public: Type type() const { return m_type; } - void append_import(NonnullRefPtr import_statement) + void append_import(NonnullRefPtr import_statement) { m_imports.append(import_statement); append(import_statement); } - void append_export(NonnullRefPtr export_statement) + void append_export(NonnullRefPtr export_statement) { m_exports.append(export_statement); append(export_statement); } - NonnullRefPtrVector const& imports() const { return m_imports; } - NonnullRefPtrVector const& exports() const { return m_exports; } + NonnullRefPtrVector const& imports() const { return m_imports; } + NonnullRefPtrVector const& exports() const { return m_exports; } - NonnullRefPtrVector& imports() { return m_imports; } - NonnullRefPtrVector& exports() { return m_exports; } + NonnullRefPtrVector& imports() { return m_imports; } + NonnullRefPtrVector& exports() { return m_exports; } bool has_top_level_await() const { return m_has_top_level_await; } void set_has_top_level_await() { m_has_top_level_await = true; } @@ -545,8 +543,8 @@ private: bool m_is_strict_mode { false }; Type m_type { Type::Script }; - NonnullRefPtrVector m_imports; - NonnullRefPtrVector m_exports; + NonnullRefPtrVector m_imports; + NonnullRefPtrVector m_exports; bool m_has_top_level_await { false }; }; @@ -618,9 +616,9 @@ struct BindingPattern : RefCounted { // This covers both BindingProperty and BindingElement, hence the more generic name struct BindingEntry { // If this entry represents a BindingElement, then name will be Empty - Variant, NonnullRefPtr, Empty> name {}; - Variant, NonnullRefPtr, NonnullRefPtr, Empty> alias {}; - RefPtr initializer {}; + Variant, NonnullRefPtr, Empty> name {}; + Variant, NonnullRefPtr, NonnullRefPtr, Empty> alias {}; + RefPtr initializer {}; bool is_rest { false }; bool is_elision() const { return name.has() && alias.has(); } @@ -642,8 +640,8 @@ struct BindingPattern : RefCounted { }; struct FunctionParameter { - Variant> binding; - RefPtr default_value; + Variant> binding; + RefPtr default_value; bool is_rest { false }; }; @@ -661,7 +659,7 @@ public: FunctionKind kind() const { return m_kind; } protected: - FunctionNode(DeprecatedFlyString name, DeprecatedString source_text, NonnullRefPtr body, Vector parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function) + FunctionNode(DeprecatedFlyString name, DeprecatedString source_text, NonnullRefPtr body, Vector parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function) : m_name(move(name)) , m_source_text(move(source_text)) , m_body(move(body)) @@ -682,7 +680,7 @@ protected: private: DeprecatedFlyString m_name; DeprecatedString m_source_text; - NonnullRefPtr m_body; + NonnullRefPtr m_body; Vector const m_parameters; const i32 m_function_length; FunctionKind m_kind; @@ -698,7 +696,7 @@ class FunctionDeclaration final public: static bool must_have_name() { return true; } - FunctionDeclaration(SourceRange source_range, DeprecatedFlyString const& name, DeprecatedString source_text, NonnullRefPtr body, Vector parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval) + FunctionDeclaration(SourceRange source_range, DeprecatedFlyString const& name, DeprecatedString source_text, NonnullRefPtr body, Vector parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval) : Declaration(source_range) , FunctionNode(name, move(source_text), move(body), move(parameters), function_length, kind, is_strict_mode, might_need_arguments_object, contains_direct_call_to_eval, false) { @@ -724,7 +722,7 @@ class FunctionExpression final public: static bool must_have_name() { return false; } - FunctionExpression(SourceRange source_range, DeprecatedFlyString const& name, DeprecatedString source_text, NonnullRefPtr body, Vector parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function = false) + FunctionExpression(SourceRange source_range, DeprecatedFlyString const& name, DeprecatedString source_text, NonnullRefPtr body, Vector parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function = false) : Expression(source_range) , FunctionNode(name, move(source_text), move(body), move(parameters), function_length, kind, is_strict_mode, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function) { @@ -755,7 +753,7 @@ public: class YieldExpression final : public Expression { public: - explicit YieldExpression(SourceRange source_range, RefPtr argument, bool is_yield_from) + explicit YieldExpression(SourceRange source_range, RefPtr argument, bool is_yield_from) : Expression(source_range) , m_argument(move(argument)) , m_is_yield_from(is_yield_from) @@ -770,13 +768,13 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - RefPtr m_argument; + RefPtr m_argument; bool m_is_yield_from { false }; }; class AwaitExpression final : public Expression { public: - explicit AwaitExpression(SourceRange source_range, NonnullRefPtr argument) + explicit AwaitExpression(SourceRange source_range, NonnullRefPtr argument) : Expression(source_range) , m_argument(move(argument)) { @@ -787,12 +785,12 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - NonnullRefPtr m_argument; + NonnullRefPtr m_argument; }; class ReturnStatement final : public Statement { public: - explicit ReturnStatement(SourceRange source_range, RefPtr argument) + explicit ReturnStatement(SourceRange source_range, RefPtr argument) : Statement(source_range) , m_argument(move(argument)) { @@ -805,12 +803,12 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - RefPtr m_argument; + RefPtr m_argument; }; class IfStatement final : public Statement { public: - IfStatement(SourceRange source_range, NonnullRefPtr predicate, NonnullRefPtr consequent, RefPtr alternate) + IfStatement(SourceRange source_range, NonnullRefPtr predicate, NonnullRefPtr consequent, RefPtr alternate) : Statement(source_range) , m_predicate(move(predicate)) , m_consequent(move(consequent)) @@ -827,14 +825,14 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - NonnullRefPtr m_predicate; - NonnullRefPtr m_consequent; - RefPtr m_alternate; + NonnullRefPtr m_predicate; + NonnullRefPtr m_consequent; + RefPtr m_alternate; }; class WhileStatement final : public IterationStatement { public: - WhileStatement(SourceRange source_range, NonnullRefPtr test, NonnullRefPtr body) + WhileStatement(SourceRange source_range, NonnullRefPtr test, NonnullRefPtr body) : IterationStatement(source_range) , m_test(move(test)) , m_body(move(body)) @@ -851,13 +849,13 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_labelled_evaluation(Bytecode::Generator&, Vector const&) const override; private: - NonnullRefPtr m_test; - NonnullRefPtr m_body; + NonnullRefPtr m_test; + NonnullRefPtr m_body; }; class DoWhileStatement final : public IterationStatement { public: - DoWhileStatement(SourceRange source_range, NonnullRefPtr test, NonnullRefPtr body) + DoWhileStatement(SourceRange source_range, NonnullRefPtr test, NonnullRefPtr body) : IterationStatement(source_range) , m_test(move(test)) , m_body(move(body)) @@ -874,13 +872,13 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_labelled_evaluation(Bytecode::Generator&, Vector const&) const override; private: - NonnullRefPtr m_test; - NonnullRefPtr m_body; + NonnullRefPtr m_test; + NonnullRefPtr m_body; }; class WithStatement final : public Statement { public: - WithStatement(SourceRange source_range, NonnullRefPtr object, NonnullRefPtr body) + WithStatement(SourceRange source_range, NonnullRefPtr object, NonnullRefPtr body) : Statement(source_range) , m_object(move(object)) , m_body(move(body)) @@ -895,13 +893,13 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - NonnullRefPtr m_object; - NonnullRefPtr m_body; + NonnullRefPtr m_object; + NonnullRefPtr m_body; }; class ForStatement final : public IterationStatement { public: - ForStatement(SourceRange source_range, RefPtr init, RefPtr test, RefPtr update, NonnullRefPtr body) + ForStatement(SourceRange source_range, RefPtr init, RefPtr test, RefPtr update, NonnullRefPtr body) : IterationStatement(source_range) , m_init(move(init)) , m_test(move(test)) @@ -924,15 +922,15 @@ public: private: Completion for_body_evaluation(Interpreter&, Vector const&, size_t per_iteration_bindings_size) const; - RefPtr m_init; - RefPtr m_test; - RefPtr m_update; - NonnullRefPtr m_body; + RefPtr m_init; + RefPtr m_test; + RefPtr m_update; + NonnullRefPtr m_body; }; class ForInStatement final : public IterationStatement { public: - ForInStatement(SourceRange source_range, Variant, NonnullRefPtr> lhs, NonnullRefPtr rhs, NonnullRefPtr body) + ForInStatement(SourceRange source_range, Variant, NonnullRefPtr> lhs, NonnullRefPtr rhs, NonnullRefPtr body) : IterationStatement(source_range) , m_lhs(move(lhs)) , m_rhs(move(rhs)) @@ -951,14 +949,14 @@ public: virtual void dump(int indent) const override; private: - Variant, NonnullRefPtr> m_lhs; - NonnullRefPtr m_rhs; - NonnullRefPtr m_body; + Variant, NonnullRefPtr> m_lhs; + NonnullRefPtr m_rhs; + NonnullRefPtr m_body; }; class ForOfStatement final : public IterationStatement { public: - ForOfStatement(SourceRange source_range, Variant, NonnullRefPtr> lhs, NonnullRefPtr rhs, NonnullRefPtr body) + ForOfStatement(SourceRange source_range, Variant, NonnullRefPtr> lhs, NonnullRefPtr rhs, NonnullRefPtr body) : IterationStatement(source_range) , m_lhs(move(lhs)) , m_rhs(move(rhs)) @@ -977,14 +975,14 @@ public: virtual void dump(int indent) const override; private: - Variant, NonnullRefPtr> m_lhs; - NonnullRefPtr m_rhs; - NonnullRefPtr m_body; + Variant, NonnullRefPtr> m_lhs; + NonnullRefPtr m_rhs; + NonnullRefPtr m_body; }; class ForAwaitOfStatement final : public IterationStatement { public: - ForAwaitOfStatement(SourceRange source_range, Variant, NonnullRefPtr> lhs, NonnullRefPtr rhs, NonnullRefPtr body) + ForAwaitOfStatement(SourceRange source_range, Variant, NonnullRefPtr> lhs, NonnullRefPtr rhs, NonnullRefPtr body) : IterationStatement(source_range) , m_lhs(move(lhs)) , m_rhs(move(rhs)) @@ -997,9 +995,9 @@ public: virtual void dump(int indent) const override; private: - Variant, NonnullRefPtr> m_lhs; - NonnullRefPtr m_rhs; - NonnullRefPtr m_body; + Variant, NonnullRefPtr> m_lhs; + NonnullRefPtr m_rhs; + NonnullRefPtr m_body; }; enum class BinaryOp { @@ -1029,7 +1027,7 @@ enum class BinaryOp { class BinaryExpression final : public Expression { public: - BinaryExpression(SourceRange source_range, BinaryOp op, NonnullRefPtr lhs, NonnullRefPtr rhs) + BinaryExpression(SourceRange source_range, BinaryOp op, NonnullRefPtr lhs, NonnullRefPtr rhs) : Expression(source_range) , m_op(op) , m_lhs(move(lhs)) @@ -1043,8 +1041,8 @@ public: private: BinaryOp m_op; - NonnullRefPtr m_lhs; - NonnullRefPtr m_rhs; + NonnullRefPtr m_lhs; + NonnullRefPtr m_rhs; }; enum class LogicalOp { @@ -1055,7 +1053,7 @@ enum class LogicalOp { class LogicalExpression final : public Expression { public: - LogicalExpression(SourceRange source_range, LogicalOp op, NonnullRefPtr lhs, NonnullRefPtr rhs) + LogicalExpression(SourceRange source_range, LogicalOp op, NonnullRefPtr lhs, NonnullRefPtr rhs) : Expression(source_range) , m_op(op) , m_lhs(move(lhs)) @@ -1069,8 +1067,8 @@ public: private: LogicalOp m_op; - NonnullRefPtr m_lhs; - NonnullRefPtr m_rhs; + NonnullRefPtr m_lhs; + NonnullRefPtr m_rhs; }; enum class UnaryOp { @@ -1085,7 +1083,7 @@ enum class UnaryOp { class UnaryExpression final : public Expression { public: - UnaryExpression(SourceRange source_range, UnaryOp op, NonnullRefPtr lhs) + UnaryExpression(SourceRange source_range, UnaryOp op, NonnullRefPtr lhs) : Expression(source_range) , m_op(op) , m_lhs(move(lhs)) @@ -1098,12 +1096,12 @@ public: private: UnaryOp m_op; - NonnullRefPtr m_lhs; + NonnullRefPtr m_lhs; }; class SequenceExpression final : public Expression { public: - SequenceExpression(SourceRange source_range, NonnullRefPtrVector expressions) + SequenceExpression(SourceRange source_range, NonnullRefPtrVector expressions) : Expression(source_range) , m_expressions(move(expressions)) { @@ -1115,7 +1113,7 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - NonnullRefPtrVector m_expressions; + NonnullRefPtrVector m_expressions; }; class Literal : public Expression { @@ -1314,7 +1312,7 @@ public: Setter, }; - ClassMethod(SourceRange source_range, NonnullRefPtr key, NonnullRefPtr function, Kind kind, bool is_static) + ClassMethod(SourceRange source_range, NonnullRefPtr key, NonnullRefPtr function, Kind kind, bool is_static) : ClassElement(source_range, is_static) , m_key(move(key)) , m_function(move(function)) @@ -1332,14 +1330,14 @@ public: private: virtual bool is_class_method() const override { return true; } - NonnullRefPtr m_key; - NonnullRefPtr m_function; + NonnullRefPtr m_key; + NonnullRefPtr m_function; Kind m_kind; }; class ClassField final : public ClassElement { public: - ClassField(SourceRange source_range, NonnullRefPtr key, RefPtr init, bool contains_direct_call_to_eval, bool is_static) + ClassField(SourceRange source_range, NonnullRefPtr key, RefPtr init, bool contains_direct_call_to_eval, bool is_static) : ClassElement(source_range, is_static) , m_key(move(key)) , m_initializer(move(init)) @@ -1348,8 +1346,8 @@ public: } Expression const& key() const { return *m_key; } - RefPtr const& initializer() const { return m_initializer; } - RefPtr& initializer() { return m_initializer; } + RefPtr const& initializer() const { return m_initializer; } + RefPtr& initializer() { return m_initializer; } virtual ElementKind class_element_kind() const override { return ElementKind::Field; } @@ -1358,8 +1356,8 @@ public: virtual Optional private_bound_identifier() const override; private: - NonnullRefPtr m_key; - RefPtr m_initializer; + NonnullRefPtr m_key; + RefPtr m_initializer; bool m_contains_direct_call_to_eval { false }; }; @@ -1397,7 +1395,7 @@ public: class ClassExpression final : public Expression { public: - ClassExpression(SourceRange source_range, DeprecatedString name, DeprecatedString source_text, RefPtr constructor, RefPtr super_class, NonnullRefPtrVector elements) + ClassExpression(SourceRange source_range, DeprecatedString name, DeprecatedString source_text, RefPtr constructor, RefPtr super_class, NonnullRefPtrVector elements) : Expression(source_range) , m_name(move(name)) , m_source_text(move(source_text)) @@ -1409,7 +1407,7 @@ public: StringView name() const { return m_name; } DeprecatedString const& source_text() const { return m_source_text; } - RefPtr constructor() const { return m_constructor; } + RefPtr constructor() const { return m_constructor; } virtual Completion execute(Interpreter&) const override; virtual void dump(int indent) const override; @@ -1424,14 +1422,14 @@ private: DeprecatedString m_name; DeprecatedString m_source_text; - RefPtr m_constructor; - RefPtr m_super_class; - NonnullRefPtrVector m_elements; + RefPtr m_constructor; + RefPtr m_super_class; + NonnullRefPtrVector m_elements; }; class ClassDeclaration final : public Declaration { public: - ClassDeclaration(SourceRange source_range, NonnullRefPtr class_expression) + ClassDeclaration(SourceRange source_range, NonnullRefPtr class_expression) : Declaration(source_range) , m_class_expression(move(class_expression)) { @@ -1452,12 +1450,12 @@ private: friend ExportStatement; - NonnullRefPtr m_class_expression; + NonnullRefPtr m_class_expression; }; class SpreadExpression final : public Expression { public: - explicit SpreadExpression(SourceRange source_range, NonnullRefPtr target) + explicit SpreadExpression(SourceRange source_range, NonnullRefPtr target) : Expression(source_range) , m_target(move(target)) { @@ -1468,7 +1466,7 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - NonnullRefPtr m_target; + NonnullRefPtr m_target; }; class ThisExpression final : public Expression { @@ -1483,7 +1481,7 @@ public: }; struct CallExpressionArgument { - NonnullRefPtr value; + NonnullRefPtr value; bool is_spread; }; @@ -1493,7 +1491,7 @@ class CallExpression : public ASTNodeWithTailArray create(SourceRange, NonnullRefPtr callee, ReadonlySpan arguments); + static NonnullRefPtr create(SourceRange, NonnullRefPtr callee, ReadonlySpan arguments); virtual Completion execute(Interpreter&) const override; virtual void dump(int indent) const override; @@ -1504,7 +1502,7 @@ public: ReadonlySpan arguments() const { return tail_span(); } protected: - CallExpression(SourceRange source_range, NonnullRefPtr callee, ReadonlySpan arguments) + CallExpression(SourceRange source_range, NonnullRefPtr callee, ReadonlySpan arguments) : ASTNodeWithTailArray(move(source_range), arguments) , m_callee(move(callee)) { @@ -1523,21 +1521,21 @@ protected: Completion throw_type_error_for_callee(Interpreter&, Value callee_value, StringView call_type) const; Optional expression_string() const; - NonnullRefPtr m_callee; + NonnullRefPtr m_callee; }; class NewExpression final : public CallExpression { friend class ASTNodeWithTailArray; public: - static NonnullRefPtr create(SourceRange, NonnullRefPtr callee, ReadonlySpan arguments); + static NonnullRefPtr create(SourceRange, NonnullRefPtr callee, ReadonlySpan arguments); virtual Completion execute(Interpreter&) const override; virtual bool is_new_expression() const override { return true; } private: - NewExpression(SourceRange source_range, NonnullRefPtr callee, ReadonlySpan arguments) + NewExpression(SourceRange source_range, NonnullRefPtr callee, ReadonlySpan arguments) : CallExpression(move(source_range), move(callee), arguments) { } @@ -1599,7 +1597,7 @@ enum class AssignmentOp { class AssignmentExpression final : public Expression { public: - AssignmentExpression(SourceRange source_range, AssignmentOp op, NonnullRefPtr lhs, NonnullRefPtr rhs) + AssignmentExpression(SourceRange source_range, AssignmentOp op, NonnullRefPtr lhs, NonnullRefPtr rhs) : Expression(source_range) , m_op(op) , m_lhs(move(lhs)) @@ -1607,7 +1605,7 @@ public: { } - AssignmentExpression(SourceRange source_range, AssignmentOp op, NonnullRefPtr lhs, NonnullRefPtr rhs) + AssignmentExpression(SourceRange source_range, AssignmentOp op, NonnullRefPtr lhs, NonnullRefPtr rhs) : Expression(source_range) , m_op(op) , m_lhs(move(lhs)) @@ -1621,8 +1619,8 @@ public: private: AssignmentOp m_op; - Variant, NonnullRefPtr> m_lhs; - NonnullRefPtr m_rhs; + Variant, NonnullRefPtr> m_lhs; + NonnullRefPtr m_rhs; }; enum class UpdateOp { @@ -1632,7 +1630,7 @@ enum class UpdateOp { class UpdateExpression final : public Expression { public: - UpdateExpression(SourceRange source_range, UpdateOp op, NonnullRefPtr argument, bool prefixed = false) + UpdateExpression(SourceRange source_range, UpdateOp op, NonnullRefPtr argument, bool prefixed = false) : Expression(source_range) , m_op(op) , m_argument(move(argument)) @@ -1648,7 +1646,7 @@ private: virtual bool is_update_expression() const override { return true; } UpdateOp m_op; - NonnullRefPtr m_argument; + NonnullRefPtr m_argument; bool m_prefixed; }; @@ -1660,20 +1658,20 @@ enum class DeclarationKind { class VariableDeclarator final : public ASTNode { public: - VariableDeclarator(SourceRange source_range, NonnullRefPtr id) + VariableDeclarator(SourceRange source_range, NonnullRefPtr id) : ASTNode(source_range) , m_target(move(id)) { } - VariableDeclarator(SourceRange source_range, NonnullRefPtr target, RefPtr init) + VariableDeclarator(SourceRange source_range, NonnullRefPtr target, RefPtr init) : ASTNode(source_range) , m_target(move(target)) , m_init(move(init)) { } - VariableDeclarator(SourceRange source_range, Variant, NonnullRefPtr> target, RefPtr init) + VariableDeclarator(SourceRange source_range, Variant, NonnullRefPtr> target, RefPtr init) : ASTNode(source_range) , m_target(move(target)) , m_init(move(init)) @@ -1687,13 +1685,13 @@ public: virtual void dump(int indent) const override; private: - Variant, NonnullRefPtr> m_target; - RefPtr m_init; + Variant, NonnullRefPtr> m_target; + RefPtr m_init; }; class VariableDeclaration final : public Declaration { public: - VariableDeclaration(SourceRange source_range, DeclarationKind declaration_kind, NonnullRefPtrVector declarations) + VariableDeclaration(SourceRange source_range, DeclarationKind declaration_kind, NonnullRefPtrVector declarations) : Declaration(source_range) , m_declaration_kind(declaration_kind) , m_declarations(move(declarations)) @@ -1706,7 +1704,7 @@ public: virtual void dump(int indent) const override; virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; - NonnullRefPtrVector const& declarations() const { return m_declarations; } + NonnullRefPtrVector const& declarations() const { return m_declarations; } virtual ThrowCompletionOr for_each_bound_name(ThrowCompletionOrVoidCallback&& callback) const override; @@ -1718,12 +1716,12 @@ private: virtual bool is_variable_declaration() const override { return true; } DeclarationKind m_declaration_kind; - NonnullRefPtrVector m_declarations; + NonnullRefPtrVector m_declarations; }; class UsingDeclaration final : public Declaration { public: - UsingDeclaration(SourceRange source_range, NonnullRefPtrVector declarations) + UsingDeclaration(SourceRange source_range, NonnullRefPtrVector declarations) : Declaration(move(source_range)) , m_declarations(move(declarations)) { @@ -1738,10 +1736,10 @@ public: virtual bool is_lexical_declaration() const override { return true; } - NonnullRefPtrVector const& declarations() const { return m_declarations; } + NonnullRefPtrVector const& declarations() const { return m_declarations; } private: - NonnullRefPtrVector m_declarations; + NonnullRefPtrVector m_declarations; }; class ObjectProperty final : public ASTNode { @@ -1754,7 +1752,7 @@ public: ProtoSetter, }; - ObjectProperty(SourceRange source_range, NonnullRefPtr key, RefPtr value, Type property_type, bool is_method) + ObjectProperty(SourceRange source_range, NonnullRefPtr key, RefPtr value, Type property_type, bool is_method) : ASTNode(source_range) , m_property_type(property_type) , m_is_method(is_method) @@ -1779,8 +1777,8 @@ public: private: Type m_property_type; bool m_is_method { false }; - NonnullRefPtr m_key; - RefPtr m_value; + NonnullRefPtr m_key; + RefPtr m_value; }; class ObjectExpression final : public Expression { @@ -1803,13 +1801,13 @@ private: class ArrayExpression final : public Expression { public: - ArrayExpression(SourceRange source_range, Vector> elements) + ArrayExpression(SourceRange source_range, Vector> elements) : Expression(source_range) , m_elements(move(elements)) { } - Vector> const& elements() const { return m_elements; } + Vector> const& elements() const { return m_elements; } virtual Completion execute(Interpreter&) const override; virtual void dump(int indent) const override; @@ -1818,18 +1816,18 @@ public: private: virtual bool is_array_expression() const override { return true; } - Vector> m_elements; + Vector> m_elements; }; class TemplateLiteral final : public Expression { public: - TemplateLiteral(SourceRange source_range, NonnullRefPtrVector expressions) + TemplateLiteral(SourceRange source_range, NonnullRefPtrVector expressions) : Expression(source_range) , m_expressions(move(expressions)) { } - TemplateLiteral(SourceRange source_range, NonnullRefPtrVector expressions, NonnullRefPtrVector raw_strings) + TemplateLiteral(SourceRange source_range, NonnullRefPtrVector expressions, NonnullRefPtrVector raw_strings) : Expression(source_range) , m_expressions(move(expressions)) , m_raw_strings(move(raw_strings)) @@ -1840,17 +1838,17 @@ public: virtual void dump(int indent) const override; virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; - NonnullRefPtrVector const& expressions() const { return m_expressions; } - NonnullRefPtrVector const& raw_strings() const { return m_raw_strings; } + NonnullRefPtrVector const& expressions() const { return m_expressions; } + NonnullRefPtrVector const& raw_strings() const { return m_raw_strings; } private: - NonnullRefPtrVector const m_expressions; - NonnullRefPtrVector const m_raw_strings; + NonnullRefPtrVector const m_expressions; + NonnullRefPtrVector const m_raw_strings; }; class TaggedTemplateLiteral final : public Expression { public: - TaggedTemplateLiteral(SourceRange source_range, NonnullRefPtr tag, NonnullRefPtr template_literal) + TaggedTemplateLiteral(SourceRange source_range, NonnullRefPtr tag, NonnullRefPtr template_literal) : Expression(source_range) , m_tag(move(tag)) , m_template_literal(move(template_literal)) @@ -1864,14 +1862,14 @@ public: ThrowCompletionOr get_template_object(Interpreter&) const; private: - NonnullRefPtr const m_tag; - NonnullRefPtr const m_template_literal; + NonnullRefPtr const m_tag; + NonnullRefPtr const m_template_literal; mutable HashMap> m_cached_values; }; class MemberExpression final : public Expression { public: - MemberExpression(SourceRange source_range, NonnullRefPtr object, NonnullRefPtr property, bool computed = false) + MemberExpression(SourceRange source_range, NonnullRefPtr object, NonnullRefPtr property, bool computed = false) : Expression(source_range) , m_computed(computed) , m_object(move(object)) @@ -1896,8 +1894,8 @@ private: virtual bool is_member_expression() const override { return true; } bool m_computed { false }; - NonnullRefPtr m_object; - NonnullRefPtr m_property; + NonnullRefPtr m_object; + NonnullRefPtr m_property; }; class OptionalChain final : public Expression { @@ -1912,21 +1910,21 @@ public: Mode mode; }; struct ComputedReference { - NonnullRefPtr expression; + NonnullRefPtr expression; Mode mode; }; struct MemberReference { - NonnullRefPtr identifier; + NonnullRefPtr identifier; Mode mode; }; struct PrivateMemberReference { - NonnullRefPtr private_identifier; + NonnullRefPtr private_identifier; Mode mode; }; using Reference = Variant; - OptionalChain(SourceRange source_range, NonnullRefPtr base, Vector references) + OptionalChain(SourceRange source_range, NonnullRefPtr base, Vector references) : Expression(source_range) , m_base(move(base)) , m_references(move(references)) @@ -1944,7 +1942,7 @@ private: }; ThrowCompletionOr to_reference_and_value(Interpreter&) const; - NonnullRefPtr m_base; + NonnullRefPtr m_base; Vector m_references; }; @@ -1971,7 +1969,7 @@ private: class ImportCall final : public Expression { public: - ImportCall(SourceRange source_range, NonnullRefPtr specifier, RefPtr options) + ImportCall(SourceRange source_range, NonnullRefPtr specifier, RefPtr options) : Expression(source_range) , m_specifier(move(specifier)) , m_options(move(options)) @@ -1984,13 +1982,13 @@ public: private: virtual bool is_import_call() const override { return true; } - NonnullRefPtr m_specifier; - RefPtr m_options; + NonnullRefPtr m_specifier; + RefPtr m_options; }; class ConditionalExpression final : public Expression { public: - ConditionalExpression(SourceRange source_range, NonnullRefPtr test, NonnullRefPtr consequent, NonnullRefPtr alternate) + ConditionalExpression(SourceRange source_range, NonnullRefPtr test, NonnullRefPtr consequent, NonnullRefPtr alternate) : Expression(source_range) , m_test(move(test)) , m_consequent(move(consequent)) @@ -2003,21 +2001,21 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - NonnullRefPtr m_test; - NonnullRefPtr m_consequent; - NonnullRefPtr m_alternate; + NonnullRefPtr m_test; + NonnullRefPtr m_consequent; + NonnullRefPtr m_alternate; }; class CatchClause final : public ASTNode { public: - CatchClause(SourceRange source_range, DeprecatedFlyString parameter, NonnullRefPtr body) + CatchClause(SourceRange source_range, DeprecatedFlyString parameter, NonnullRefPtr body) : ASTNode(source_range) , m_parameter(move(parameter)) , m_body(move(body)) { } - CatchClause(SourceRange source_range, NonnullRefPtr parameter, NonnullRefPtr body) + CatchClause(SourceRange source_range, NonnullRefPtr parameter, NonnullRefPtr body) : ASTNode(source_range) , m_parameter(move(parameter)) , m_body(move(body)) @@ -2031,13 +2029,13 @@ public: virtual Completion execute(Interpreter&) const override; private: - Variant> m_parameter; - NonnullRefPtr m_body; + Variant> m_parameter; + NonnullRefPtr m_body; }; class TryStatement final : public Statement { public: - TryStatement(SourceRange source_range, NonnullRefPtr block, RefPtr handler, RefPtr finalizer) + TryStatement(SourceRange source_range, NonnullRefPtr block, RefPtr handler, RefPtr finalizer) : Statement(source_range) , m_block(move(block)) , m_handler(move(handler)) @@ -2054,14 +2052,14 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - NonnullRefPtr m_block; - RefPtr m_handler; - RefPtr m_finalizer; + NonnullRefPtr m_block; + RefPtr m_handler; + RefPtr m_finalizer; }; class ThrowStatement final : public Statement { public: - explicit ThrowStatement(SourceRange source_range, NonnullRefPtr argument) + explicit ThrowStatement(SourceRange source_range, NonnullRefPtr argument) : Statement(source_range) , m_argument(move(argument)) { @@ -2074,12 +2072,12 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; private: - NonnullRefPtr m_argument; + NonnullRefPtr m_argument; }; class SwitchCase final : public ScopeNode { public: - SwitchCase(SourceRange source_range, RefPtr test) + SwitchCase(SourceRange source_range, RefPtr test) : ScopeNode(source_range) , m_test(move(test)) { @@ -2091,12 +2089,12 @@ public: virtual Completion execute(Interpreter&) const override; private: - RefPtr m_test; + RefPtr m_test; }; class SwitchStatement final : public ScopeNode { public: - SwitchStatement(SourceRange source_range, NonnullRefPtr discriminant) + SwitchStatement(SourceRange source_range, NonnullRefPtr discriminant) : ScopeNode(source_range) , m_discriminant(move(discriminant)) { @@ -2108,11 +2106,11 @@ public: virtual Bytecode::CodeGenerationErrorOr generate_labelled_evaluation(Bytecode::Generator&, Vector const&) const; Completion execute_impl(Interpreter&) const; - void add_case(NonnullRefPtr switch_case) { m_cases.append(move(switch_case)); } + void add_case(NonnullRefPtr switch_case) { m_cases.append(move(switch_case)); } private: - NonnullRefPtr m_discriminant; - NonnullRefPtrVector m_cases; + NonnullRefPtr m_discriminant; + NonnullRefPtrVector m_cases; }; class BreakStatement final : public Statement { -- cgit v1.2.3