mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +00:00
LibJS: Pass call/construct argument lists as ReadonlySpan<Value>
(Instead of MarkedVector<Value>.) This is a step towards not storing argument lists in MarkedVector<Value> at all. Note that they still end up in MarkedVectors since that's what ExecutionContext has.
This commit is contained in:
@@ -63,6 +63,24 @@ NonnullGCPtr<Array> Array::create_from(Realm& realm, Vector<Value> const& elemen
|
||||
return array;
|
||||
}
|
||||
|
||||
NonnullGCPtr<Array> Array::create_from(Realm& realm, ReadonlySpan<Value> const& elements)
|
||||
{
|
||||
// 1. Let array be ! ArrayCreate(0).
|
||||
auto array = MUST(Array::create(realm, 0));
|
||||
|
||||
// 2. Let n be 0.
|
||||
// 3. For each element e of elements, do
|
||||
for (u32 n = 0; n < elements.size(); ++n) {
|
||||
// a. Perform ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), e).
|
||||
MUST(array->create_data_property_or_throw(n, elements[n]));
|
||||
|
||||
// b. Set n to n + 1.
|
||||
}
|
||||
|
||||
// 4. Return array.
|
||||
return array;
|
||||
}
|
||||
|
||||
Array::Array(Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user