mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:37:45 +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
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
|
Value FunctionExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const
|
||||||
{
|
{
|
||||||
InterpreterNodeScope node_scope { interpreter, *this };
|
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
|
Value ExpressionStatement::execute(Interpreter& interpreter, GlobalObject& global_object) const
|
||||||
|
|
|
@ -227,10 +227,11 @@ public:
|
||||||
Vector<Parameter> const& parameters() const { return m_parameters; };
|
Vector<Parameter> const& parameters() const { return m_parameters; };
|
||||||
i32 function_length() const { return m_function_length; }
|
i32 function_length() const { return m_function_length; }
|
||||||
bool is_strict_mode() const { return m_is_strict_mode; }
|
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; }
|
bool is_generator() const { return m_is_generator; }
|
||||||
|
|
||||||
protected:
|
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_name(name)
|
||||||
, m_body(move(body))
|
, m_body(move(body))
|
||||||
, m_parameters(move(parameters))
|
, m_parameters(move(parameters))
|
||||||
|
@ -238,6 +239,7 @@ protected:
|
||||||
, m_function_length(function_length)
|
, m_function_length(function_length)
|
||||||
, m_is_generator(is_generator)
|
, m_is_generator(is_generator)
|
||||||
, m_is_strict_mode(is_strict_mode)
|
, m_is_strict_mode(is_strict_mode)
|
||||||
|
, m_is_arrow_function(is_arrow_function)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,6 +262,7 @@ private:
|
||||||
const i32 m_function_length;
|
const i32 m_function_length;
|
||||||
bool m_is_generator;
|
bool m_is_generator;
|
||||||
bool m_is_strict_mode;
|
bool m_is_strict_mode;
|
||||||
|
bool m_is_arrow_function { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
class FunctionDeclaration final
|
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)
|
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))
|
: 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)
|
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)
|
: Expression(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, is_arrow_function)
|
||||||
, m_is_arrow_function(is_arrow_function)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +310,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_cannot_auto_rename { false };
|
bool m_cannot_auto_rename { false };
|
||||||
bool m_is_arrow_function { false };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ErrorExpression final : public Expression {
|
class ErrorExpression final : public Expression {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue