14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#include "ecmascript/containers/containers_bitvector.h" 174514f5e3Sopenharmony_ci 184514f5e3Sopenharmony_ci#include "ecmascript/containers/containers_errors.h" 194514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_bitvector.h" 204514f5e3Sopenharmony_ci#include "ecmascript/object_factory-inl.h" 214514f5e3Sopenharmony_cinamespace panda::ecmascript::containers { 224514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::BitVectorConstructor(EcmaRuntimeCallInfo* argv) 234514f5e3Sopenharmony_ci{ 244514f5e3Sopenharmony_ci ASSERT(argv); 254514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 264514f5e3Sopenharmony_ci BUILTINS_API_TRACE(thread, BitVector, Constructor); 274514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 284514f5e3Sopenharmony_ci 294514f5e3Sopenharmony_ci ObjectFactory* factory = thread->GetEcmaVM()->GetFactory(); 304514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> newTarget = GetNewTarget(argv); 314514f5e3Sopenharmony_ci if (newTarget->IsUndefined()) { 324514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError( 334514f5e3Sopenharmony_ci thread, ErrorFlag::IS_NULL_ERROR, "The BitVector's constructor cannot be directly invoked."); 344514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 354514f5e3Sopenharmony_ci } 364514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> constructor = GetConstructor(argv); 374514f5e3Sopenharmony_ci JSHandle<JSAPIBitVector> obj = 384514f5e3Sopenharmony_ci JSHandle<JSAPIBitVector>(factory->NewJSObjectByConstructor(JSHandle<JSFunction>(constructor), newTarget)); 394514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 404514f5e3Sopenharmony_ci 414514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> length = GetCallArg(argv, 0); 424514f5e3Sopenharmony_ci if (!length->IsInteger()) { 434514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, length); 444514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 454514f5e3Sopenharmony_ci CString errorMsg = "The type of \"length\" must be integer. Received value is: " + ConvertToString(*result); 464514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 474514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 484514f5e3Sopenharmony_ci } 494514f5e3Sopenharmony_ci 504514f5e3Sopenharmony_ci auto* newBitSetVector = new std::vector<std::bitset<JSAPIBitVector::BIT_SET_LENGTH>>(); 514514f5e3Sopenharmony_ci if (!length->IsZero()) { 524514f5e3Sopenharmony_ci int32_t capacity = (length->GetInt() / JSAPIBitVector::BIT_SET_LENGTH) + 1; 534514f5e3Sopenharmony_ci 544514f5e3Sopenharmony_ci std::bitset<JSAPIBitVector::BIT_SET_LENGTH> initBitSet; 554514f5e3Sopenharmony_ci newBitSetVector->resize(capacity, initBitSet); 564514f5e3Sopenharmony_ci } 574514f5e3Sopenharmony_ci JSHandle<JSNativePointer> pointer = factory->NewJSNativePointer(newBitSetVector, 584514f5e3Sopenharmony_ci ContainersBitVector::FreeBitsetVectorPointer); 594514f5e3Sopenharmony_ci obj->SetNativePointer(thread, pointer); 604514f5e3Sopenharmony_ci obj->SetLength(length->GetInt()); 614514f5e3Sopenharmony_ci return obj.GetTaggedValue(); 624514f5e3Sopenharmony_ci} 634514f5e3Sopenharmony_ci 644514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::Push(EcmaRuntimeCallInfo* argv) 654514f5e3Sopenharmony_ci{ 664514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, Push); 674514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 684514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 694514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 704514f5e3Sopenharmony_ci 714514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 724514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 734514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 744514f5e3Sopenharmony_ci } else { 754514f5e3Sopenharmony_ci JSTaggedValue error = 764514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, ErrorFlag::BIND_ERROR, "The push method cannot be bound"); 774514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 784514f5e3Sopenharmony_ci } 794514f5e3Sopenharmony_ci } 804514f5e3Sopenharmony_ci 814514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value = GetCallArg(argv, 0); 824514f5e3Sopenharmony_ci return GetTaggedBoolean(JSAPIBitVector::Push(thread, JSHandle<JSAPIBitVector>::Cast(self), value)); 834514f5e3Sopenharmony_ci} 844514f5e3Sopenharmony_ci 854514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::Pop(EcmaRuntimeCallInfo* argv) 864514f5e3Sopenharmony_ci{ 874514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, Pop); 884514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 894514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 904514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 914514f5e3Sopenharmony_ci 924514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 934514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 944514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 954514f5e3Sopenharmony_ci } else { 964514f5e3Sopenharmony_ci JSTaggedValue error = 974514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, ErrorFlag::BIND_ERROR, "The pop method cannot be bound"); 984514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 994514f5e3Sopenharmony_ci } 1004514f5e3Sopenharmony_ci } 1014514f5e3Sopenharmony_ci 1024514f5e3Sopenharmony_ci return JSHandle<JSAPIBitVector>::Cast(self)->Pop(thread, JSHandle<JSAPIBitVector>::Cast(self)); 1034514f5e3Sopenharmony_ci} 1044514f5e3Sopenharmony_ci 1054514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::Has(EcmaRuntimeCallInfo* argv) 1064514f5e3Sopenharmony_ci{ 1074514f5e3Sopenharmony_ci ASSERT(argv); 1084514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, Has); 1094514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 1104514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 1114514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 1124514f5e3Sopenharmony_ci 1134514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 1144514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 1154514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 1164514f5e3Sopenharmony_ci } else { 1174514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, BIND_ERROR, "The has method cannot be bound"); 1184514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 1194514f5e3Sopenharmony_ci } 1204514f5e3Sopenharmony_ci } 1214514f5e3Sopenharmony_ci 1224514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value = GetCallArg(argv, 0); 1234514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> startIndex = GetCallArg(argv, 1); 1244514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> endIndex = GetCallArg(argv, 2); // 2 means the third arg 1254514f5e3Sopenharmony_ci if (!startIndex->IsInteger()) { 1264514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, startIndex); 1274514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 1284514f5e3Sopenharmony_ci CString errorMsg = "The type of \"fromIndex\" must be integer. Received value is: " + ConvertToString(*result); 1294514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 1304514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 1314514f5e3Sopenharmony_ci } 1324514f5e3Sopenharmony_ci if (!endIndex->IsInteger()) { 1334514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, endIndex); 1344514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 1354514f5e3Sopenharmony_ci CString errorMsg = "The type of \"toIndex\" must be integer. Received value is: " + ConvertToString(*result); 1364514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 1374514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 1384514f5e3Sopenharmony_ci } 1394514f5e3Sopenharmony_ci bool isHas = JSHandle<JSAPIBitVector>::Cast(self)->Has( 1404514f5e3Sopenharmony_ci thread, JSHandle<JSAPIBitVector>::Cast(self), value, startIndex, endIndex); 1414514f5e3Sopenharmony_ci 1424514f5e3Sopenharmony_ci return GetTaggedBoolean(isHas); 1434514f5e3Sopenharmony_ci} 1444514f5e3Sopenharmony_ci 1454514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::SetBitsByRange(EcmaRuntimeCallInfo* argv) 1464514f5e3Sopenharmony_ci{ 1474514f5e3Sopenharmony_ci ASSERT(argv); 1484514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, SetBitsByRange); 1494514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 1504514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 1514514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 1524514f5e3Sopenharmony_ci 1534514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 1544514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 1554514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 1564514f5e3Sopenharmony_ci } else { 1574514f5e3Sopenharmony_ci JSTaggedValue error = 1584514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, BIND_ERROR, "The setBitsByRange method cannot be bound"); 1594514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 1604514f5e3Sopenharmony_ci } 1614514f5e3Sopenharmony_ci } 1624514f5e3Sopenharmony_ci 1634514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value = GetCallArg(argv, 0); 1644514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> startIndex = GetCallArg(argv, 1); 1654514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> endIndex = GetCallArg(argv, 2); // 2 means the third arg 1664514f5e3Sopenharmony_ci if (!startIndex->IsInteger()) { 1674514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, startIndex); 1684514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 1694514f5e3Sopenharmony_ci CString errorMsg = "The type of \"fromIndex\" must be integer. Received value is: " + ConvertToString(*result); 1704514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 1714514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 1724514f5e3Sopenharmony_ci } 1734514f5e3Sopenharmony_ci if (!endIndex->IsInteger()) { 1744514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, endIndex); 1754514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 1764514f5e3Sopenharmony_ci CString errorMsg = "The type of \"toIndex\" must be integer. Received value is: " + ConvertToString(*result); 1774514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 1784514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 1794514f5e3Sopenharmony_ci } 1804514f5e3Sopenharmony_ci JSHandle<JSAPIBitVector>::Cast(self)->SetBitsByRange( 1814514f5e3Sopenharmony_ci thread, JSHandle<JSAPIBitVector>::Cast(self), value, startIndex, endIndex); 1824514f5e3Sopenharmony_ci return JSTaggedValue::Undefined(); 1834514f5e3Sopenharmony_ci} 1844514f5e3Sopenharmony_ci 1854514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::GetBitsByRange(EcmaRuntimeCallInfo* argv) 1864514f5e3Sopenharmony_ci{ 1874514f5e3Sopenharmony_ci ASSERT(argv); 1884514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, GetBitsByRange); 1894514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 1904514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 1914514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 1924514f5e3Sopenharmony_ci 1934514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 1944514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 1954514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 1964514f5e3Sopenharmony_ci } else { 1974514f5e3Sopenharmony_ci JSTaggedValue error = 1984514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, BIND_ERROR, "The getBitsByRange method cannot be bound"); 1994514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 2004514f5e3Sopenharmony_ci } 2014514f5e3Sopenharmony_ci } 2024514f5e3Sopenharmony_ci 2034514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> startIndex = GetCallArg(argv, 0); 2044514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> endIndex = GetCallArg(argv, 1); 2054514f5e3Sopenharmony_ci if (!startIndex->IsInteger()) { 2064514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, startIndex); 2074514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 2084514f5e3Sopenharmony_ci CString errorMsg = "The type of \"fromIndex\" must be integer. Received value is: " + ConvertToString(*result); 2094514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 2104514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 2114514f5e3Sopenharmony_ci } 2124514f5e3Sopenharmony_ci if (!endIndex->IsInteger()) { 2134514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, endIndex); 2144514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 2154514f5e3Sopenharmony_ci CString errorMsg = "The type of \"toIndex\" must be integer. Received value is: " + ConvertToString(*result); 2164514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 2174514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 2184514f5e3Sopenharmony_ci } 2194514f5e3Sopenharmony_ci return JSHandle<JSAPIBitVector>::Cast(self)->GetBitsByRange( 2204514f5e3Sopenharmony_ci thread, JSHandle<JSAPIBitVector>::Cast(self), startIndex, endIndex); 2214514f5e3Sopenharmony_ci} 2224514f5e3Sopenharmony_ci 2234514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::Resize(EcmaRuntimeCallInfo* argv) 2244514f5e3Sopenharmony_ci{ 2254514f5e3Sopenharmony_ci ASSERT(argv); 2264514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, Resize); 2274514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 2284514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 2294514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 2304514f5e3Sopenharmony_ci 2314514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 2324514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 2334514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 2344514f5e3Sopenharmony_ci } else { 2354514f5e3Sopenharmony_ci JSTaggedValue error = 2364514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, BIND_ERROR, "The resize method cannot be bound"); 2374514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 2384514f5e3Sopenharmony_ci } 2394514f5e3Sopenharmony_ci } 2404514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> size = GetCallArg(argv, 0); 2414514f5e3Sopenharmony_ci if (!size->IsInteger()) { 2424514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, size); 2434514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 2444514f5e3Sopenharmony_ci CString errorMsg = "The type of \"size\" must be integer. Received value is: " + ConvertToString(*result); 2454514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 2464514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 2474514f5e3Sopenharmony_ci } 2484514f5e3Sopenharmony_ci JSHandle<JSAPIBitVector>::Cast(self)->Resize( 2494514f5e3Sopenharmony_ci thread, JSHandle<JSAPIBitVector>::Cast(self), JSTaggedValue::ToUint32(thread, size)); 2504514f5e3Sopenharmony_ci return JSTaggedValue::Undefined(); 2514514f5e3Sopenharmony_ci} 2524514f5e3Sopenharmony_ci 2534514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::SetAllBits(EcmaRuntimeCallInfo* argv) 2544514f5e3Sopenharmony_ci{ 2554514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, SetAllBits); 2564514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 2574514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 2584514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 2594514f5e3Sopenharmony_ci 2604514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 2614514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 2624514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 2634514f5e3Sopenharmony_ci } else { 2644514f5e3Sopenharmony_ci JSTaggedValue error = 2654514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, ErrorFlag::BIND_ERROR, "The setAllBits method cannot be bound"); 2664514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 2674514f5e3Sopenharmony_ci } 2684514f5e3Sopenharmony_ci } 2694514f5e3Sopenharmony_ci 2704514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value = GetCallArg(argv, 0); 2714514f5e3Sopenharmony_ci JSHandle<JSAPIBitVector>::Cast(self)->SetAllBits(thread, JSHandle<JSAPIBitVector>::Cast(self), value); 2724514f5e3Sopenharmony_ci return JSTaggedValue::Undefined(); 2734514f5e3Sopenharmony_ci} 2744514f5e3Sopenharmony_ci 2754514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::GetBitCountByRange(EcmaRuntimeCallInfo* argv) 2764514f5e3Sopenharmony_ci{ 2774514f5e3Sopenharmony_ci ASSERT(argv); 2784514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, GetBitCountByRange); 2794514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 2804514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 2814514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 2824514f5e3Sopenharmony_ci 2834514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 2844514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 2854514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 2864514f5e3Sopenharmony_ci } else { 2874514f5e3Sopenharmony_ci JSTaggedValue error = 2884514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, BIND_ERROR, "The getBitCountByRange method cannot be bound"); 2894514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 2904514f5e3Sopenharmony_ci } 2914514f5e3Sopenharmony_ci } 2924514f5e3Sopenharmony_ci 2934514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value = GetCallArg(argv, 0); 2944514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> startIndex = GetCallArg(argv, 1); 2954514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> endIndex = GetCallArg(argv, 2); // 2 means the third arg 2964514f5e3Sopenharmony_ci if (!startIndex->IsInteger()) { 2974514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, startIndex); 2984514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 2994514f5e3Sopenharmony_ci CString errorMsg = "The type of \"fromIndex\" must be integer. Received value is: " + ConvertToString(*result); 3004514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 3014514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 3024514f5e3Sopenharmony_ci } 3034514f5e3Sopenharmony_ci if (!endIndex->IsInteger()) { 3044514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, endIndex); 3054514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 3064514f5e3Sopenharmony_ci CString errorMsg = "The type of \"toIndex\" must be integer. Received value is: " + ConvertToString(*result); 3074514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 3084514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 3094514f5e3Sopenharmony_ci } 3104514f5e3Sopenharmony_ci return JSHandle<JSAPIBitVector>::Cast(self)->GetBitCountByRange( 3114514f5e3Sopenharmony_ci thread, JSHandle<JSAPIBitVector>::Cast(self), value, startIndex, endIndex); 3124514f5e3Sopenharmony_ci} 3134514f5e3Sopenharmony_ci 3144514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::GetIndexOf(EcmaRuntimeCallInfo* argv) 3154514f5e3Sopenharmony_ci{ 3164514f5e3Sopenharmony_ci ASSERT(argv); 3174514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, GetIndexOf); 3184514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 3194514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 3204514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 3214514f5e3Sopenharmony_ci 3224514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 3234514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 3244514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 3254514f5e3Sopenharmony_ci } else { 3264514f5e3Sopenharmony_ci JSTaggedValue error = 3274514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, BIND_ERROR, "The getIndexOf method cannot be bound"); 3284514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 3294514f5e3Sopenharmony_ci } 3304514f5e3Sopenharmony_ci } 3314514f5e3Sopenharmony_ci 3324514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value = GetCallArg(argv, 0); 3334514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> startIndex = GetCallArg(argv, 1); 3344514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> endIndex = GetCallArg(argv, 2); // 2 means the third arg 3354514f5e3Sopenharmony_ci if (!startIndex->IsInteger()) { 3364514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, startIndex); 3374514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 3384514f5e3Sopenharmony_ci CString errorMsg = "The type of \"fromIndex\" must be integer. Received value is: " + ConvertToString(*result); 3394514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 3404514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 3414514f5e3Sopenharmony_ci } 3424514f5e3Sopenharmony_ci if (!endIndex->IsInteger()) { 3434514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, endIndex); 3444514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 3454514f5e3Sopenharmony_ci CString errorMsg = "The type of \"toIndex\" must be integer. Received value is: " + ConvertToString(*result); 3464514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 3474514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 3484514f5e3Sopenharmony_ci } 3494514f5e3Sopenharmony_ci 3504514f5e3Sopenharmony_ci return JSTaggedValue( 3514514f5e3Sopenharmony_ci JSAPIBitVector::GetIndexOf(thread, JSHandle<JSAPIBitVector>::Cast(self), value, startIndex, endIndex)); 3524514f5e3Sopenharmony_ci} 3534514f5e3Sopenharmony_ci 3544514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::GetLastIndexOf(EcmaRuntimeCallInfo* argv) 3554514f5e3Sopenharmony_ci{ 3564514f5e3Sopenharmony_ci ASSERT(argv); 3574514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, GetLastIndexOf); 3584514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 3594514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 3604514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 3614514f5e3Sopenharmony_ci 3624514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 3634514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 3644514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 3654514f5e3Sopenharmony_ci } else { 3664514f5e3Sopenharmony_ci JSTaggedValue error = 3674514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, BIND_ERROR, "The getLastIndexOf method cannot be bound"); 3684514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 3694514f5e3Sopenharmony_ci } 3704514f5e3Sopenharmony_ci } 3714514f5e3Sopenharmony_ci 3724514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value = GetCallArg(argv, 0); 3734514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> startIndex = GetCallArg(argv, 1); 3744514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> endIndex = GetCallArg(argv, 2); // 2 means the third arg 3754514f5e3Sopenharmony_ci if (!startIndex->IsInteger()) { 3764514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, startIndex); 3774514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 3784514f5e3Sopenharmony_ci CString errorMsg = "The type of \"fromIndex\" must be integer. Received value is: " + ConvertToString(*result); 3794514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 3804514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 3814514f5e3Sopenharmony_ci } 3824514f5e3Sopenharmony_ci if (!endIndex->IsInteger()) { 3834514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, endIndex); 3844514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 3854514f5e3Sopenharmony_ci CString errorMsg = "The type of \"toIndex\" must be integer. Received value is: " + ConvertToString(*result); 3864514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 3874514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 3884514f5e3Sopenharmony_ci } 3894514f5e3Sopenharmony_ci return JSTaggedValue( 3904514f5e3Sopenharmony_ci JSAPIBitVector::GetLastIndexOf(thread, JSHandle<JSAPIBitVector>::Cast(self), value, startIndex, endIndex)); 3914514f5e3Sopenharmony_ci} 3924514f5e3Sopenharmony_ci 3934514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::FlipBitByIndex(EcmaRuntimeCallInfo* argv) 3944514f5e3Sopenharmony_ci{ 3954514f5e3Sopenharmony_ci ASSERT(argv); 3964514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, FlipBitByIndex); 3974514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 3984514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 3994514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 4004514f5e3Sopenharmony_ci 4014514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 4024514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 4034514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 4044514f5e3Sopenharmony_ci } else { 4054514f5e3Sopenharmony_ci JSTaggedValue error = 4064514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, BIND_ERROR, "The flipBitByIndex method cannot be bound"); 4074514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 4084514f5e3Sopenharmony_ci } 4094514f5e3Sopenharmony_ci } 4104514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> value = GetCallArg(argv, 0); 4114514f5e3Sopenharmony_ci if (!value->IsInteger()) { 4124514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, value); 4134514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 4144514f5e3Sopenharmony_ci CString errorMsg = "The type of \"index\" must be integer. Received value is: " + ConvertToString(*result); 4154514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 4164514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 4174514f5e3Sopenharmony_ci } 4184514f5e3Sopenharmony_ci 4194514f5e3Sopenharmony_ci JSAPIBitVector::FlipBitByIndex( 4204514f5e3Sopenharmony_ci thread, JSHandle<JSAPIBitVector>::Cast(self), JSTaggedValue::ToUint32(thread, value)); 4214514f5e3Sopenharmony_ci return JSTaggedValue::Undefined(); 4224514f5e3Sopenharmony_ci} 4234514f5e3Sopenharmony_ci 4244514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::FlipBitsByRange(EcmaRuntimeCallInfo* argv) 4254514f5e3Sopenharmony_ci{ 4264514f5e3Sopenharmony_ci ASSERT(argv); 4274514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, FlipBitsByRange); 4284514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 4294514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 4304514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 4314514f5e3Sopenharmony_ci 4324514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 4334514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 4344514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 4354514f5e3Sopenharmony_ci } else { 4364514f5e3Sopenharmony_ci JSTaggedValue error = 4374514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, BIND_ERROR, "The flipBitsByRange method cannot be bound"); 4384514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 4394514f5e3Sopenharmony_ci } 4404514f5e3Sopenharmony_ci } 4414514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> startIndex = GetCallArg(argv, 0); 4424514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> endIndex = GetCallArg(argv, 1); 4434514f5e3Sopenharmony_ci if (!startIndex->IsInteger()) { 4444514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, startIndex); 4454514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 4464514f5e3Sopenharmony_ci CString errorMsg = "The type of \"fromIndex\" must be integer. Received value is: " + ConvertToString(*result); 4474514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 4484514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 4494514f5e3Sopenharmony_ci } 4504514f5e3Sopenharmony_ci if (!endIndex->IsInteger()) { 4514514f5e3Sopenharmony_ci JSHandle<EcmaString> result = JSTaggedValue::ToString(thread, endIndex); 4524514f5e3Sopenharmony_ci RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); 4534514f5e3Sopenharmony_ci CString errorMsg = "The type of \"toIndex\" must be integer. Received value is: " + ConvertToString(*result); 4544514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError(thread, ErrorFlag::TYPE_ERROR, errorMsg.c_str()); 4554514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 4564514f5e3Sopenharmony_ci } 4574514f5e3Sopenharmony_ci JSHandle<JSAPIBitVector>::Cast(self)->FlipBitsByRange( 4584514f5e3Sopenharmony_ci thread, JSHandle<JSAPIBitVector>::Cast(self), startIndex, endIndex); 4594514f5e3Sopenharmony_ci return JSTaggedValue::Undefined(); 4604514f5e3Sopenharmony_ci} 4614514f5e3Sopenharmony_ci 4624514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::GetSize(EcmaRuntimeCallInfo* argv) 4634514f5e3Sopenharmony_ci{ 4644514f5e3Sopenharmony_ci ASSERT(argv); 4654514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, GetSize); 4664514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 4674514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 4684514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 4694514f5e3Sopenharmony_ci 4704514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 4714514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 4724514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 4734514f5e3Sopenharmony_ci } else { 4744514f5e3Sopenharmony_ci JSTaggedValue error = 4754514f5e3Sopenharmony_ci ContainerError::BusinessError(thread, ErrorFlag::BIND_ERROR, "The getSize method cannot be bound"); 4764514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 4774514f5e3Sopenharmony_ci } 4784514f5e3Sopenharmony_ci } 4794514f5e3Sopenharmony_ci 4804514f5e3Sopenharmony_ci return JSTaggedValue(JSHandle<JSAPIBitVector>::Cast(self)->GetSize()); 4814514f5e3Sopenharmony_ci} 4824514f5e3Sopenharmony_ci 4834514f5e3Sopenharmony_ciJSTaggedValue ContainersBitVector::GetIteratorObj(EcmaRuntimeCallInfo* argv) 4844514f5e3Sopenharmony_ci{ 4854514f5e3Sopenharmony_ci ASSERT(argv); 4864514f5e3Sopenharmony_ci BUILTINS_API_TRACE(argv->GetThread(), BitVector, GetIteratorObj); 4874514f5e3Sopenharmony_ci JSThread* thread = argv->GetThread(); 4884514f5e3Sopenharmony_ci [[maybe_unused]] EcmaHandleScope handleScope(thread); 4894514f5e3Sopenharmony_ci 4904514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> self = GetThis(argv); 4914514f5e3Sopenharmony_ci 4924514f5e3Sopenharmony_ci if (!self->IsJSAPIBitVector()) { 4934514f5e3Sopenharmony_ci if (self->IsJSProxy() && JSHandle<JSProxy>::Cast(self)->GetTarget().IsJSAPIBitVector()) { 4944514f5e3Sopenharmony_ci self = JSHandle<JSTaggedValue>(thread, JSHandle<JSProxy>::Cast(self)->GetTarget()); 4954514f5e3Sopenharmony_ci } else { 4964514f5e3Sopenharmony_ci JSTaggedValue error = ContainerError::BusinessError( 4974514f5e3Sopenharmony_ci thread, ErrorFlag::BIND_ERROR, "The Symbol.iterator method cannot be bound"); 4984514f5e3Sopenharmony_ci THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error, JSTaggedValue::Exception()); 4994514f5e3Sopenharmony_ci } 5004514f5e3Sopenharmony_ci } 5014514f5e3Sopenharmony_ci 5024514f5e3Sopenharmony_ci JSTaggedValue values = JSAPIBitVector::GetIteratorObj(thread, JSHandle<JSAPIBitVector>::Cast(self)); 5034514f5e3Sopenharmony_ci 5044514f5e3Sopenharmony_ci return values; 5054514f5e3Sopenharmony_ci} 5064514f5e3Sopenharmony_ci 5074514f5e3Sopenharmony_civoid ContainersBitVector::FreeBitsetVectorPointer([[maybe_unused]] void *env, void *pointer, 5084514f5e3Sopenharmony_ci [[maybe_unused]] void *data) 5094514f5e3Sopenharmony_ci{ 5104514f5e3Sopenharmony_ci if (pointer == nullptr) { 5114514f5e3Sopenharmony_ci return; 5124514f5e3Sopenharmony_ci } 5134514f5e3Sopenharmony_ci auto bitsetVector = reinterpret_cast<std::vector<std::bitset<JSAPIBitVector::BIT_SET_LENGTH>> *>(pointer); 5144514f5e3Sopenharmony_ci delete bitsetVector; 5154514f5e3Sopenharmony_ci} 5164514f5e3Sopenharmony_ci} // namespace panda::ecmascript::containers 517