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_OBJECTS_JS_COLLECTION_INL_H_
6 #define V8_OBJECTS_JS_COLLECTION_INL_H_
7
8 #include "src/objects/js-collection.h"
9
10 #include "src/objects-inl.h" // Needed for write barriers
11
12 // Has to be the last include (doesn't have include guards):
13 #include "src/objects/object-macros.h"
14
15 namespace v8 {
16 namespace internal {
17
ACCESSORS(JSCollection,table,Object,kTableOffset)18 ACCESSORS(JSCollection, table, Object, kTableOffset)
19 ACCESSORS(JSCollectionIterator, table, Object, kTableOffset)
20 ACCESSORS(JSCollectionIterator, index, Object, kIndexOffset)
21
22 ACCESSORS(JSWeakCollection, table, Object, kTableOffset)
23
24 CAST_ACCESSOR(JSSet)
25 CAST_ACCESSOR(JSSetIterator)
26 CAST_ACCESSOR(JSMap)
27 CAST_ACCESSOR(JSMapIterator)
28 CAST_ACCESSOR(JSWeakCollection)
29 CAST_ACCESSOR(JSWeakMap)
30 CAST_ACCESSOR(JSWeakSet)
31
32 Object* JSMapIterator::CurrentValue() {
33 OrderedHashMap* table(OrderedHashMap::cast(this->table()));
34 int index = Smi::ToInt(this->index());
35 Object* value = table->ValueAt(index);
36 DCHECK(!value->IsTheHole());
37 return value;
38 }
39
40 } // namespace internal
41 } // namespace v8
42
43 #include "src/objects/object-macros-undef.h"
44
45 #endif // V8_OBJECTS_JS_COLLECTION_INL_H_
46