1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "ecmascript/builtins/builtins_iterator.h" 17#include "ecmascript/js_iterator.h" 18 19namespace panda::ecmascript::builtins { 20JSTaggedValue BuiltinsIterator::IteratorConstructor([[maybe_unused]] EcmaRuntimeCallInfo *argv) 21{ 22 BUILTINS_API_TRACE(argv->GetThread(), Iterator, Constructor); 23 return JSTaggedValue::Undefined(); 24} 25 26JSTaggedValue BuiltinsIterator::Next([[maybe_unused]] EcmaRuntimeCallInfo *argv) 27{ 28 BUILTINS_API_TRACE(argv->GetThread(), Iterator, Next); 29 return JSTaggedValue::Undefined(); 30} 31 32JSTaggedValue BuiltinsIterator::Throw([[maybe_unused]] EcmaRuntimeCallInfo *argv) 33{ 34 BUILTINS_API_TRACE(argv->GetThread(), Iterator, Throw); 35 return JSTaggedValue::Undefined(); 36} 37 38JSTaggedValue BuiltinsIterator::Return(EcmaRuntimeCallInfo *argv) 39{ 40 BUILTINS_API_TRACE(argv->GetThread(), Iterator, Return); 41 JSThread *thread = argv->GetThread(); 42 [[maybe_unused]] EcmaHandleScope handleScope(thread); 43 JSHandle<JSTaggedValue> thisValue = GetCallArg(argv, 0); 44 return ReturnInternal(thread, thisValue); 45} 46 47JSTaggedValue BuiltinsIterator::ReturnInternal(JSThread *thread, JSHandle<JSTaggedValue> thisValue) 48{ 49 JSHandle<JSObject> iterResult = JSIterator::CreateIterResultObject(thread, thisValue, true); 50 return iterResult.GetTaggedValue(); 51} 52 53JSTaggedValue BuiltinsIterator::GetIteratorObj(EcmaRuntimeCallInfo *argv) 54{ 55 BUILTINS_API_TRACE(argv->GetThread(), Iterator, GetObj); 56 return base::BuiltinsBase::GetThis(argv).GetTaggedValue(); 57} 58} // namespace panda::ecmascript::builtins 59