OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 BUILTIN(FixedArrayIteratorNext) { | 35 BUILTIN(FixedArrayIteratorNext) { |
36 HandleScope scope(isolate); | 36 HandleScope scope(isolate); |
37 DCHECK_EQ(1, args.length()); | 37 DCHECK_EQ(1, args.length()); |
38 Handle<Object> receiver = args.at<Object>(0); | 38 Handle<Object> receiver = args.at<Object>(0); |
39 | 39 |
40 // It is an error if this function is called on anything other than the | 40 // It is an error if this function is called on anything other than the |
41 // particular iterator object for which the function was created. | 41 // particular iterator object for which the function was created. |
42 if (!receiver->IsJSFixedArrayIterator() || | 42 if (!receiver->IsJSFixedArrayIterator() || |
43 Handle<JSFixedArrayIterator>::cast(receiver)->initial_next() != | 43 Handle<JSFixedArrayIterator>::cast(receiver)->initial_next() != |
44 *args.target<JSFunction>()) { | 44 *args.target()) { |
45 THROW_NEW_ERROR_RETURN_FAILURE( | 45 THROW_NEW_ERROR_RETURN_FAILURE( |
46 isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, | 46 isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |
47 isolate->factory()->next_string(), receiver)); | 47 isolate->factory()->next_string(), receiver)); |
48 } | 48 } |
49 | 49 |
50 auto iterator = Handle<JSFixedArrayIterator>::cast(receiver); | 50 auto iterator = Handle<JSFixedArrayIterator>::cast(receiver); |
51 Handle<Object> value; | 51 Handle<Object> value; |
52 bool done; | 52 bool done; |
53 | 53 |
54 int index = iterator->index(); | 54 int index = iterator->index(); |
55 if (index < iterator->array()->length()) { | 55 if (index < iterator->array()->length()) { |
56 value = handle(iterator->array()->get(index), isolate); | 56 value = handle(iterator->array()->get(index), isolate); |
57 done = false; | 57 done = false; |
58 iterator->set_index(index + 1); | 58 iterator->set_index(index + 1); |
59 } else { | 59 } else { |
60 value = isolate->factory()->undefined_value(); | 60 value = isolate->factory()->undefined_value(); |
61 done = true; | 61 done = true; |
62 } | 62 } |
63 | 63 |
64 return *isolate->factory()->NewJSIteratorResult(value, done); | 64 return *isolate->factory()->NewJSIteratorResult(value, done); |
65 } | 65 } |
66 | 66 |
67 } // namespace internal | 67 } // namespace internal |
68 } // namespace v8 | 68 } // namespace v8 |
OLD | NEW |