Skip to content

Commit

Permalink
LibJS: Delete named_evaluation_if_anonymous_function()
Browse files Browse the repository at this point in the history
This code was a leftover from AST interpreter.
  • Loading branch information
kalenikaliaksandr authored and awesomekling committed May 11, 2024
1 parent 6ad6e09 commit 0c8e76c
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 42 deletions.
20 changes: 0 additions & 20 deletions Userland/Libraries/LibJS/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,26 +452,6 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::create_class_const
return { class_constructor };
}

ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_evaluation(VM& vm, Optional<DeprecatedFlyString> const& binding_name, DeprecatedFlyString const& class_name) const
{
auto* environment = vm.lexical_environment();
VERIFY(environment);
auto class_environment = new_declarative_environment(*environment);

Value super_class;

if (binding_name.has_value())
MUST(class_environment->create_immutable_binding(vm, binding_name.value(), true));

if (!m_super_class.is_null()) {
vm.running_execution_context().lexical_environment = class_environment;
super_class = TRY(vm.execute_ast_node(*m_super_class));
vm.running_execution_context().lexical_environment = environment;
}

return create_class_constructor(vm, class_environment, environment, super_class, binding_name, class_name);
}

void ASTNode::dump(int indent) const
{
print_indent(indent);
Expand Down
1 change: 0 additions & 1 deletion Userland/Libraries/LibJS/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,6 @@ class ClassExpression final : public Expression {

bool has_name() const { return m_name; }

ThrowCompletionOr<ECMAScriptFunctionObject*> class_definition_evaluation(VM&, Optional<DeprecatedFlyString> const& binding_name = {}, DeprecatedFlyString const& class_name = {}) const;
ThrowCompletionOr<ECMAScriptFunctionObject*> create_class_constructor(VM&, Environment* class_environment, Environment* environment, Value super_class, Optional<DeprecatedFlyString> const& binding_name = {}, DeprecatedFlyString const& class_name = {}) const;

private:
Expand Down
19 changes: 0 additions & 19 deletions Userland/Libraries/LibJS/Runtime/VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,25 +219,6 @@ void VM::gather_roots(HashMap<Cell*, HeapRoot>& roots)
roots.set(job, HeapRoot { .type = HeapRoot::Type::VM });
}

ThrowCompletionOr<Value> VM::named_evaluation_if_anonymous_function(ASTNode const& expression, DeprecatedFlyString const& name)
{
// 8.3.3 Static Semantics: IsAnonymousFunctionDefinition ( expr ), https://tc39.es/ecma262/#sec-isanonymousfunctiondefinition
// And 8.3.5 Runtime Semantics: NamedEvaluation, https://tc39.es/ecma262/#sec-runtime-semantics-namedevaluation
if (is<FunctionExpression>(expression)) {
auto& function = static_cast<FunctionExpression const&>(expression);
if (!function.has_name()) {
return function.instantiate_ordinary_function_expression(*this, name);
}
} else if (is<ClassExpression>(expression)) {
auto& class_expression = static_cast<ClassExpression const&>(expression);
if (!class_expression.has_name()) {
return TRY(class_expression.class_definition_evaluation(*this, {}, name));
}
}

return execute_ast_node(expression);
}

ThrowCompletionOr<Value> VM::execute_ast_node(ASTNode const& node)
{
// FIXME: This function should be gone once we will emit bytecode for everything before executing instructions.
Expand Down
2 changes: 0 additions & 2 deletions Userland/Libraries/LibJS/Runtime/VM.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ class VM : public RefCounted<VM> {

CustomData* custom_data() { return m_custom_data; }

ThrowCompletionOr<Value> named_evaluation_if_anonymous_function(ASTNode const& expression, DeprecatedFlyString const& name);

void save_execution_context_stack();
void clear_execution_context_stack();
void restore_execution_context_stack();
Expand Down

0 comments on commit 0c8e76c

Please sign in to comment.