diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 0b95c3476c..7dce1fca03 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -1310,13 +1310,6 @@ void FunctionNode::dump(int indent, String const& class_name) const parameter.default_value->dump(indent + 3); } } - if (!m_variables.is_empty()) { - print_indent(indent + 1); - outln("(Variables)"); - - for (auto& variable : m_variables) - variable.dump(indent + 2); - } print_indent(indent + 1); outln("(Body)"); body().dump(indent + 2); diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h index e229900e03..e71a91b638 100644 --- a/Userland/Libraries/LibJS/AST.h +++ b/Userland/Libraries/LibJS/AST.h @@ -257,11 +257,10 @@ public: FunctionKind kind() const { return m_kind; } protected: - FunctionNode(FlyString name, NonnullRefPtr body, Vector parameters, i32 function_length, NonnullRefPtrVector variables, FunctionKind kind, bool is_strict_mode, bool is_arrow_function) + FunctionNode(FlyString name, NonnullRefPtr body, Vector parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool is_arrow_function) : m_name(move(name)) , m_body(move(body)) , m_parameters(move(parameters)) - , m_variables(move(variables)) , m_function_length(function_length) , m_kind(kind) , m_is_strict_mode(is_strict_mode) @@ -271,8 +270,6 @@ protected: void dump(int indent, String const& class_name) const; - NonnullRefPtrVector const& variables() const { return m_variables; } - protected: void set_name(FlyString name) { @@ -284,7 +281,6 @@ private: FlyString m_name; NonnullRefPtr m_body; Vector const m_parameters; - NonnullRefPtrVector m_variables; const i32 m_function_length; FunctionKind m_kind; bool m_is_strict_mode; @@ -297,9 +293,9 @@ class FunctionDeclaration final public: static bool must_have_name() { return true; } - FunctionDeclaration(SourceRange source_range, FlyString const& name, NonnullRefPtr body, Vector parameters, i32 function_length, NonnullRefPtrVector variables, FunctionKind kind, bool is_strict_mode = false) + FunctionDeclaration(SourceRange source_range, FlyString const& name, NonnullRefPtr body, Vector parameters, i32 function_length, FunctionKind kind, bool is_strict_mode = false) : Declaration(source_range) - , FunctionNode(name, move(body), move(parameters), function_length, move(variables), kind, is_strict_mode, false) + , FunctionNode(name, move(body), move(parameters), function_length, kind, is_strict_mode, false) { } @@ -314,9 +310,9 @@ class FunctionExpression final public: static bool must_have_name() { return false; } - FunctionExpression(SourceRange source_range, FlyString const& name, NonnullRefPtr body, Vector parameters, i32 function_length, NonnullRefPtrVector variables, FunctionKind kind, bool is_strict_mode, bool is_arrow_function = false) + FunctionExpression(SourceRange source_range, FlyString const& name, NonnullRefPtr body, Vector parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool is_arrow_function = false) : Expression(source_range) - , FunctionNode(name, move(body), move(parameters), function_length, move(variables), kind, is_strict_mode, is_arrow_function) + , FunctionNode(name, move(body), move(parameters), function_length, kind, is_strict_mode, is_arrow_function) { } diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 24c8d30c5d..dbc7f8445e 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -348,7 +348,6 @@ NonnullRefPtr Parser::parse_statement() RefPtr Parser::try_parse_arrow_function_expression(bool expect_parens) { save_state(); - m_state.var_scopes.append(NonnullRefPtrVector()); auto rule_start = push_start(); ArmedScopeGuard state_rollback_guard = [&] { @@ -426,7 +425,7 @@ RefPtr Parser::try_parse_arrow_function_expression(bool expe auto body = function_body_result.release_nonnull(); return create_ast_node( { m_state.current_token.filename(), rule_start.position(), position() }, "", move(body), - move(parameters), function_length, m_state.var_scopes.take_last(), FunctionKind::Regular, is_strict, true); + move(parameters), function_length, FunctionKind::Regular, is_strict, true); } return nullptr; @@ -623,11 +622,11 @@ NonnullRefPtr Parser::parse_class_expression(bool expect_class_ constructor = create_ast_node( { m_state.current_token.filename(), rule_start.position(), position() }, class_name, move(constructor_body), - Vector { FunctionNode::Parameter { FlyString { "args" }, nullptr, true } }, 0, NonnullRefPtrVector(), FunctionKind::Regular, true); + Vector { FunctionNode::Parameter { FlyString { "args" }, nullptr, true } }, 0, FunctionKind::Regular, true); } else { constructor = create_ast_node( { m_state.current_token.filename(), rule_start.position(), position() }, class_name, move(constructor_body), - Vector {}, 0, NonnullRefPtrVector(), FunctionKind::Regular, true); + Vector {}, 0, FunctionKind::Regular, true); } } @@ -1465,7 +1464,7 @@ NonnullRefPtr Parser::parse_function_node(u8 parse_options) body->add_functions(m_state.function_scopes.last()); return create_ast_node( { m_state.current_token.filename(), rule_start.position(), position() }, - name, move(body), move(parameters), function_length, NonnullRefPtrVector(), + name, move(body), move(parameters), function_length, is_generator ? FunctionKind::Generator : FunctionKind::Regular, is_strict); }