| 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/code-stub-assembler.h" | 7 #include "src/code-stub-assembler.h" | 
| 8 #include "src/frames-inl.h" | 8 #include "src/frames-inl.h" | 
| 9 | 9 | 
| 10 namespace v8 { | 10 namespace v8 { | 
| 11 namespace internal { | 11 namespace internal { | 
| 12 | 12 | 
| 13 void Builtins::Generate_IteratorPrototypeIterator( | 13 void Builtins::Generate_IteratorPrototypeIterator( | 
| 14     compiler::CodeAssemblerState* state) { | 14     compiler::CodeAssemblerState* state) { | 
| 15   CodeStubAssembler assembler(state); | 15   CodeStubAssembler assembler(state); | 
| 16   assembler.Return(assembler.Parameter(0)); | 16   assembler.Return(assembler.Parameter(0)); | 
| 17 } | 17 } | 
| 18 | 18 | 
| 19 BUILTIN(ModuleNamespaceIterator) { |  | 
| 20   HandleScope scope(isolate); |  | 
| 21   DCHECK_EQ(1, args.length()); |  | 
| 22   Handle<Object> receiver = args.at<Object>(0); |  | 
| 23 |  | 
| 24   if (!receiver->IsJSModuleNamespace()) { |  | 
| 25     THROW_NEW_ERROR_RETURN_FAILURE( |  | 
| 26         isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |  | 
| 27                               isolate->factory()->iterator_symbol(), receiver)); |  | 
| 28   } |  | 
| 29   auto ns = Handle<JSModuleNamespace>::cast(receiver); |  | 
| 30 |  | 
| 31   Handle<FixedArray> names = |  | 
| 32       KeyAccumulator::GetKeys(ns, KeyCollectionMode::kOwnOnly, SKIP_SYMBOLS) |  | 
| 33           .ToHandleChecked(); |  | 
| 34   return *isolate->factory()->NewJSFixedArrayIterator(names); |  | 
| 35 } |  | 
| 36 |  | 
| 37 BUILTIN(FixedArrayIteratorNext) { |  | 
| 38   HandleScope scope(isolate); |  | 
| 39   DCHECK_EQ(1, args.length()); |  | 
| 40   Handle<Object> receiver = args.at<Object>(0); |  | 
| 41 |  | 
| 42   // It is an error if this function is called on anything other than the |  | 
| 43   // particular iterator object for which the function was created. |  | 
| 44   if (!receiver->IsJSFixedArrayIterator() || |  | 
| 45       Handle<JSFixedArrayIterator>::cast(receiver)->initial_next() != |  | 
| 46           *args.target()) { |  | 
| 47     THROW_NEW_ERROR_RETURN_FAILURE( |  | 
| 48         isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |  | 
| 49                               isolate->factory()->next_string(), receiver)); |  | 
| 50   } |  | 
| 51 |  | 
| 52   auto iterator = Handle<JSFixedArrayIterator>::cast(receiver); |  | 
| 53   Handle<Object> value; |  | 
| 54   bool done; |  | 
| 55 |  | 
| 56   int index = iterator->index(); |  | 
| 57   if (index < iterator->array()->length()) { |  | 
| 58     value = handle(iterator->array()->get(index), isolate); |  | 
| 59     done = false; |  | 
| 60     iterator->set_index(index + 1); |  | 
| 61   } else { |  | 
| 62     value = isolate->factory()->undefined_value(); |  | 
| 63     done = true; |  | 
| 64   } |  | 
| 65 |  | 
| 66   return *isolate->factory()->NewJSIteratorResult(value, done); |  | 
| 67 } |  | 
| 68 |  | 
| 69 }  // namespace internal | 19 }  // namespace internal | 
| 70 }  // namespace v8 | 20 }  // namespace v8 | 
| OLD | NEW | 
|---|