1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:15:07 +00:00

LibJS/Bytecode: Use primitive this for strict mode GetByValue

GetByValue now shares code with GetById to elide the synthetic wrapper
objects for primitive values in strict mode.

Fixes 2 test-js tests in bytecode mode. :^)
This commit is contained in:
Andreas Kling 2023-07-21 07:18:30 +02:00
parent 7253d021fc
commit c90bf22d29

View file

@ -1180,11 +1180,19 @@ ThrowCompletionOr<void> GetByValue::execute_impl(Bytecode::Interpreter& interpre
// NOTE: Get the property key from the accumulator before side effects have a chance to overwrite it.
auto property_key_value = interpreter.accumulator();
auto object = TRY(interpreter.reg(m_base).to_object(vm));
auto base_value = interpreter.reg(m_base);
auto object = TRY(base_object_for_get(interpreter, base_value));
auto property_key = TRY(property_key_value.to_property_key(vm));
interpreter.accumulator() = TRY(object->get(property_key));
if (base_value.is_string()) {
auto string_value = TRY(base_value.as_string().get(vm, property_key));
if (string_value.has_value()) {
interpreter.accumulator() = *string_value;
return {};
}
}
interpreter.accumulator() = TRY(object->internal_get(property_key, base_value));
return {};
}