V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
builtins-iterator-gen.h
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_BUILTINS_BUILTINS_ITERATOR_GEN_H_
6 #define V8_BUILTINS_BUILTINS_ITERATOR_GEN_H_
7 
8 #include "src/code-stub-assembler.h"
9 #include "torque-generated/builtins-base-from-dsl-gen.h"
10 #include "torque-generated/builtins-iterator-from-dsl-gen.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 using compiler::Node;
16 
19  public:
22 
23  // Returns object[Symbol.iterator].
24  TNode<Object> GetIteratorMethod(Node* context, Node* object);
25 
26  // https://tc39.github.io/ecma262/#sec-getiterator --- never used for
27  // @@asyncIterator.
28  IteratorRecord GetIterator(Node* context, Node* object,
29  Label* if_exception = nullptr,
30  Variable* exception = nullptr);
31  IteratorRecord GetIterator(Node* context, Node* object, Node* method,
32  Label* if_exception = nullptr,
33  Variable* exception = nullptr);
34 
35  // https://tc39.github.io/ecma262/#sec-iteratorstep
36  // Returns `false` if the iterator is done, otherwise returns an
37  // iterator result.
38  // `fast_iterator_result_map` refers to the map for the JSIteratorResult
39  // object, loaded from the native context.
40  TNode<Object> IteratorStep(Node* context, const IteratorRecord& iterator,
41  Label* if_done,
42  Node* fast_iterator_result_map = nullptr,
43  Label* if_exception = nullptr,
44  Variable* exception = nullptr);
45 
46  TNode<Object> IteratorStep(Node* context, const IteratorRecord& iterator,
47  Node* fast_iterator_result_map, Label* if_done) {
48  return IteratorStep(context, iterator, if_done, fast_iterator_result_map);
49  }
50 
51  // https://tc39.github.io/ecma262/#sec-iteratorvalue
52  // Return the `value` field from an iterator.
53  // `fast_iterator_result_map` refers to the map for the JSIteratorResult
54  // object, loaded from the native context.
55  Node* IteratorValue(Node* context, Node* result,
56  Node* fast_iterator_result_map = nullptr,
57  Label* if_exception = nullptr,
58  Variable* exception = nullptr);
59 
60  // https://tc39.github.io/ecma262/#sec-iteratorclose
61  void IteratorCloseOnException(Node* context, const IteratorRecord& iterator,
62  Label* if_exception, Variable* exception);
63  void IteratorCloseOnException(Node* context, const IteratorRecord& iterator,
64  TNode<Object> exception);
65 
66  // #sec-iterabletolist
67  // Build a JSArray by iterating over {iterable} using {iterator_fn},
68  // following the ECMAscript operation with the same name.
69  TNode<JSArray> IterableToList(TNode<Context> context, TNode<Object> iterable,
70  TNode<Object> iterator_fn);
71 
72  void FastIterableToList(TNode<Context> context, TNode<Object> iterable,
73  TVariable<Object>* var_result, Label* slow);
74 };
75 
76 } // namespace internal
77 } // namespace v8
78 
79 #endif // V8_BUILTINS_BUILTINS_ITERATOR_GEN_H_
Definition: libplatform.h:13