mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: Move is_arrow_function() from FunctionExpression to FunctionNode
This will make it easier to write bytecode generation for function expressions in just a moment.
This commit is contained in:
parent
17da54d49c
commit
749a3b9245
Notes:
sideshowbarker
2024-07-18 12:27:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/749a3b9245d
2 changed files with 7 additions and 6 deletions
|
@ -100,7 +100,7 @@ Value FunctionDeclaration::execute(Interpreter& interpreter, GlobalObject&) cons
|
|||
Value FunctionExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const
|
||||
{
|
||||
InterpreterNodeScope node_scope { interpreter, *this };
|
||||
return ScriptFunction::create(global_object, name(), body(), parameters(), function_length(), interpreter.current_scope(), is_generator(), is_strict_mode() || interpreter.vm().in_strict_mode(), m_is_arrow_function);
|
||||
return ScriptFunction::create(global_object, name(), body(), parameters(), function_length(), interpreter.current_scope(), is_generator(), is_strict_mode() || interpreter.vm().in_strict_mode(), is_arrow_function());
|
||||
}
|
||||
|
||||
Value ExpressionStatement::execute(Interpreter& interpreter, GlobalObject& global_object) const
|
||||
|
|
|
@ -227,10 +227,11 @@ public:
|
|||
Vector<Parameter> const& parameters() const { return m_parameters; };
|
||||
i32 function_length() const { return m_function_length; }
|
||||
bool is_strict_mode() const { return m_is_strict_mode; }
|
||||
bool is_arrow_function() const { return m_is_arrow_function; }
|
||||
bool is_generator() const { return m_is_generator; }
|
||||
|
||||
protected:
|
||||
FunctionNode(FlyString const& name, NonnullRefPtr<Statement> body, Vector<Parameter> parameters, i32 function_length, NonnullRefPtrVector<VariableDeclaration> variables, bool is_generator, bool is_strict_mode)
|
||||
FunctionNode(FlyString const& name, NonnullRefPtr<Statement> body, Vector<Parameter> parameters, i32 function_length, NonnullRefPtrVector<VariableDeclaration> variables, bool is_generator, bool is_strict_mode, bool is_arrow_function)
|
||||
: m_name(name)
|
||||
, m_body(move(body))
|
||||
, m_parameters(move(parameters))
|
||||
|
@ -238,6 +239,7 @@ protected:
|
|||
, m_function_length(function_length)
|
||||
, m_is_generator(is_generator)
|
||||
, m_is_strict_mode(is_strict_mode)
|
||||
, m_is_arrow_function(is_arrow_function)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -260,6 +262,7 @@ private:
|
|||
const i32 m_function_length;
|
||||
bool m_is_generator;
|
||||
bool m_is_strict_mode;
|
||||
bool m_is_arrow_function { false };
|
||||
};
|
||||
|
||||
class FunctionDeclaration final
|
||||
|
@ -270,7 +273,7 @@ public:
|
|||
|
||||
FunctionDeclaration(SourceRange source_range, FlyString const& name, NonnullRefPtr<Statement> body, Vector<Parameter> parameters, i32 function_length, NonnullRefPtrVector<VariableDeclaration> variables, bool is_generator, bool is_strict_mode = false)
|
||||
: Declaration(move(source_range))
|
||||
, FunctionNode(name, move(body), move(parameters), function_length, move(variables), is_generator, is_strict_mode)
|
||||
, FunctionNode(name, move(body), move(parameters), function_length, move(variables), is_generator, is_strict_mode, false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -287,8 +290,7 @@ public:
|
|||
|
||||
FunctionExpression(SourceRange source_range, FlyString const& name, NonnullRefPtr<Statement> body, Vector<Parameter> parameters, i32 function_length, NonnullRefPtrVector<VariableDeclaration> variables, bool is_generator, bool is_strict_mode, bool is_arrow_function = false)
|
||||
: Expression(source_range)
|
||||
, FunctionNode(name, move(body), move(parameters), function_length, move(variables), is_generator, is_strict_mode)
|
||||
, m_is_arrow_function(is_arrow_function)
|
||||
, FunctionNode(name, move(body), move(parameters), function_length, move(variables), is_generator, is_strict_mode, is_arrow_function)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -308,7 +310,6 @@ public:
|
|||
|
||||
private:
|
||||
bool m_cannot_auto_rename { false };
|
||||
bool m_is_arrow_function { false };
|
||||
};
|
||||
|
||||
class ErrorExpression final : public Expression {
|
||||
|
|
Loading…
Reference in a new issue