mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibJS/Bytecode: Add codegen for "named evaluation if anonymous function"
This gives anonymous functions the name from the LHS they are being assigned to. 171 new passes on test262. :^)
This commit is contained in:
parent
a92d94f4e9
commit
85a3a1c085
8 changed files with 109 additions and 27 deletions
|
@ -21,6 +21,10 @@
|
|||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibJS/Runtime/ValueTraits.h>
|
||||
|
||||
namespace JS {
|
||||
class FunctionExpression;
|
||||
}
|
||||
|
||||
namespace JS::Bytecode::Op {
|
||||
|
||||
class Load final : public Instruction {
|
||||
|
@ -798,9 +802,10 @@ private:
|
|||
|
||||
class NewClass final : public Instruction {
|
||||
public:
|
||||
explicit NewClass(ClassExpression const& class_expression)
|
||||
explicit NewClass(ClassExpression const& class_expression, Optional<DeprecatedFlyString const&> lhs_name)
|
||||
: Instruction(Type::NewClass)
|
||||
, m_class_expression(class_expression)
|
||||
, m_lhs_name(lhs_name.has_value() ? *lhs_name : Optional<DeprecatedFlyString> {})
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -811,13 +816,15 @@ public:
|
|||
|
||||
private:
|
||||
ClassExpression const& m_class_expression;
|
||||
Optional<DeprecatedFlyString> m_lhs_name;
|
||||
};
|
||||
|
||||
class NewFunction final : public Instruction {
|
||||
public:
|
||||
explicit NewFunction(FunctionNode const& function_node, Optional<Register> home_object = {})
|
||||
explicit NewFunction(FunctionExpression const& function_node, Optional<DeprecatedFlyString const&> lhs_name, Optional<Register> home_object = {})
|
||||
: Instruction(Type::NewFunction)
|
||||
, m_function_node(function_node)
|
||||
, m_lhs_name(lhs_name.has_value() ? *lhs_name : Optional<DeprecatedFlyString> {})
|
||||
, m_home_object(move(home_object))
|
||||
{
|
||||
}
|
||||
|
@ -828,7 +835,8 @@ public:
|
|||
void replace_references_impl(Register, Register);
|
||||
|
||||
private:
|
||||
FunctionNode const& m_function_node;
|
||||
FunctionExpression const& m_function_node;
|
||||
Optional<DeprecatedFlyString> m_lhs_name;
|
||||
Optional<Register> m_home_object;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue