Lines Matching refs:thread

59     JSThread *thread = msg->GetThread();
60 [[maybe_unused]] EcmaHandleScope handleScope(thread);
66 THROW_TYPE_ERROR_AND_RETURN(thread, "Incorrect input parameters", JSTaggedValue::Exception());
70 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
72 JSHandle<JSObject> undefinedIteratorResult = JSIterator::CreateIterResultObject(thread, undefinedHandle, true);
78 res = InitializeContainer(thread, thisValue, InitializeArrayList, "ArrayListConstructor");
82 res = InitializeContainer(thread, thisValue, InitializeDeque, "DequeConstructor");
86 res = InitializeContainer(thread, thisValue, InitializeLightWeightMap, "LightWeightMapConstructor");
90 res = InitializeContainer(thread, thisValue, InitializeLightWeightSet, "LightWeightSetConstructor");
94 res = InitializeContainer(thread, thisValue, InitializePlainArray, "PlainArrayConstructor");
98 res = InitializeContainer(thread, thisValue, InitializeQueue, "QueueConstructor");
102 res = InitializeContainer(thread, thisValue, InitializeStack, "StackConstructor");
106 res = InitializeContainer(thread, thisValue, InitializeTreeMap, "TreeMapConstructor");
110 res = InitializeContainer(thread, thisValue, InitializeTreeSet, "TreeSetConstructor");
114 res = InitializeContainer(thread, thisValue, InitializeVector, "VectorConstructor");
118 res = InitializeContainer(thread, thisValue, InitializeBitVector, "BitVectorConstructor");
122 res = InitializeContainer(thread, thisValue, InitializeList, "ListConstructor");
126 res = InitializeContainer(thread, thisValue, InitializeLinkedList, "LinkedListConstructor");
130 res = InitializeContainer(thread, thisValue, InitializeHashMap, "HashMapConstructor");
134 res = InitializeContainer(thread, thisValue, InitializeHashSet, "HashSetConstructor");
147 JSTaggedValue ContainersPrivate::InitializeContainer(JSThread *thread, const JSHandle<JSObject> &obj,
150 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
153 (thread, obj.GetTaggedValue(), key.GetTaggedValue());
157 JSHandle<JSTaggedValue> map = func(thread);
158 SetFrozenConstructor(thread, obj, name, map);
162 JSHandle<JSFunction> ContainersPrivate::NewContainerConstructor(JSThread *thread, const JSHandle<JSObject> &prototype,
165 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
166 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
170 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
171 JSFunction::SetFunctionLength(thread, ctor, JSTaggedValue(length));
173 JSFunction::SetFunctionName(thread, JSHandle<JSFunctionBase>(ctor), nameString,
176 PropertyDescriptor descriptor1(thread, JSHandle<JSTaggedValue>::Cast(ctor), true, false, true);
177 JSObject::DefineOwnProperty(thread, prototype, constructorKey, descriptor1);
180 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread, ctor, prototype.GetTaggedValue());
185 void ContainersPrivate::SetFrozenFunction(JSThread *thread, const JSHandle<JSObject> &obj, const char *key,
188 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
190 JSHandle<JSFunction> function = NewFunction(thread, keyString, func, length, builtinId);
191 PropertyDescriptor descriptor(thread, JSHandle<JSTaggedValue>(function), false, false, false);
192 JSObject::DefineOwnProperty(thread, obj, keyString, descriptor);
195 void ContainersPrivate::SetFrozenConstructor(JSThread *thread, const JSHandle<JSObject> &obj, const char *keyChar,
198 JSObject::PreventExtensions(thread, JSHandle<JSObject>::Cast(value));
199 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
201 PropertyDescriptor descriptor(thread, value, false, false, false);
202 JSObject::DefineOwnProperty(thread, obj, key, descriptor);
205 JSHandle<JSFunction> ContainersPrivate::NewFunction(JSThread *thread, const JSHandle<JSTaggedValue> &key,
209 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
211 factory->NewJSFunction(thread->GetEcmaVM()->GetGlobalEnv(), reinterpret_cast<void *>(func),
213 JSFunction::SetFunctionLength(thread, function, JSTaggedValue(length));
215 JSFunction::SetFunctionName(thread, baseFunction, key, thread->GlobalConstants()->GetHandledUndefined());
219 JSHandle<JSTaggedValue> ContainersPrivate::CreateGetter(JSThread *thread, EcmaEntrypoint func, const char *name,
222 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
223 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
225 JSFunction::SetFunctionLength(thread, function, JSTaggedValue(length));
227 JSHandle<JSTaggedValue> prefix = thread->GlobalConstants()->GetHandledGetString();
228 JSFunction::SetFunctionName(thread, JSHandle<JSFunctionBase>(function), funcName, prefix);
232 void ContainersPrivate::SetGetter(JSThread *thread, const JSHandle<JSObject> &obj, const JSHandle<JSTaggedValue> &key,
235 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
237 accessor->SetGetter(thread, getter);
239 JSObject::AddAccessor(thread, JSHandle<JSTaggedValue>::Cast(obj), key, accessor, attr);
242 void ContainersPrivate::SetFunctionAtSymbol(JSThread *thread, const JSHandle<GlobalEnv> &env,
246 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
248 JSFunction::SetFunctionLength(thread, function, JSTaggedValue(length));
251 JSFunction::SetFunctionName(thread, baseFunction, nameString, thread->GlobalConstants()->GetHandledUndefined());
252 PropertyDescriptor descriptor(thread, JSHandle<JSTaggedValue>::Cast(function), false, false, false);
253 JSObject::DefineOwnProperty(thread, obj, symbol, descriptor);
256 void ContainersPrivate::SetStringTagSymbol(JSThread *thread, const JSHandle<GlobalEnv> &env,
259 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
262 PropertyDescriptor desc(thread, tag, false, false, false);
263 JSObject::DefineOwnProperty(thread, obj, symbol, desc);
266 JSHandle<JSTaggedValue> ContainersPrivate::InitializeArrayList(JSThread *thread)
268 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
269 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
278 thread, prototype, ContainersArrayList::ArrayListConstructor, "ArrayList", FuncLength::ZERO));
279 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
284 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(prototype), constructorKey, arrayListFunction);
285 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
288 SetFrozenFunction(thread, prototype, "add", ContainersArrayList::Add, FuncLength::ONE);
289 SetFrozenFunction(thread, prototype, "insert", ContainersArrayList::Insert, FuncLength::TWO);
290 SetFrozenFunction(thread, prototype, "clear", ContainersArrayList::Clear, FuncLength::ZERO);
291 SetFrozenFunction(thread, prototype, "clone", ContainersArrayList::Clone, FuncLength::ZERO);
292 SetFrozenFunction(thread, prototype, "has", ContainersArrayList::Has, FuncLength::ONE);
293 SetFrozenFunction(thread, prototype, "getCapacity", ContainersArrayList::GetCapacity, FuncLength::ZERO);
294 SetFrozenFunction(thread, prototype, "increaseCapacityTo",
296 SetFrozenFunction(thread, prototype, "trimToCurrentLength",
298 SetFrozenFunction(thread, prototype, "getIndexOf", ContainersArrayList::GetIndexOf, FuncLength::ONE);
299 SetFrozenFunction(thread, prototype, "isEmpty", ContainersArrayList::IsEmpty, FuncLength::ZERO);
300 SetFrozenFunction(thread, prototype, "getLastIndexOf", ContainersArrayList::GetLastIndexOf, FuncLength::ONE);
301 SetFrozenFunction(thread, prototype, "removeByIndex", ContainersArrayList::RemoveByIndex, FuncLength::ONE);
302 SetFrozenFunction(thread, prototype, "remove", ContainersArrayList::Remove, FuncLength::ONE);
303 SetFrozenFunction(thread, prototype, "removeByRange", ContainersArrayList::RemoveByRange, FuncLength::TWO);
304 SetFrozenFunction(thread, prototype, "replaceAllElements", ContainersArrayList::ReplaceAllElements,
306 SetFrozenFunction(thread, prototype, "sort", ContainersArrayList::Sort, FuncLength::ONE);
307 SetFrozenFunction(thread, prototype, "subArrayList", ContainersArrayList::SubArrayList, FuncLength::TWO);
308 SetFrozenFunction(thread, prototype, "convertToArray", ContainersArrayList::ConvertToArray, FuncLength::ZERO);
309 SetFrozenFunction(thread, prototype, "forEach", ContainersArrayList::ForEach, FuncLength::TWO,
312 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
313 SetStringTagSymbol(thread, env, prototype, "ArrayList");
315 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(thread, ContainersArrayList::GetSize, "length",
317 JSHandle<JSTaggedValue> lengthKey(thread, globalConst->GetLengthString());
318 SetGetter(thread, prototype, lengthKey, lengthGetter);
320 SetFunctionAtSymbol(thread, env, prototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
322 ContainersPrivate::InitializeArrayListIterator(thread, env, globalConst);
327 void ContainersPrivate::InitializeArrayListIterator(JSThread *thread, const JSHandle<GlobalEnv> &env,
330 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
337 SetFrozenFunction(thread, arrayListIteratorPrototype, "next", JSAPIArrayListIterator::Next, FuncLength::ONE);
338 SetStringTagSymbol(thread, env, arrayListIteratorPrototype, "ArrayList Iterator");
343 JSHandle<JSTaggedValue> ContainersPrivate::InitializeLightWeightMap(JSThread *thread)
345 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
346 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
352 thread, funcPrototype, ContainersLightWeightMap::LightWeightMapConstructor, "LightWeightMap",
354 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
359 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(funcPrototype), constructorKey, lightWeightMapFunction);
360 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
363 SetFrozenFunction(thread, funcPrototype, "hasAll", ContainersLightWeightMap::HasAll, FuncLength::ONE);
364 SetFrozenFunction(thread, funcPrototype, "hasKey", ContainersLightWeightMap::HasKey, FuncLength::ONE);
365 SetFrozenFunction(thread, funcPrototype, "hasValue", ContainersLightWeightMap::HasValue, FuncLength::ONE);
366 SetFrozenFunction(thread, funcPrototype, "increaseCapacityTo", ContainersLightWeightMap::IncreaseCapacityTo,
368 SetFrozenFunction(thread, funcPrototype, "entries", ContainersLightWeightMap::Entries, FuncLength::ONE);
369 SetFrozenFunction(thread, funcPrototype, "get", ContainersLightWeightMap::Get, FuncLength::ONE);
370 SetFrozenFunction(thread, funcPrototype, "getIndexOfKey", ContainersLightWeightMap::GetIndexOfKey, FuncLength::ONE);
371 SetFrozenFunction(thread, funcPrototype, "getIndexOfValue", ContainersLightWeightMap::GetIndexOfValue,
373 SetFrozenFunction(thread, funcPrototype, "isEmpty", ContainersLightWeightMap::IsEmpty, FuncLength::ONE);
374 SetFrozenFunction(thread, funcPrototype, "getKeyAt", ContainersLightWeightMap::GetKeyAt, FuncLength::ONE);
375 SetFrozenFunction(thread, funcPrototype, "keys", ContainersLightWeightMap::Keys, FuncLength::ONE);
376 SetFrozenFunction(thread, funcPrototype, "setAll", ContainersLightWeightMap::SetAll, FuncLength::ONE);
377 SetFrozenFunction(thread, funcPrototype, "set", ContainersLightWeightMap::Set, FuncLength::ONE);
378 SetFrozenFunction(thread, funcPrototype, "remove", ContainersLightWeightMap::Remove, FuncLength::ONE);
379 SetFrozenFunction(thread, funcPrototype, "removeAt", ContainersLightWeightMap::RemoveAt, FuncLength::ONE);
380 SetFrozenFunction(thread, funcPrototype, "clear", ContainersLightWeightMap::Clear, FuncLength::ONE);
381 SetFrozenFunction(thread, funcPrototype, "setValueAt", ContainersLightWeightMap::SetValueAt, FuncLength::ONE);
382 SetFrozenFunction(thread, funcPrototype, "forEach", ContainersLightWeightMap::ForEach, FuncLength::ONE,
384 SetFrozenFunction(thread, funcPrototype, "toString", ContainersLightWeightMap::ToString, FuncLength::ONE);
385 SetFrozenFunction(thread, funcPrototype, "getValueAt", ContainersLightWeightMap::GetValueAt, FuncLength::ONE);
386 SetFrozenFunction(thread, funcPrototype, "values", ContainersLightWeightMap::Values, FuncLength::ONE);
388 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(thread, ContainersLightWeightMap::Length, "length",
391 SetGetter(thread, funcPrototype, lengthKey, lengthGetter);
393 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
394 SetFunctionAtSymbol(thread, env, funcPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
397 ContainersPrivate::InitializeLightWeightMapIterator(thread);
401 void ContainersPrivate::InitializeLightWeightMapIterator(JSThread *thread)
403 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
404 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
408 SetFrozenFunction(thread, lightWeightMapIteratorPrototype, "next", JSAPILightWeightMapIterator::Next,
410 SetStringTagSymbol(thread, env, lightWeightMapIteratorPrototype, "LightWeightMap Iterator");
411 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
416 JSHandle<JSTaggedValue> ContainersPrivate::InitializeLightWeightSet(JSThread *thread)
418 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
419 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
427 NewContainerConstructor(thread, funcPrototype, ContainersLightWeightSet::LightWeightSetConstructor,
429 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
433 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(funcPrototype), constructorKey, lightweightSetFunction);
434 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
435 SetFrozenFunction(thread, funcPrototype, "add", ContainersLightWeightSet::Add, FuncLength::ONE);
436 SetFrozenFunction(thread, funcPrototype, "addAll", ContainersLightWeightSet::AddAll, FuncLength::ONE);
437 SetFrozenFunction(thread, funcPrototype, "isEmpty", ContainersLightWeightSet::IsEmpty, FuncLength::ONE);
438 SetFrozenFunction(thread, funcPrototype, "getValueAt", ContainersLightWeightSet::GetValueAt, FuncLength::ONE);
439 SetFrozenFunction(thread, funcPrototype, "hasAll", ContainersLightWeightSet::HasAll, FuncLength::ONE);
440 SetFrozenFunction(thread, funcPrototype, "has", ContainersLightWeightSet::Has, FuncLength::ONE);
441 SetFrozenFunction(thread, funcPrototype, "equal", ContainersLightWeightSet::Equal, FuncLength::ONE);
442 SetFrozenFunction(thread, funcPrototype, "increaseCapacityTo",
444 SetFrozenFunction(thread, funcPrototype, "forEach", ContainersLightWeightSet::ForEach, FuncLength::ONE,
446 SetFrozenFunction(thread, funcPrototype, "getIndexOf", ContainersLightWeightSet::GetIndexOf, FuncLength::ONE);
447 SetFrozenFunction(thread, funcPrototype, "remove", ContainersLightWeightSet::Remove, FuncLength::ZERO);
448 SetFrozenFunction(thread, funcPrototype, "removeAt", ContainersLightWeightSet::RemoveAt, FuncLength::ZERO);
449 SetFrozenFunction(thread, funcPrototype, "clear", ContainersLightWeightSet::Clear, FuncLength::ONE);
450 SetFrozenFunction(thread, funcPrototype, "toString", ContainersLightWeightSet::ToString, FuncLength::ZERO);
451 SetFrozenFunction(thread, funcPrototype, "toArray", ContainersLightWeightSet::ToArray, FuncLength::ONE);
452 SetFrozenFunction(thread, funcPrototype, "values", ContainersLightWeightSet::Values, FuncLength::ONE);
453 SetFrozenFunction(thread, funcPrototype, "entries", ContainersLightWeightSet::Entries, FuncLength::ZERO);
455 CreateGetter(thread, ContainersLightWeightSet::GetSize, "length", FuncLength::ZERO);
458 SetGetter(thread, funcPrototype, lengthKey, lengthGetter);
459 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
460 SetFunctionAtSymbol(thread, env, funcPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
463 InitializeLightWeightSetIterator(thread);
467 void ContainersPrivate::InitializeLightWeightSetIterator(JSThread *thread)
469 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
470 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
471 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
473 JSHandle<JSHClass>(thread, globalConst->GetHandledJSAPIIteratorFuncHClass().GetObject<JSHClass>());
476 thread, lightWeightSetIteratorPrototype, "next", JSAPILightWeightSetIterator::Next, FuncLength::ONE);
477 SetStringTagSymbol(thread, env, lightWeightSetIteratorPrototype, "LightWeightSet Iterator");
482 JSHandle<JSTaggedValue> ContainersPrivate::InitializeTreeMap(JSThread *thread)
484 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
485 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
494 thread, mapFuncPrototype, ContainersTreeMap::TreeMapConstructor, "TreeMap", FuncLength::ZERO));
495 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
500 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(mapFuncPrototype), constructorKey, mapFunction);
501 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
503 SetFrozenFunction(thread, mapFuncPrototype, "set", ContainersTreeMap::Set, FuncLength::TWO);
504 SetFrozenFunction(thread, mapFuncPrototype, "get", ContainersTreeMap::Get, FuncLength::ONE);
505 SetFrozenFunction(thread, mapFuncPrototype, "remove", ContainersTreeMap::Remove, FuncLength::ONE);
506 SetFrozenFunction(thread, mapFuncPrototype, "hasKey", ContainersTreeMap::HasKey, FuncLength::ONE);
507 SetFrozenFunction(thread, mapFuncPrototype, "hasValue", ContainersTreeMap::HasValue, FuncLength::ONE);
508 SetFrozenFunction(thread, mapFuncPrototype, "getFirstKey", ContainersTreeMap::GetFirstKey, FuncLength::ZERO);
509 SetFrozenFunction(thread, mapFuncPrototype, "getLastKey", ContainersTreeMap::GetLastKey, FuncLength::ZERO);
510 SetFrozenFunction(thread, mapFuncPrototype, "setAll", ContainersTreeMap::SetAll, FuncLength::ONE);
511 SetFrozenFunction(thread, mapFuncPrototype, "clear", ContainersTreeMap::Clear, FuncLength::ZERO);
512 SetFrozenFunction(thread, mapFuncPrototype, "getLowerKey", ContainersTreeMap::GetLowerKey, FuncLength::ONE);
513 SetFrozenFunction(thread, mapFuncPrototype, "getHigherKey", ContainersTreeMap::GetHigherKey, FuncLength::ONE);
514 SetFrozenFunction(thread, mapFuncPrototype, "keys", ContainersTreeMap::Keys, FuncLength::ZERO);
515 SetFrozenFunction(thread, mapFuncPrototype, "values", ContainersTreeMap::Values, FuncLength::ZERO);
516 SetFrozenFunction(thread, mapFuncPrototype, "replace", ContainersTreeMap::Replace, FuncLength::TWO);
517 SetFrozenFunction(thread, mapFuncPrototype, "forEach", ContainersTreeMap::ForEach, FuncLength::ONE);
518 SetFrozenFunction(thread, mapFuncPrototype, "entries", ContainersTreeMap::Entries, FuncLength::ZERO);
519 SetFrozenFunction(thread, mapFuncPrototype, "isEmpty", ContainersTreeMap::IsEmpty, FuncLength::ZERO);
522 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
523 SetStringTagSymbol(thread, env, mapFuncPrototype, "TreeMap");
528 JSObject::GetMethod(thread, JSHandle<JSTaggedValue>::Cast(mapFuncPrototype), entries);
529 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
530 PropertyDescriptor descriptor(thread, entriesFunc, false, false, false);
531 JSObject::DefineOwnProperty(thread, mapFuncPrototype, iteratorSymbol, descriptor);
534 CreateGetter(thread, ContainersTreeMap::GetLength, "length", FuncLength::ZERO);
535 JSHandle<JSTaggedValue> lengthKey(thread, globalConst->GetLengthString());
536 SetGetter(thread, mapFuncPrototype, lengthKey, lengthGetter);
538 InitializeTreeMapIterator(thread);
542 void ContainersPrivate::InitializeTreeMapIterator(JSThread *thread)
544 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
545 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
553 SetFrozenFunction(thread, mapIteratorPrototype, "next", JSAPITreeMapIterator::Next, FuncLength::ZERO);
554 SetStringTagSymbol(thread, env, mapIteratorPrototype, "TreeMap Iterator");
555 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
559 JSHandle<JSTaggedValue> ContainersPrivate::InitializeTreeSet(JSThread *thread)
561 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
562 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
571 thread, setFuncPrototype, ContainersTreeSet::TreeSetConstructor, "TreeSet", FuncLength::ZERO));
572 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
577 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(setFuncPrototype), constructorKey, setFunction);
578 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
580 SetFrozenFunction(thread, setFuncPrototype, "add", ContainersTreeSet::Add, FuncLength::TWO);
581 SetFrozenFunction(thread, setFuncPrototype, "remove", ContainersTreeSet::Remove, FuncLength::ONE);
582 SetFrozenFunction(thread, setFuncPrototype, "has", ContainersTreeSet::Has, FuncLength::ONE);
583 SetFrozenFunction(thread, setFuncPrototype, "getFirstValue", ContainersTreeSet::GetFirstValue, FuncLength::ZERO);
584 SetFrozenFunction(thread, setFuncPrototype, "getLastValue", ContainersTreeSet::GetLastValue, FuncLength::ZERO);
585 SetFrozenFunction(thread, setFuncPrototype, "clear", ContainersTreeSet::Clear, FuncLength::ZERO);
586 SetFrozenFunction(thread, setFuncPrototype, "getLowerValue", ContainersTreeSet::GetLowerValue, FuncLength::ONE);
587 SetFrozenFunction(thread, setFuncPrototype, "getHigherValue", ContainersTreeSet::GetHigherValue, FuncLength::ONE);
588 SetFrozenFunction(thread, setFuncPrototype, "popFirst", ContainersTreeSet::PopFirst, FuncLength::ZERO);
589 SetFrozenFunction(thread, setFuncPrototype, "popLast", ContainersTreeSet::PopLast, FuncLength::ZERO);
590 SetFrozenFunction(thread, setFuncPrototype, "isEmpty", ContainersTreeSet::IsEmpty, FuncLength::TWO);
591 SetFrozenFunction(thread, setFuncPrototype, "values", ContainersTreeSet::Values, FuncLength::ZERO);
592 SetFrozenFunction(thread, setFuncPrototype, "forEach", ContainersTreeSet::ForEach, FuncLength::ONE);
593 SetFrozenFunction(thread, setFuncPrototype, "entries", ContainersTreeSet::Entries, FuncLength::ZERO);
596 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
597 SetStringTagSymbol(thread, env, setFuncPrototype, "TreeSet");
600 JSHandle<JSTaggedValue> values(thread, globalConst->GetValuesString());
602 JSObject::GetMethod(thread, JSHandle<JSTaggedValue>::Cast(setFuncPrototype), values);
603 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
604 PropertyDescriptor descriptor(thread, valuesFunc, false, false, false);
605 JSObject::DefineOwnProperty(thread, setFuncPrototype, iteratorSymbol, descriptor);
608 CreateGetter(thread, ContainersTreeSet::GetLength, "length", FuncLength::ZERO);
609 JSHandle<JSTaggedValue> lengthKey(thread, globalConst->GetLengthString());
610 SetGetter(thread, setFuncPrototype, lengthKey, lengthGetter);
612 InitializeTreeSetIterator(thread);
616 void ContainersPrivate::InitializeTreeSetIterator(JSThread *thread)
618 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
619 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
627 SetFrozenFunction(thread, setIteratorPrototype, "next", JSAPITreeSetIterator::Next, FuncLength::ZERO);
628 SetStringTagSymbol(thread, env, setIteratorPrototype, "TreeSet Iterator");
629 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
633 JSHandle<JSTaggedValue> ContainersPrivate::InitializePlainArray(JSThread *thread)
635 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
636 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
644 NewContainerConstructor(thread, plainArrayFuncPrototype, ContainersPlainArray::PlainArrayConstructor,
646 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
651 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(plainArrayFuncPrototype), constructorKey,
653 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
655 SetFrozenFunction(thread, plainArrayFuncPrototype, "add", ContainersPlainArray::Add, FuncLength::ONE);
656 SetFrozenFunction(thread, plainArrayFuncPrototype, "clear", ContainersPlainArray::Clear, FuncLength::ONE);
657 SetFrozenFunction(thread, plainArrayFuncPrototype, "clone", ContainersPlainArray::Clone, FuncLength::ONE);
658 SetFrozenFunction(thread, plainArrayFuncPrototype, "has", ContainersPlainArray::Has, FuncLength::ONE);
659 SetFrozenFunction(thread, plainArrayFuncPrototype, "get", ContainersPlainArray::Get, FuncLength::ONE);
660 SetFrozenFunction(thread, plainArrayFuncPrototype, "forEach", ContainersPlainArray::ForEach, FuncLength::ONE,
662 SetFrozenFunction(thread, plainArrayFuncPrototype, "toString", ContainersPlainArray::ToString,
664 SetFrozenFunction(thread, plainArrayFuncPrototype, "getIndexOfKey", ContainersPlainArray::GetIndexOfKey,
666 SetFrozenFunction(thread, plainArrayFuncPrototype, "getIndexOfValue", ContainersPlainArray::GetIndexOfValue,
668 SetFrozenFunction(thread, plainArrayFuncPrototype, "isEmpty", ContainersPlainArray::IsEmpty, FuncLength::ZERO);
669 SetFrozenFunction(thread, plainArrayFuncPrototype, "getKeyAt",
671 SetFrozenFunction(thread, plainArrayFuncPrototype, "remove", ContainersPlainArray::Remove, FuncLength::ZERO);
672 SetFrozenFunction(thread, plainArrayFuncPrototype, "removeAt", ContainersPlainArray::RemoveAt,
674 SetFrozenFunction(thread, plainArrayFuncPrototype, "removeRangeFrom", ContainersPlainArray::RemoveRangeFrom,
676 SetFrozenFunction(thread, plainArrayFuncPrototype, "setValueAt", ContainersPlainArray::SetValueAt,
678 SetFrozenFunction(thread, plainArrayFuncPrototype, "getValueAt", ContainersPlainArray::GetValueAt,
681 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(thread, ContainersPlainArray::GetSize, "length",
684 SetGetter(thread, plainArrayFuncPrototype, lengthKey, lengthGetter);
686 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
687 SetFunctionAtSymbol(thread, env, plainArrayFuncPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
689 InitializePlainArrayIterator(thread);
694 void ContainersPrivate::InitializePlainArrayIterator(JSThread *thread)
696 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
697 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
698 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
700 JSHandle<JSHClass>(thread, globalConst->GetHandledJSAPIIteratorFuncHClass().GetObject<JSHClass>());
702 SetFrozenFunction(thread, plainarrayIteratorPrototype, "next", JSAPIPlainArrayIterator::Next, FuncLength::ONE);
703 SetStringTagSymbol(thread, env, plainarrayIteratorPrototype, "PlainArray Iterator");
708 JSHandle<JSTaggedValue> ContainersPrivate::InitializeStack(JSThread *thread)
710 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
711 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
720 thread, stackFuncPrototype, ContainersStack::StackConstructor, "Stack", FuncLength::ZERO));
721 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
726 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(stackFuncPrototype), constructorKey, stackFunction);
727 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
729 SetFrozenFunction(thread, stackFuncPrototype, "push", ContainersStack::Push, FuncLength::ONE);
731 SetFrozenFunction(thread, stackFuncPrototype, "isEmpty", ContainersStack::IsEmpty, FuncLength::ONE);
733 SetFrozenFunction(thread, stackFuncPrototype, "peek", ContainersStack::Peek, FuncLength::ONE);
735 SetFrozenFunction(thread, stackFuncPrototype, "pop", ContainersStack::Pop, FuncLength::ONE);
737 SetFrozenFunction(thread, stackFuncPrototype, "locate", ContainersStack::Locate, FuncLength::ONE);
739 SetFrozenFunction(thread, stackFuncPrototype, "forEach", ContainersStack::ForEach, FuncLength::ONE,
741 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
742 SetStringTagSymbol(thread, env, stackFuncPrototype, "Stack");
744 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(thread, ContainersStack::GetLength, "length", FuncLength::ZERO);
746 SetGetter(thread, stackFuncPrototype, lengthKey, lengthGetter);
748 SetFunctionAtSymbol(thread, env, stackFuncPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
751 ContainersPrivate::InitializeStackIterator(thread, globalConst);
755 void ContainersPrivate::InitializeStackIterator(JSThread *thread, GlobalEnvConstants *globalConst)
757 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
758 JSHandle<JSHClass> iteratorFuncHClass = JSHandle<JSHClass>(thread, globalConst->
763 SetFrozenFunction(thread, stackIteratorPrototype, "next", JSAPIStackIterator::Next, FuncLength::ONE);
767 JSHandle<JSTaggedValue> ContainersPrivate::InitializeVector(JSThread *thread)
769 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
770 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
779 thread, prototype, ContainersVector::VectorConstructor, "Vector", FuncLength::ZERO));
780 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
785 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(prototype), constructorKey, vectorFunction);
786 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
788 SetFrozenFunction(thread, prototype, "add", ContainersVector::Add, FuncLength::ONE);
789 SetFrozenFunction(thread, prototype, "insert", ContainersVector::Insert, FuncLength::TWO);
790 SetFrozenFunction(thread, prototype, "setLength", ContainersVector::SetLength, FuncLength::ONE);
791 SetFrozenFunction(thread, prototype, "getCapacity", ContainersVector::GetCapacity, FuncLength::ZERO);
792 SetFrozenFunction(thread, prototype, "increaseCapacityTo", ContainersVector::IncreaseCapacityTo, FuncLength::ONE);
793 SetFrozenFunction(thread, prototype, "get", ContainersVector::Get, FuncLength::ONE);
794 SetFrozenFunction(thread, prototype, "getIndexOf", ContainersVector::GetIndexOf, FuncLength::ONE);
795 SetFrozenFunction(thread, prototype, "getIndexFrom", ContainersVector::GetIndexFrom, FuncLength::TWO);
796 SetFrozenFunction(thread, prototype, "isEmpty", ContainersVector::IsEmpty, FuncLength::ZERO);
797 SetFrozenFunction(thread, prototype, "getLastElement", ContainersVector::GetLastElement, FuncLength::ZERO);
798 SetFrozenFunction(thread, prototype, "getLastIndexOf", ContainersVector::GetLastIndexOf, FuncLength::ONE);
799 SetFrozenFunction(thread, prototype, "getLastIndexFrom", ContainersVector::GetLastIndexFrom, FuncLength::TWO);
800 SetFrozenFunction(thread, prototype, "remove", ContainersVector::Remove, FuncLength::ONE);
801 SetFrozenFunction(thread, prototype, "removeByIndex", ContainersVector::RemoveByIndex, FuncLength::ONE);
802 SetFrozenFunction(thread, prototype, "removeByRange", ContainersVector::RemoveByRange, FuncLength::TWO);
803 SetFrozenFunction(thread, prototype, "set", ContainersVector::Set, FuncLength::TWO);
804 SetFrozenFunction(thread, prototype, "subVector", ContainersVector::SubVector, FuncLength::TWO);
805 SetFrozenFunction(thread, prototype, "toString", ContainersVector::ToString, FuncLength::ZERO);
806 SetFrozenFunction(thread, prototype, "forEach", ContainersVector::ForEach, FuncLength::TWO,
808 SetFrozenFunction(thread, prototype, "replaceAllElements", ContainersVector::ReplaceAllElements, FuncLength::TWO,
810 SetFrozenFunction(thread, prototype, "has", ContainersVector::Has, FuncLength::ONE);
811 SetFrozenFunction(thread, prototype, "sort", ContainersVector::Sort, FuncLength::ZERO);
812 SetFrozenFunction(thread, prototype, "clear", ContainersVector::Clear, FuncLength::ZERO);
813 SetFrozenFunction(thread, prototype, "clone", ContainersVector::Clone, FuncLength::ZERO);
814 SetFrozenFunction(thread, prototype, "copyToArray", ContainersVector::CopyToArray, FuncLength::ONE);
815 SetFrozenFunction(thread, prototype, "convertToArray", ContainersVector::ConvertToArray, FuncLength::ZERO);
816 SetFrozenFunction(thread, prototype, "getFirstElement", ContainersVector::GetFirstElement, FuncLength::ZERO);
817 SetFrozenFunction(thread, prototype, "trimToCurrentLength",
820 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
821 SetStringTagSymbol(thread, env, prototype, "Vector");
823 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(thread, ContainersVector::GetSize, "length", FuncLength::ZERO);
824 JSHandle<JSTaggedValue> lengthKey(thread, globalConst->GetLengthString());
825 SetGetter(thread, prototype, lengthKey, lengthGetter);
827 SetFunctionAtSymbol(thread, env, prototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
830 ContainersPrivate::InitializeVectorIterator(thread, env, globalConst);
835 void ContainersPrivate::InitializeVectorIterator(JSThread *thread, const JSHandle<GlobalEnv> &env,
838 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
839 JSHandle<JSHClass> iteratorFuncHClass = JSHandle<JSHClass>(thread, globalConst->
844 SetFrozenFunction(thread, vectorIteratorPrototype, "next", JSAPIVectorIterator::Next, FuncLength::ONE);
845 SetStringTagSymbol(thread, env, vectorIteratorPrototype, "Vector Iterator");
849 JSHandle<JSTaggedValue> ContainersPrivate::InitializeBitVector(JSThread* thread)
851 auto globalConst = const_cast<GlobalEnvConstants*>(thread->GlobalConstants());
852 ObjectFactory* factory = thread->GetEcmaVM()->GetFactory();
861 thread, prototype, ContainersBitVector::BitVectorConstructor, "BitVector", FuncLength::ONE));
863 thread, JSHandle<JSFunction>::Cast(bitVectorFunction), bitVectorInstanceClass.GetTaggedValue());
867 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(prototype), constructorKey, bitVectorFunction);
868 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
871 SetFrozenFunction(thread, prototype, "push", ContainersBitVector::Push, FuncLength::ONE);
872 SetFrozenFunction(thread, prototype, "pop", ContainersBitVector::Pop, FuncLength::ZERO);
873 SetFrozenFunction(thread, prototype, "has", ContainersBitVector::Has, FuncLength::THREE);
874 SetFrozenFunction(thread, prototype, "setBitsByRange", ContainersBitVector::SetBitsByRange, FuncLength::THREE);
875 SetFrozenFunction(thread, prototype, "getBitsByRange", ContainersBitVector::GetBitsByRange, FuncLength::TWO);
876 SetFrozenFunction(thread, prototype, "setAllBits", ContainersBitVector::SetAllBits, FuncLength::ONE);
877 SetFrozenFunction(thread, prototype, "resize", ContainersBitVector::Resize, FuncLength::ONE);
879 thread, prototype, "getBitCountByRange", ContainersBitVector::GetBitCountByRange, FuncLength::THREE);
880 SetFrozenFunction(thread, prototype, "getIndexOf", ContainersBitVector::GetIndexOf, FuncLength::THREE);
881 SetFrozenFunction(thread, prototype, "getLastIndexOf", ContainersBitVector::GetLastIndexOf, FuncLength::THREE);
882 SetFrozenFunction(thread, prototype, "flipBitByIndex", ContainersBitVector::FlipBitByIndex, FuncLength::ONE);
883 SetFrozenFunction(thread, prototype, "flipBitsByRange", ContainersBitVector::FlipBitsByRange, FuncLength::TWO);
884 SetFrozenFunction(thread, prototype, "values", ContainersBitVector::GetIteratorObj, FuncLength::ZERO);
886 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
887 SetStringTagSymbol(thread, env, prototype, "BitVector");
890 CreateGetter(thread, ContainersBitVector::GetSize, "length", FuncLength::ZERO);
891 JSHandle<JSTaggedValue> lengthKey(thread, globalConst->GetLengthString());
892 SetGetter(thread, prototype, lengthKey, lengthGetter);
894 SetFunctionAtSymbol(thread, env, prototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
896 ContainersPrivate::InitializeBitVectorIterator(thread, env, globalConst);
903 JSThread* thread, const JSHandle<GlobalEnv>& env, GlobalEnvConstants* globalConst)
905 ObjectFactory* factory = thread->GetEcmaVM()->GetFactory();
907 JSHandle<JSHClass>(thread, globalConst->GetHandledJSAPIIteratorFuncHClass().GetObject<JSHClass>());
911 SetFrozenFunction(thread, bitVectorIteratorPrototype, "next", JSAPIBitVectorIterator::Next, FuncLength::ONE);
912 SetStringTagSymbol(thread, env, bitVectorIteratorPrototype, "BitVector Iterator");
917 JSHandle<JSTaggedValue> ContainersPrivate::InitializeQueue(JSThread *thread)
919 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
920 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
929 thread, queueFuncPrototype, ContainersQueue::QueueConstructor, "Queue", FuncLength::ZERO));
930 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
935 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(queueFuncPrototype), constructorKey, queueFunction);
936 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
938 SetFrozenFunction(thread, queueFuncPrototype, "add", ContainersQueue::Add, FuncLength::ONE);
939 SetFrozenFunction(thread, queueFuncPrototype, "getFirst", ContainersQueue::GetFirst, FuncLength::ZERO);
940 SetFrozenFunction(thread, queueFuncPrototype, "pop", ContainersQueue::Pop, FuncLength::ZERO);
941 SetFrozenFunction(thread, queueFuncPrototype, "forEach", ContainersQueue::ForEach, FuncLength::TWO,
944 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
945 SetStringTagSymbol(thread, env, queueFuncPrototype, "Queue");
947 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(thread, ContainersQueue::GetSize, "length", FuncLength::ZERO);
948 JSHandle<JSTaggedValue> lengthKey(thread, globalConst->GetLengthString());
949 SetGetter(thread, queueFuncPrototype, lengthKey, lengthGetter);
951 SetFunctionAtSymbol(thread, env, queueFuncPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
954 ContainersPrivate::InitializeQueueIterator(thread, env, globalConst);
958 void ContainersPrivate::InitializeQueueIterator(JSThread *thread, const JSHandle<GlobalEnv> &env,
961 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
967 SetFrozenFunction(thread, queueIteratorPrototype, "next", JSAPIQueueIterator::Next, FuncLength::ONE);
968 SetStringTagSymbol(thread, env, queueIteratorPrototype, "Queue Iterator");
972 JSHandle<JSTaggedValue> ContainersPrivate::InitializeDeque(JSThread *thread)
974 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
975 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
984 thread, dequeFuncPrototype, ContainersDeque::DequeConstructor, "Deque", FuncLength::ZERO));
985 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
990 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(dequeFuncPrototype), constructorKey, dequeFunction);
991 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
992 SetFrozenFunction(thread, dequeFuncPrototype, "insertFront", ContainersDeque::InsertFront, FuncLength::ONE);
993 SetFrozenFunction(thread, dequeFuncPrototype, "insertEnd", ContainersDeque::InsertEnd, FuncLength::ONE);
994 SetFrozenFunction(thread, dequeFuncPrototype, "getFirst", ContainersDeque::GetFirst, FuncLength::ZERO);
995 SetFrozenFunction(thread, dequeFuncPrototype, "getLast", ContainersDeque::GetLast, FuncLength::ZERO);
996 SetFrozenFunction(thread, dequeFuncPrototype, "has", ContainersDeque::Has, FuncLength::ONE);
997 SetFrozenFunction(thread, dequeFuncPrototype, "popFirst", ContainersDeque::PopFirst, FuncLength::ZERO);
998 SetFrozenFunction(thread, dequeFuncPrototype, "popLast", ContainersDeque::PopLast, FuncLength::ZERO);
999 SetFrozenFunction(thread, dequeFuncPrototype, "forEach", ContainersDeque::ForEach, FuncLength::TWO,
1002 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1003 SetStringTagSymbol(thread, env, dequeFuncPrototype, "Deque");
1005 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(thread, ContainersDeque::GetSize, "length", FuncLength::ZERO);
1007 SetGetter(thread, dequeFuncPrototype, lengthKey, lengthGetter);
1009 SetFunctionAtSymbol(thread, env, dequeFuncPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
1012 ContainersPrivate::InitializeDequeIterator(thread, env, globalConst);
1017 void ContainersPrivate::InitializeDequeIterator(JSThread *thread, const JSHandle<GlobalEnv> &env,
1020 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1021 JSHandle<JSHClass> iteratorFuncHClass = JSHandle<JSHClass>(thread, globalConst->
1024 SetFrozenFunction(thread, dequeIteratorPrototype, "next", JSAPIDequeIterator::Next, FuncLength::ONE);
1025 SetStringTagSymbol(thread, env, dequeIteratorPrototype, "Deque Iterator");
1029 JSHandle<JSTaggedValue> ContainersPrivate::InitializeList(JSThread *thread)
1031 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
1032 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1038 thread, listFuncPrototype, ContainersList::ListConstructor, "List", FuncLength::ZERO));
1039 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
1043 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(listFuncPrototype), constructorKey, listFunction);
1044 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
1045 SetFrozenFunction(thread, listFuncPrototype, "add", ContainersList::Add, FuncLength::ONE);
1046 SetFrozenFunction(thread, listFuncPrototype, "getFirst", ContainersList::GetFirst, FuncLength::ONE);
1047 SetFrozenFunction(thread, listFuncPrototype, "getLast", ContainersList::GetLast, FuncLength::ONE);
1048 SetFrozenFunction(thread, listFuncPrototype, "insert", ContainersList::Insert, FuncLength::ONE);
1049 SetFrozenFunction(thread, listFuncPrototype, "clear", ContainersList::Clear, FuncLength::ONE);
1050 SetFrozenFunction(thread, listFuncPrototype, "removeByIndex", ContainersList::RemoveByIndex, FuncLength::ONE);
1051 SetFrozenFunction(thread, listFuncPrototype, "remove", ContainersList::Remove, FuncLength::ONE);
1052 SetFrozenFunction(thread, listFuncPrototype, "has", ContainersList::Has, FuncLength::ONE);
1053 SetFrozenFunction(thread, listFuncPrototype, "isEmpty", ContainersList::IsEmpty, FuncLength::ONE);
1054 SetFrozenFunction(thread, listFuncPrototype, "get", ContainersList::Get, FuncLength::ONE);
1055 SetFrozenFunction(thread, listFuncPrototype, "getIndexOf", ContainersList::GetIndexOf, FuncLength::ONE);
1056 SetFrozenFunction(thread, listFuncPrototype, "getLastIndexOf", ContainersList::GetLastIndexOf, FuncLength::ONE);
1057 SetFrozenFunction(thread, listFuncPrototype, "set", ContainersList::Set, FuncLength::ONE);
1058 SetFrozenFunction(thread, listFuncPrototype, "forEach", ContainersList::ForEach, FuncLength::ONE,
1060 SetFrozenFunction(thread, listFuncPrototype, "replaceAllElements", ContainersList::ReplaceAllElements,
1062 SetFrozenFunction(thread, listFuncPrototype, "equal", ContainersList::Equal, FuncLength::ONE);
1063 SetFrozenFunction(thread, listFuncPrototype, "sort", ContainersList::Sort, FuncLength::ONE);
1064 SetFrozenFunction(thread, listFuncPrototype, "convertToArray", ContainersList::ConvertToArray, FuncLength::ONE);
1065 SetFrozenFunction(thread, listFuncPrototype, "getSubList", ContainersList::GetSubList, FuncLength::ONE);
1067 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(thread, ContainersList::Length, "length", FuncLength::ZERO);
1069 SetGetter(thread, listFuncPrototype, lengthKey, lengthGetter);
1071 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1072 SetFunctionAtSymbol(thread, env, listFuncPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
1075 InitializeListIterator(thread, env);
1080 JSHandle<JSTaggedValue> ContainersPrivate::InitializeLinkedList(JSThread *thread)
1082 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
1083 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1089 thread, linkedListFuncPrototype, ContainersLinkedList::LinkedListConstructor, "LinkedList", FuncLength::ZERO));
1090 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
1094 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(linkedListFuncPrototype), constructorKey, linkedListFunction);
1095 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
1096 SetFrozenFunction(thread, linkedListFuncPrototype, "add", ContainersLinkedList::Add, FuncLength::ONE);
1097 SetFrozenFunction(thread, linkedListFuncPrototype, "insert", ContainersLinkedList::Insert, FuncLength::ONE);
1098 SetFrozenFunction(thread, linkedListFuncPrototype, "clear", ContainersLinkedList::Clear, FuncLength::ONE);
1099 SetFrozenFunction(thread, linkedListFuncPrototype, "clone", ContainersLinkedList::Clone, FuncLength::ONE);
1100 SetFrozenFunction(thread, linkedListFuncPrototype, "removeFirst", ContainersLinkedList::RemoveFirst,
1102 SetFrozenFunction(thread, linkedListFuncPrototype, "removeLast", ContainersLinkedList::RemoveLast, FuncLength::ONE);
1103 SetFrozenFunction(thread, linkedListFuncPrototype, "removeFirstFound", ContainersLinkedList::RemoveFirstFound,
1105 SetFrozenFunction(thread, linkedListFuncPrototype, "removeByIndex", ContainersLinkedList::RemoveByIndex,
1107 SetFrozenFunction(thread, linkedListFuncPrototype, "remove", ContainersLinkedList::Remove, FuncLength::ONE);
1108 SetFrozenFunction(thread, linkedListFuncPrototype, "removeLastFound", ContainersLinkedList::RemoveLastFound,
1110 SetFrozenFunction(thread, linkedListFuncPrototype, "has", ContainersLinkedList::Has, FuncLength::ONE);
1111 SetFrozenFunction(thread, linkedListFuncPrototype, "get", ContainersLinkedList::Get, FuncLength::ONE);
1112 SetFrozenFunction(thread, linkedListFuncPrototype, "addFirst", ContainersLinkedList::AddFirst, FuncLength::ONE);
1113 SetFrozenFunction(thread, linkedListFuncPrototype, "getFirst", ContainersLinkedList::GetFirst, FuncLength::ONE);
1114 SetFrozenFunction(thread, linkedListFuncPrototype, "getLast", ContainersLinkedList::GetLast, FuncLength::ONE);
1115 SetFrozenFunction(thread, linkedListFuncPrototype, "getIndexOf", ContainersLinkedList::GetIndexOf, FuncLength::ONE);
1116 SetFrozenFunction(thread, linkedListFuncPrototype, "getLastIndexOf", ContainersLinkedList::GetLastIndexOf,
1118 SetFrozenFunction(thread, linkedListFuncPrototype, "convertToArray", ContainersLinkedList::ConvertToArray,
1120 SetFrozenFunction(thread, linkedListFuncPrototype, "set", ContainersLinkedList::Set, FuncLength::ONE);
1121 SetFrozenFunction(thread, linkedListFuncPrototype, "forEach", ContainersLinkedList::ForEach, FuncLength::ONE,
1124 JSHandle<JSTaggedValue> lengthGetter = CreateGetter(thread, ContainersLinkedList::Length, "length",
1127 SetGetter(thread, linkedListFuncPrototype, lengthKey, lengthGetter);
1129 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1130 SetFunctionAtSymbol(thread, env, linkedListFuncPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
1133 InitializeLinkedListIterator(thread, env);
1138 void ContainersPrivate::InitializeLinkedListIterator(JSThread *thread, const JSHandle<GlobalEnv> &env)
1140 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
1141 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1143 JSHandle<JSHClass>(thread, globalConst->GetHandledJSAPIIteratorFuncHClass().GetObject<JSHClass>());
1145 SetFrozenFunction(thread, setIteratorPrototype, "next", JSAPILinkedListIterator::Next, FuncLength::ONE);
1146 SetStringTagSymbol(thread, env, setIteratorPrototype, "linkedlist Iterator");
1151 void ContainersPrivate::InitializeListIterator(JSThread *thread, const JSHandle<GlobalEnv> &env)
1153 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
1154 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1156 JSHandle<JSHClass>(thread, globalConst->GetHandledJSAPIIteratorFuncHClass().GetObject<JSHClass>());
1158 SetFrozenFunction(thread, setIteratorPrototype, "next", JSAPIListIterator::Next, FuncLength::ONE);
1159 SetStringTagSymbol(thread, env, setIteratorPrototype, "list Iterator");
1163 JSHandle<JSTaggedValue> ContainersPrivate::InitializeHashMap(JSThread *thread)
1165 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1166 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1175 thread, hashMapFuncPrototype, ContainersHashMap::HashMapConstructor, "HashMap", FuncLength::ZERO));
1176 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
1181 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(hashMapFuncPrototype), constructorKey, hashMapFunction);
1182 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
1184 SetFrozenFunction(thread, hashMapFuncPrototype, "set", ContainersHashMap::Set, FuncLength::TWO);
1186 SetFrozenFunction(thread, hashMapFuncPrototype, "setAll", ContainersHashMap::SetAll, FuncLength::ONE);
1188 SetFrozenFunction(thread, hashMapFuncPrototype, "isEmpty", ContainersHashMap::IsEmpty, FuncLength::ZERO);
1190 SetFrozenFunction(thread, hashMapFuncPrototype, "remove", ContainersHashMap::Remove, FuncLength::ONE);
1192 SetFrozenFunction(thread, hashMapFuncPrototype, "clear", ContainersHashMap::Clear, FuncLength::ZERO);
1194 SetFrozenFunction(thread, hashMapFuncPrototype, "get", ContainersHashMap::Get, FuncLength::ONE);
1196 SetFrozenFunction(thread, hashMapFuncPrototype, "forEach", ContainersHashMap::ForEach, FuncLength::TWO,
1199 SetFrozenFunction(thread, hashMapFuncPrototype, "hasKey", ContainersHashMap::HasKey, FuncLength::ONE);
1201 SetFrozenFunction(thread, hashMapFuncPrototype, "hasValue", ContainersHashMap::HasValue, FuncLength::ONE);
1203 SetFrozenFunction(thread, hashMapFuncPrototype, "replace", ContainersHashMap::Replace, FuncLength::TWO);
1205 SetFrozenFunction(thread, hashMapFuncPrototype, "keys", ContainersHashMap::Keys, FuncLength::ZERO);
1207 SetFrozenFunction(thread, hashMapFuncPrototype, "values", ContainersHashMap::Values, FuncLength::ZERO);
1209 SetFrozenFunction(thread, hashMapFuncPrototype, "entries", ContainersHashMap::Entries, FuncLength::ZERO);
1210 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1212 SetStringTagSymbol(thread, env, hashMapFuncPrototype, "HashMap");
1214 SetFunctionAtSymbol(thread, env, hashMapFuncPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
1218 CreateGetter(thread, ContainersHashMap::GetLength, "length", FuncLength::ZERO);
1219 JSHandle<JSTaggedValue> lengthKey(thread, globalConst->GetLengthString());
1220 SetGetter(thread, hashMapFuncPrototype, lengthKey, lengthGetter);
1221 InitializeHashMapIterator(thread);
1225 void ContainersPrivate::InitializeHashMapIterator(JSThread *thread)
1227 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1228 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
1229 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1235 SetFrozenFunction(thread, hashMapIteratorPrototype, "next", JSAPIHashMapIterator::Next, FuncLength::ZERO);
1236 SetStringTagSymbol(thread, env, hashMapIteratorPrototype, "HashMap Iterator");
1242 JSHandle<JSTaggedValue> ContainersPrivate::InitializeHashSet(JSThread *thread)
1244 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1245 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1254 thread, hashSetFuncPrototype, ContainersHashSet::HashSetConstructor, "HashSet", FuncLength::ZERO));
1255 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread,
1260 JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(hashSetFuncPrototype), constructorKey, hashSetFunction);
1261 RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
1262 SetFrozenFunction(thread, hashSetFuncPrototype, "isEmpty", ContainersHashSet::IsEmpty, FuncLength::ZERO);
1263 SetFrozenFunction(thread, hashSetFuncPrototype, "has", ContainersHashSet::Has, FuncLength::ONE);
1264 SetFrozenFunction(thread, hashSetFuncPrototype, "add", ContainersHashSet::Add, FuncLength::ONE);
1265 SetFrozenFunction(thread, hashSetFuncPrototype, "has", ContainersHashSet::Has, FuncLength::ONE);
1266 SetFrozenFunction(thread, hashSetFuncPrototype, "remove", ContainersHashSet::Remove, FuncLength::ONE);
1267 SetFrozenFunction(thread, hashSetFuncPrototype, "clear", ContainersHashSet::Clear, FuncLength::ZERO);
1268 SetFrozenFunction(thread, hashSetFuncPrototype, "values", ContainersHashSet::Values, FuncLength::ZERO);
1269 SetFrozenFunction(thread, hashSetFuncPrototype, "entries", ContainersHashSet::Entries, FuncLength::ZERO);
1270 SetFrozenFunction(thread, hashSetFuncPrototype, "forEach", ContainersHashSet::ForEach, FuncLength::TWO,
1273 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1275 SetStringTagSymbol(thread, env, hashSetFuncPrototype, "HashSet");
1277 SetFunctionAtSymbol(thread, env, hashSetFuncPrototype, env->GetIteratorSymbol(), "[Symbol.iterator]",
1281 CreateGetter(thread, ContainersHashSet::GetLength, "length", FuncLength::ZERO);
1282 JSHandle<JSTaggedValue> lengthKey(thread, globalConst->GetLengthString());
1283 SetGetter(thread, hashSetFuncPrototype, lengthKey, lengthGetter);
1284 InitializeHashSetIterator(thread);
1288 void ContainersPrivate::InitializeHashSetIterator(JSThread *thread)
1290 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1291 auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
1292 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1299 SetFrozenFunction(thread, hashSetIteratorPrototype, "next", JSAPIHashSetIterator::Next, FuncLength::ZERO);
1300 SetStringTagSymbol(thread, env, hashSetIteratorPrototype, "HashSet Iterator");