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 BUILTINS_API_TRACE(argv->GetThread(), Iterator, Constructor);
27 return JSTaggedValue::Undefined();
28 }
29
Next(EcmaRuntimeCallInfo * argv)30 JSTaggedValue BuiltinsIterator::Next([[maybe_unused]] EcmaRuntimeCallInfo *argv)
31 {
32 BUILTINS_API_TRACE(argv->GetThread(), Iterator, Next);
33 return JSTaggedValue::Undefined();
34 }
35
Throw(EcmaRuntimeCallInfo * argv)36 JSTaggedValue BuiltinsIterator::Throw([[maybe_unused]] EcmaRuntimeCallInfo *argv)
37 {
38 BUILTINS_API_TRACE(argv->GetThread(), Iterator, Throw);
39 return JSTaggedValue::Undefined();
40 }
41
Return(EcmaRuntimeCallInfo * argv)42 JSTaggedValue BuiltinsIterator::Return(EcmaRuntimeCallInfo *argv)
43 {
44 BUILTINS_API_TRACE(argv->GetThread(), Iterator, Return);
45 JSThread *thread = argv->GetThread();
46 [[maybe_unused]] EcmaHandleScope handleScope(thread);
47 JSHandle<JSTaggedValue> value = GetCallArg(argv, 0);
48 JSHandle<JSObject> iterResult = JSIterator::CreateIterResultObject(thread, value, true);
49 return iterResult.GetTaggedValue();
50 }
51
GetIteratorObj(EcmaRuntimeCallInfo * argv)52 JSTaggedValue BuiltinsIterator::GetIteratorObj(EcmaRuntimeCallInfo *argv)
53 {
54 BUILTINS_API_TRACE(argv->GetThread(), Iterator, GetObj);
55 return base::BuiltinsBase::GetThis(argv).GetTaggedValue();
56 }
57 } // namespace panda::ecmascript::builtins
58