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
18 #include "ecmascript/base/builtins_base.h"
19 #include "ecmascript/ecma_vm.h"
20 #include "ecmascript/global_env.h"
21 #include "ecmascript/js_iterator.h"
22
23 namespace panda::ecmascript::builtins {
IteratorConstructor(EcmaRuntimeCallInfo * argv)24 JSTaggedValue BuiltinsIterator::IteratorConstructor([[maybe_unused]] EcmaRuntimeCallInfo *argv)
25 {
26 return JSTaggedValue::Undefined();
27 }
28
Next(EcmaRuntimeCallInfo * argv)29 JSTaggedValue BuiltinsIterator::Next([[maybe_unused]] EcmaRuntimeCallInfo *argv)
30 {
31 return JSTaggedValue::Undefined();
32 }
33
Throw(EcmaRuntimeCallInfo * argv)34 JSTaggedValue BuiltinsIterator::Throw([[maybe_unused]] EcmaRuntimeCallInfo *argv)
35 {
36 return JSTaggedValue::Undefined();
37 }
38
Return(EcmaRuntimeCallInfo * argv)39 JSTaggedValue BuiltinsIterator::Return(EcmaRuntimeCallInfo *argv)
40 {
41 BUILTINS_API_TRACE(argv->GetThread(), Iterator, Return);
42 JSThread *thread = argv->GetThread();
43 [[maybe_unused]] EcmaHandleScope handleScope(thread);
44 JSHandle<JSTaggedValue> value = GetCallArg(argv, 0);
45 JSHandle<JSObject> iterResult = JSIterator::CreateIterResultObject(thread, value, true);
46 return iterResult.GetTaggedValue();
47 }
48
GetIteratorObj(EcmaRuntimeCallInfo * argv)49 JSTaggedValue BuiltinsIterator::GetIteratorObj(EcmaRuntimeCallInfo *argv)
50 {
51 return base::BuiltinsBase::GetThis(argv).GetTaggedValue();
52 }
53 } // namespace panda::ecmascript::builtins
54