mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
LibJS: Don't use null DFS for binding_name parameters in ClassExpression
This commit is contained in:
parent
d558468d03
commit
026c1caba0
3 changed files with 9 additions and 9 deletions
|
@ -293,7 +293,7 @@ ThrowCompletionOr<ClassElement::ClassValue> StaticInitializer::class_element_eva
|
||||||
return ClassValue { normal_completion(body_function) };
|
return ClassValue { normal_completion(body_function) };
|
||||||
}
|
}
|
||||||
|
|
||||||
ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::create_class_constructor(VM& vm, Environment* class_environment, Environment* environment, Value super_class, DeprecatedFlyString const& binding_name, DeprecatedFlyString const& class_name) const
|
ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::create_class_constructor(VM& vm, Environment* class_environment, Environment* environment, Value super_class, Optional<DeprecatedFlyString> const& binding_name, DeprecatedFlyString const& class_name) const
|
||||||
{
|
{
|
||||||
auto& realm = *vm.current_realm();
|
auto& realm = *vm.current_realm();
|
||||||
|
|
||||||
|
@ -421,8 +421,8 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::create_class_const
|
||||||
vm.running_execution_context().lexical_environment = environment;
|
vm.running_execution_context().lexical_environment = environment;
|
||||||
restore_environment.disarm();
|
restore_environment.disarm();
|
||||||
|
|
||||||
if (!binding_name.is_null())
|
if (binding_name.has_value())
|
||||||
MUST(class_environment->initialize_binding(vm, binding_name, class_constructor, Environment::InitializeBindingHint::Normal));
|
MUST(class_environment->initialize_binding(vm, binding_name.value(), class_constructor, Environment::InitializeBindingHint::Normal));
|
||||||
|
|
||||||
for (auto& field : instance_fields)
|
for (auto& field : instance_fields)
|
||||||
class_constructor->add_field(field);
|
class_constructor->add_field(field);
|
||||||
|
@ -451,7 +451,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::create_class_const
|
||||||
return { class_constructor };
|
return { class_constructor };
|
||||||
}
|
}
|
||||||
|
|
||||||
ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_evaluation(VM& vm, DeprecatedFlyString const& binding_name, DeprecatedFlyString const& class_name) const
|
ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_evaluation(VM& vm, Optional<DeprecatedFlyString> const& binding_name, DeprecatedFlyString const& class_name) const
|
||||||
{
|
{
|
||||||
auto* environment = vm.lexical_environment();
|
auto* environment = vm.lexical_environment();
|
||||||
VERIFY(environment);
|
VERIFY(environment);
|
||||||
|
@ -459,8 +459,8 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
|
||||||
|
|
||||||
Value super_class;
|
Value super_class;
|
||||||
|
|
||||||
if (!binding_name.is_null())
|
if (binding_name.has_value())
|
||||||
MUST(class_environment->create_immutable_binding(vm, binding_name, true));
|
MUST(class_environment->create_immutable_binding(vm, binding_name.value(), true));
|
||||||
|
|
||||||
if (!m_super_class.is_null()) {
|
if (!m_super_class.is_null()) {
|
||||||
vm.running_execution_context().lexical_environment = class_environment;
|
vm.running_execution_context().lexical_environment = class_environment;
|
||||||
|
|
|
@ -1418,8 +1418,8 @@ public:
|
||||||
|
|
||||||
bool has_name() const { return m_name; }
|
bool has_name() const { return m_name; }
|
||||||
|
|
||||||
ThrowCompletionOr<ECMAScriptFunctionObject*> class_definition_evaluation(VM&, DeprecatedFlyString const& binding_name = {}, DeprecatedFlyString const& class_name = {}) const;
|
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, 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:
|
private:
|
||||||
virtual bool is_class_expression() const override { return true; }
|
virtual bool is_class_expression() const override { return true; }
|
||||||
|
|
|
@ -611,7 +611,7 @@ inline ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM& vm, Value supe
|
||||||
auto* class_environment = vm.lexical_environment();
|
auto* class_environment = vm.lexical_environment();
|
||||||
vm.running_execution_context().lexical_environment = interpreter.saved_lexical_environment_stack().take_last();
|
vm.running_execution_context().lexical_environment = interpreter.saved_lexical_environment_stack().take_last();
|
||||||
|
|
||||||
DeprecatedFlyString binding_name;
|
Optional<DeprecatedFlyString> binding_name;
|
||||||
DeprecatedFlyString class_name;
|
DeprecatedFlyString class_name;
|
||||||
if (!class_expression.has_name() && lhs_name.has_value()) {
|
if (!class_expression.has_name() && lhs_name.has_value()) {
|
||||||
class_name = interpreter.current_executable().get_identifier(lhs_name.value());
|
class_name = interpreter.current_executable().get_identifier(lhs_name.value());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue