mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:37:43 +00:00
LibJS/Bytecode: Make NewArray write directly to indexed properties
This follows how the regular AST interpreter creates arrays, as using Array::create_from uses create_data_property_or_throw, which will crash when it encounters an empty value. We require empty values to represent array holes.
This commit is contained in:
parent
750b69540e
commit
e517cb505a
1 changed files with 6 additions and 5 deletions
|
@ -127,11 +127,12 @@ ThrowCompletionOr<void> NewBigInt::execute_impl(Bytecode::Interpreter& interpret
|
||||||
|
|
||||||
ThrowCompletionOr<void> NewArray::execute_impl(Bytecode::Interpreter& interpreter) const
|
ThrowCompletionOr<void> NewArray::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||||
{
|
{
|
||||||
Vector<Value> elements;
|
auto* array = MUST(Array::create(interpreter.global_object(), 0));
|
||||||
elements.ensure_capacity(m_element_count);
|
for (size_t i = 0; i < m_element_count; i++) {
|
||||||
for (size_t i = 0; i < m_element_count; i++)
|
auto& value = interpreter.reg(m_elements[i]);
|
||||||
elements.append(interpreter.reg(m_elements[i]));
|
array->indexed_properties().put(i, value, default_attributes);
|
||||||
interpreter.accumulator() = Array::create_from(interpreter.global_object(), elements);
|
}
|
||||||
|
interpreter.accumulator() = array;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue