Lines Matching +full:non +full:- +full:array
7 * http://www.apache.org/licenses/LICENSE-2.0
22 #include "ecmascript/js_tagged_value-inl.h"
24 #include "interpreter/fast_runtime_stub-inl.h"
29 return JSArray::Cast(*self)->GetLength(); in LengthGetter()
47 uint32_t oldLen = JSArray::Cast(*self)->GetArrayLength(); in LengthSetter()
54 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv(); in ArrayCreate()
55 JSHandle<JSTaggedValue> arrayFunction = env->GetArrayFunction(); in ArrayCreate()
63 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); in ArrayCreate()
70 THROW_RANGE_ERROR_AND_RETURN(thread, "array length must less than 2^32 - 1", exception); in ArrayCreate()
75 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv(); in ArrayCreate()
76 JSHandle<JSTaggedValue> arrayFunc = env->GetArrayFunction(); in ArrayCreate()
77 …JSHandle<JSObject> obj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(arrayFunc), newTar… in ArrayCreate()
79 obj->GetJSHClass()->SetExtensible(true); in ArrayCreate()
83 JSArray::Cast(*obj)->SetArrayLength(thread, normalArrayLength); in ArrayCreate()
92 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv(); in ArraySpeciesCreate()
93 const GlobalEnvConstants *globalConst = thread->GlobalConstants(); in ArraySpeciesCreate()
98 if (arrayLength == -0) { in ArraySpeciesCreate()
104 bool isArray = originalValue->IsArray(thread); in ArraySpeciesCreate()
111 auto *hclass = originalArray->GetJSHClass(); in ArraySpeciesCreate()
112 if (hclass->IsJSArray() && !hclass->HasConstructor()) { in ArraySpeciesCreate()
115 JSHandle<JSTaggedValue> constructorKey = globalConst->GetHandledConstructorString(); in ArraySpeciesCreate()
120 if (constructor->IsConstructor()) { in ArraySpeciesCreate()
128 JSTaggedValue realmArrayConstructor = realmC->GetArrayFunction().GetTaggedValue(); in ArraySpeciesCreate()
129 // If SameValue(C, realmC.[[intrinsics]].[[%Array%]]) is true, let C be undefined. in ArraySpeciesCreate()
137 if (constructor->IsECMAObject()) { in ArraySpeciesCreate()
139 JSHandle<JSTaggedValue> speciesSymbol = env->GetSpeciesSymbol(); in ArraySpeciesCreate()
144 if (constructor->IsNull()) { in ArraySpeciesCreate()
151 if (constructor->IsUndefined()) { in ArraySpeciesCreate()
155 if (!constructor->IsConstructor()) { in ArraySpeciesCreate()
160 InternalCallParams *arguments = thread->GetInternalCallParams(); in ArraySpeciesCreate()
161 arguments->MakeArgv(JSTaggedValue(arrayLength)); in ArraySpeciesCreate()
162 …JSTaggedValue result = JSFunction::Construct(thread, constructor, 1, arguments->GetArgv(), newTarg… in ArraySpeciesCreate()
164 // NOTEIf originalArray was created using the standard built-in Array constructor for in ArraySpeciesCreate()
165 // a Realm that is not the Realm of the running execution context, then a new Array is in ArraySpeciesCreate()
167 // with Web browsers that have historically had that behaviour for the Array.prototype methods in ArraySpeciesCreate()
172 void JSArray::SetCapacity(JSThread *thread, const JSHandle<JSObject> &array, uint32_t oldLen, uint3… in SetCapacity() argument
174 TaggedArray *element = TaggedArray::Cast(array->GetElements().GetTaggedObject()); in SetCapacity()
176 if (element->IsDictionaryMode()) { in SetCapacity()
177 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); in SetCapacity()
178 int32_t numOfElements = array->GetNumberOfElements(); in SetCapacity()
182 JSHandle<TaggedArray> newArr = factory->NewTaggedArray(numOfElements); in SetCapacity()
183 GetAllElementKeys(thread, array, 0, newArr); in SetCapacity()
184 for (uint32_t i = numOfElements - 1; i >= newLen; i--) { in SetCapacity()
185 JSTaggedValue value = newArr->Get(i); in SetCapacity()
189 int entry = dictHandle->FindEntry(key); in SetCapacity()
190 uint32_t attr = dictHandle->GetAttributes(entry).GetValue(); in SetCapacity()
194 array->SetElements(thread, newDict); in SetCapacity()
205 JSArray::Cast(*array)->SetArrayLength(thread, newNumOfElements); in SetCapacity()
208 uint32_t capacity = element->GetLength(); in SetCapacity()
210 // judge if need to cut down the array size, else fill the unused tail with holes in SetCapacity()
211 array->FillElementsWithHoles(thread, newLen, oldLen < capacity ? oldLen : capacity); in SetCapacity()
214 JSObject::ElementsToDictionary(thread, array); in SetCapacity()
216 JSObject::GrowElementsCapacity(thread, array, newLen); in SetCapacity()
218 JSArray::Cast(*array)->SetArrayLength(thread, newLen); in SetCapacity()
221 bool JSArray::ArraySetLength(JSThread *thread, const JSHandle<JSObject> &array, const PropertyDescr… in ArraySetLength() argument
223 JSHandle<JSTaggedValue> lengthKeyHandle(thread->GlobalConstants()->GetHandledLengthString()); in ArraySetLength()
228 return JSObject::OrdinaryDefineOwnProperty(thread, array, lengthKeyHandle, desc); in ArraySetLength()
233 // 3. - 7. Convert Desc.[[Value]] to newLen. in ArraySetLength()
236 THROW_RANGE_ERROR_AND_RETURN(thread, "array length must less than 2^32 - 1", false); in ArraySetLength()
242 [[maybe_unused]] bool success = GetOwnProperty(thread, array, lengthKeyHandle, oldLenDesc); in ArraySetLength()
254 return JSObject::OrdinaryDefineOwnProperty(thread, array, lengthKeyHandle, newLenDesc); in ArraySetLength()
278 JSArray::SetCapacity(thread, array, oldLen, newLen); in ArraySetLength()
279 // Steps 19d-ii, 20. in ArraySetLength()
283 success = JSObject::DefineOwnProperty(thread, array, lengthKeyHandle, readonly); in ArraySetLength()
287 // Steps 19d-v, 21. Return false if there were non-deletable elements. in ArraySetLength()
288 uint32_t arrayLength = JSArray::Cast(*array)->GetArrayLength(); in ArraySetLength()
298 bool JSArray::DefineOwnProperty(JSThread *thread, const JSHandle<JSObject> &array, const JSHandle<J… in DefineOwnProperty() argument
306 return ArraySetLength(thread, array, desc); in DefineOwnProperty()
308 // 3. Else if P is an array index, then in DefineOwnProperty()
311 bool success = JSObject::OrdinaryDefineOwnProperty(thread, array, key, desc); in DefineOwnProperty()
313 JSTaggedValue constructorKey = thread->GlobalConstants()->GetConstructorString(); in DefineOwnProperty()
315 array->GetJSHClass()->SetHasConstructor(true); in DefineOwnProperty()
322 bool JSArray::DefineOwnProperty(JSThread *thread, const JSHandle<JSObject> &array, uint32_t index, in DefineOwnProperty() argument
325 return JSObject::OrdinaryDefineOwnProperty(thread, array, index, desc); in DefineOwnProperty()
330 return key.GetTaggedValue() == thread->GlobalConstants()->GetLengthString(); in IsLengthString()
337 // 2. Let array be ArrayCreate(0) (see 9.4.2.2). in CreateArrayFromList()
338 uint32_t length = elements->GetLength(); in CreateArrayFromList()
341 auto env = thread->GetEcmaVM()->GetGlobalEnv(); in CreateArrayFromList()
342 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); in CreateArrayFromList()
343 JSHandle<JSTaggedValue> arrayFunc = env->GetArrayFunction(); in CreateArrayFromList()
344 …JSHandle<JSObject> obj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(arrayFunc), arrayF… in CreateArrayFromList()
345 obj->GetJSHClass()->SetExtensible(true); in CreateArrayFromList()
346 JSArray::Cast(*obj)->SetArrayLength(thread, length); in CreateArrayFromList()
348 obj->SetElements(thread, elements); in CreateArrayFromList()