OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_ELEMENTS_H_ | 5 #ifndef V8_ELEMENTS_H_ |
6 #define V8_ELEMENTS_H_ | 6 #define V8_ELEMENTS_H_ |
7 | 7 |
8 #include "src/elements-kind.h" | 8 #include "src/elements-kind.h" |
9 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 Handle<JSObject> holder, | 36 Handle<JSObject> holder, |
37 uint32_t key, | 37 uint32_t key, |
38 Handle<FixedArrayBase> backing_store) = 0; | 38 Handle<FixedArrayBase> backing_store) = 0; |
39 | 39 |
40 inline bool HasElement( | 40 inline bool HasElement( |
41 Handle<JSObject> holder, | 41 Handle<JSObject> holder, |
42 uint32_t key) { | 42 uint32_t key) { |
43 return HasElement(holder, key, handle(holder->elements())); | 43 return HasElement(holder, key, handle(holder->elements())); |
44 } | 44 } |
45 | 45 |
| 46 inline Handle<Object> Set(Handle<JSObject> holder, uint32_t key, |
| 47 Handle<Object> value) { |
| 48 return Set(holder, key, handle(holder->elements()), value); |
| 49 } |
| 50 |
46 // Returns the element with the specified key or undefined if there is no such | 51 // Returns the element with the specified key or undefined if there is no such |
47 // element. This method doesn't iterate up the prototype chain. The caller | 52 // element. This method doesn't iterate up the prototype chain. The caller |
48 // can optionally pass in the backing store to use for the check, which must | 53 // can optionally pass in the backing store to use for the check, which must |
49 // be compatible with the ElementsKind of the ElementsAccessor. If | 54 // be compatible with the ElementsKind of the ElementsAccessor. If |
50 // backing_store is NULL, the holder->elements() is used as the backing store. | 55 // backing_store is NULL, the holder->elements() is used as the backing store. |
51 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key, | 56 virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key, |
52 Handle<FixedArrayBase> backing_store) = 0; | 57 Handle<FixedArrayBase> backing_store) = 0; |
53 | 58 |
54 inline Handle<Object> Get(Handle<JSObject> holder, uint32_t key) { | 59 inline Handle<Object> Get(Handle<JSObject> holder, uint32_t key) { |
55 return Get(holder, key, handle(holder->elements())); | 60 return Get(holder, key, handle(holder->elements())); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps | 185 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps |
181 // the index to a key using the KeyAt method on the NumberDictionary. | 186 // the index to a key using the KeyAt method on the NumberDictionary. |
182 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, | 187 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
183 uint32_t index) = 0; | 188 uint32_t index) = 0; |
184 virtual uint32_t GetIndexForKey(FixedArrayBase* backing_store, | 189 virtual uint32_t GetIndexForKey(FixedArrayBase* backing_store, |
185 uint32_t key) = 0; | 190 uint32_t key) = 0; |
186 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, | 191 virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, |
187 uint32_t index) = 0; | 192 uint32_t index) = 0; |
188 virtual bool HasIndex(FixedArrayBase* backing_store, uint32_t key) = 0; | 193 virtual bool HasIndex(FixedArrayBase* backing_store, uint32_t key) = 0; |
189 | 194 |
| 195 virtual Handle<Object> Set(Handle<JSObject> holder, uint32_t key, |
| 196 Handle<FixedArrayBase> backing_store, |
| 197 Handle<Object> value) = 0; |
| 198 |
190 private: | 199 private: |
191 static ElementsAccessor** elements_accessors_; | 200 static ElementsAccessor** elements_accessors_; |
192 const char* name_; | 201 const char* name_; |
193 | 202 |
194 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); | 203 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); |
195 }; | 204 }; |
196 | 205 |
197 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, | 206 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, |
198 bool allow_appending = false); | 207 bool allow_appending = false); |
199 | 208 |
200 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( | 209 MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements( |
201 Handle<JSArray> array, | 210 Handle<JSArray> array, |
202 Arguments* args); | 211 Arguments* args); |
203 | 212 |
204 } } // namespace v8::internal | 213 } } // namespace v8::internal |
205 | 214 |
206 #endif // V8_ELEMENTS_H_ | 215 #endif // V8_ELEMENTS_H_ |
OLD | NEW |