OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2618 function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ? rw_attribs | 2618 function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ? rw_attribs |
2619 : ro_attribs; | 2619 : ro_attribs; |
2620 Handle<AccessorInfo> prototype = | 2620 Handle<AccessorInfo> prototype = |
2621 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2621 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2622 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2622 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2623 prototype, attribs); | 2623 prototype, attribs); |
2624 map->AppendDescriptor(&d); | 2624 map->AppendDescriptor(&d); |
2625 } | 2625 } |
2626 } | 2626 } |
2627 | 2627 |
| 2628 Handle<JSFixedArrayIterator> Factory::NewJSFixedArrayIterator( |
| 2629 Handle<FixedArray> array) { |
| 2630 // Create the "next" function (must be unique per iterator object). |
| 2631 Handle<Code> code( |
| 2632 isolate()->builtins()->builtin(Builtins::kFixedArrayIteratorNext)); |
| 2633 // TODO(neis): Don't create a new SharedFunctionInfo each time. |
| 2634 Handle<JSFunction> next = isolate()->factory()->NewFunctionWithoutPrototype( |
| 2635 isolate()->factory()->next_string(), code, false); |
| 2636 next->shared()->set_native(true); |
| 2637 |
| 2638 // Create the iterator. |
| 2639 Handle<Map> map(isolate()->native_context()->fixed_array_iterator_map()); |
| 2640 Handle<JSFixedArrayIterator> iterator = |
| 2641 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); |
| 2642 iterator->set_next(*next); |
| 2643 iterator->set_array(*array); |
| 2644 iterator->set_index(0); |
| 2645 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); |
| 2646 return iterator; |
| 2647 } |
| 2648 |
2628 } // namespace internal | 2649 } // namespace internal |
2629 } // namespace v8 | 2650 } // namespace v8 |
OLD | NEW |