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