diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index c7439d26b53..0b63b5a6fcd 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -560,9 +560,33 @@ void ForStatement::generate_bytecode(Bytecode::Generator& generator) const void ObjectExpression::generate_bytecode(Bytecode::Generator& generator) const { generator.emit(); + if (m_properties.is_empty()) + return; - if (!m_properties.is_empty()) - TODO(); + auto object_reg = generator.allocate_register(); + generator.emit(object_reg); + + for (auto& property : m_properties) { + if (property.type() != ObjectProperty::Type::KeyValue) + TODO(); + + if (is(property.key())) { + auto& string_literal = static_cast(property.key()); + Bytecode::StringTableIndex key_name = generator.intern_string(string_literal.value()); + + property.value().generate_bytecode(generator); + generator.emit(object_reg, key_name); + } else { + property.key().generate_bytecode(generator); + auto property_reg = generator.allocate_register(); + generator.emit(property_reg); + + property.value().generate_bytecode(generator); + generator.emit(object_reg, property_reg); + } + } + + generator.emit(object_reg); } void ArrayExpression::generate_bytecode(Bytecode::Generator& generator) const