diff --git a/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 0ed6109711e..32dfc18cc5b 100644 --- a/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -621,7 +621,7 @@ Bytecode::CodeGenerationErrorOr> AssignmentExpression::g // ii. Let rval be ? GetValue(rref). auto rval = TRY([&]() -> Bytecode::CodeGenerationErrorOr { if (lhs->is_identifier()) { - return TRY(generator.emit_named_evaluation_if_anonymous_function(*m_rhs, generator.intern_identifier(static_cast(*lhs).string()))).value(); + return TRY(generator.emit_named_evaluation_if_anonymous_function(*m_rhs, generator.intern_identifier(static_cast(*lhs).string()))); } else { return TRY(m_rhs->generate_bytecode(generator)).value(); } @@ -731,7 +731,7 @@ Bytecode::CodeGenerationErrorOr> AssignmentExpression::g auto rhs = TRY([&]() -> Bytecode::CodeGenerationErrorOr { if (lhs_expression->is_identifier()) { - return TRY(generator.emit_named_evaluation_if_anonymous_function(*m_rhs, generator.intern_identifier(static_cast(*lhs_expression).string()))).value(); + return TRY(generator.emit_named_evaluation_if_anonymous_function(*m_rhs, generator.intern_identifier(static_cast(*lhs_expression).string()))); } return TRY(m_rhs->generate_bytecode(generator)).value(); }()); @@ -1183,7 +1183,7 @@ Bytecode::CodeGenerationErrorOr> ObjectExpression::gener else if (property_kind == Bytecode::Op::PropertyKind::Setter) identifier = MUST(String::formatted("set {}", identifier)); auto name = generator.intern_identifier(identifier); - value = TRY(generator.emit_named_evaluation_if_anonymous_function(property->value(), name)).value(); + value = TRY(generator.emit_named_evaluation_if_anonymous_function(property->value(), name)); } generator.emit(object, key_name, *value, property_kind, generator.next_property_lookup_cache()); @@ -1370,9 +1370,9 @@ static Bytecode::CodeGenerationErrorOr generate_object_binding_pattern_byt generator.switch_to_basic_block(if_undefined_block); Optional default_value; if (auto const* alias_identifier = alias.get_pointer>()) { - default_value = TRY(generator.emit_named_evaluation_if_anonymous_function(*initializer, generator.intern_identifier((*alias_identifier)->string()))).value(); + default_value = TRY(generator.emit_named_evaluation_if_anonymous_function(*initializer, generator.intern_identifier((*alias_identifier)->string()))); } else if (auto const* lhs = name.get_pointer>()) { - default_value = TRY(generator.emit_named_evaluation_if_anonymous_function(*initializer, generator.intern_identifier((*lhs)->string()))).value(); + default_value = TRY(generator.emit_named_evaluation_if_anonymous_function(*initializer, generator.intern_identifier((*lhs)->string()))); } else { default_value = TRY(initializer->generate_bytecode(generator)).value(); } @@ -1543,9 +1543,9 @@ static Bytecode::CodeGenerationErrorOr generate_array_binding_pattern_byte Optional default_value; if (auto const* alias_identifier = alias.get_pointer>()) { - default_value = TRY(generator.emit_named_evaluation_if_anonymous_function(*initializer, generator.intern_identifier((*alias_identifier)->string()))).value(); + default_value = TRY(generator.emit_named_evaluation_if_anonymous_function(*initializer, generator.intern_identifier((*alias_identifier)->string()))); } else if (auto const* name_identifier = name.get_pointer>()) { - default_value = TRY(generator.emit_named_evaluation_if_anonymous_function(*initializer, generator.intern_identifier((*name_identifier)->string()))).value(); + default_value = TRY(generator.emit_named_evaluation_if_anonymous_function(*initializer, generator.intern_identifier((*name_identifier)->string()))); } else { default_value = TRY(initializer->generate_bytecode(generator)).value(); } @@ -1618,7 +1618,7 @@ Bytecode::CodeGenerationErrorOr> VariableDeclaration::ge if (declarator->init()) { auto value = TRY([&]() -> Bytecode::CodeGenerationErrorOr { if (auto const* lhs = declarator->target().get_pointer>()) { - return TRY(generator.emit_named_evaluation_if_anonymous_function(*declarator->init(), generator.intern_identifier((*lhs)->string()), init_dst)).value(); + return TRY(generator.emit_named_evaluation_if_anonymous_function(*declarator->init(), generator.intern_identifier((*lhs)->string()), init_dst)); } else { return TRY(declarator->init()->generate_bytecode(generator, init_dst)).value(); } @@ -3061,7 +3061,7 @@ static Bytecode::CodeGenerationErrorOr for_in_of_he VERIFY(variable->target().has>()); auto identifier = variable->target().get>(); auto identifier_table_ref = generator.intern_identifier(identifier->string()); - auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(*variable->init(), identifier_table_ref)).value(); + auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(*variable->init(), identifier_table_ref)); generator.emit_set_variable(*identifier, value); } } else { @@ -3456,9 +3456,8 @@ Bytecode::CodeGenerationErrorOr> ClassFieldInitializerSt { Bytecode::Generator::SourceLocationScope scope(generator, *this); auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(*m_expression, generator.intern_identifier(m_class_field_identifier_name), preferred_dst)); - VERIFY(value.has_value()); generator.perform_needed_unwinds(); - generator.emit(value->operand()); + generator.emit(value.operand()); return value; } @@ -3573,7 +3572,7 @@ Bytecode::CodeGenerationErrorOr> ExportStatement::genera } if (is(*m_statement)) { - auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(static_cast(*m_statement), generator.intern_identifier("default"_fly_string))).value(); + auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(static_cast(*m_statement), generator.intern_identifier("default"_fly_string))); if (!static_cast(*m_statement).has_name()) { generator.emit( @@ -3586,7 +3585,7 @@ Bytecode::CodeGenerationErrorOr> ExportStatement::genera // ExportDeclaration : export default AssignmentExpression ; VERIFY(is(*m_statement)); - auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(static_cast(*m_statement), generator.intern_identifier("default"_fly_string))).value(); + auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(static_cast(*m_statement), generator.intern_identifier("default"_fly_string))); generator.emit( generator.intern_identifier(ExportStatement::local_name_for_default), value); diff --git a/Libraries/LibJS/Bytecode/Generator.cpp b/Libraries/LibJS/Bytecode/Generator.cpp index 88c1d326a30..dd07edb60eb 100644 --- a/Libraries/LibJS/Bytecode/Generator.cpp +++ b/Libraries/LibJS/Bytecode/Generator.cpp @@ -1090,7 +1090,7 @@ void Generator::emit_new_function(ScopedOperand dst, FunctionExpression const& f } } -CodeGenerationErrorOr> Generator::emit_named_evaluation_if_anonymous_function(Expression const& expression, Optional lhs_name, Optional preferred_dst) +CodeGenerationErrorOr Generator::emit_named_evaluation_if_anonymous_function(Expression const& expression, Optional lhs_name, Optional preferred_dst) { if (is(expression)) { auto const& function_expression = static_cast(expression); @@ -1106,7 +1106,7 @@ CodeGenerationErrorOr> Generator::emit_named_evaluation_ } } - return expression.generate_bytecode(*this, preferred_dst); + return TRY(expression.generate_bytecode(*this, preferred_dst)).value(); } void Generator::emit_get_by_id(ScopedOperand dst, ScopedOperand base, IdentifierTableIndex property_identifier, Optional base_identifier) diff --git a/Libraries/LibJS/Bytecode/Generator.h b/Libraries/LibJS/Bytecode/Generator.h index e906b1e5e6b..980375a589d 100644 --- a/Libraries/LibJS/Bytecode/Generator.h +++ b/Libraries/LibJS/Bytecode/Generator.h @@ -165,7 +165,7 @@ public: void pop_home_object(); void emit_new_function(ScopedOperand dst, JS::FunctionExpression const&, Optional lhs_name); - CodeGenerationErrorOr> emit_named_evaluation_if_anonymous_function(Expression const&, Optional lhs_name, Optional preferred_dst = {}); + CodeGenerationErrorOr emit_named_evaluation_if_anonymous_function(Expression const&, Optional lhs_name, Optional preferred_dst = {}); void begin_continuable_scope(Label continue_target, Vector const& language_label_set); void end_continuable_scope();