1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:17:42 +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:
Andreas Kling 2023-11-27 12:56:20 +01:00
parent 9fa6628efa
commit ece961f882
29 changed files with 119 additions and 112 deletions

View file

@ -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)
{