| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 virtual ~ElementsAccessor() { } | 41 virtual ~ElementsAccessor() { } |
| 42 virtual MaybeObject* Get(FixedArrayBase* backing_store, | 42 virtual MaybeObject* Get(FixedArrayBase* backing_store, |
| 43 uint32_t key, | 43 uint32_t key, |
| 44 JSObject* holder, | 44 JSObject* holder, |
| 45 Object* receiver) = 0; | 45 Object* receiver) = 0; |
| 46 | 46 |
| 47 virtual MaybeObject* Delete(JSObject* holder, | 47 virtual MaybeObject* Delete(JSObject* holder, |
| 48 uint32_t key, | 48 uint32_t key, |
| 49 JSReceiver::DeleteMode mode) = 0; | 49 JSReceiver::DeleteMode mode) = 0; |
| 50 | 50 |
| 51 virtual bool HasElementAtKey(FixedArrayBase* backing_store, |
| 52 uint32_t key, |
| 53 JSObject* holder, |
| 54 Object* receiver) = 0; |
| 55 |
| 51 virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from, | 56 virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from, |
| 52 FixedArray* to, | 57 FixedArray* to, |
| 53 JSObject* holder, | 58 JSObject* holder, |
| 54 Object* receiver) = 0; | 59 Object* receiver) = 0; |
| 55 | 60 |
| 56 // Returns a shared ElementsAccessor for the specified ElementsKind. | 61 // Returns a shared ElementsAccessor for the specified ElementsKind. |
| 57 static ElementsAccessor* ForKind(ElementsKind elements_kind) { | 62 static ElementsAccessor* ForKind(ElementsKind elements_kind) { |
| 58 ASSERT(elements_kind < kElementsKindCount); | 63 ASSERT(elements_kind < kElementsKindCount); |
| 59 return elements_accessors_[elements_kind]; | 64 return elements_accessors_[elements_kind]; |
| 60 } | 65 } |
| 61 | 66 |
| 62 static ElementsAccessor* ForArray(FixedArrayBase* array); | 67 static ElementsAccessor* ForArray(FixedArrayBase* array); |
| 63 | 68 |
| 64 static void InitializeOncePerProcess(); | 69 static void InitializeOncePerProcess(); |
| 65 | 70 |
| 66 protected: | 71 protected: |
| 67 friend class NonStrictArgumentsElementsAccessor; | 72 friend class NonStrictArgumentsElementsAccessor; |
| 68 | 73 |
| 69 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0; | 74 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0; |
| 70 | 75 |
| 71 virtual bool HasElementAtIndex(FixedArrayBase* backing_store, | 76 virtual bool HasElementAtIndex(FixedArrayBase* backing_store, |
| 72 uint32_t index, | 77 uint32_t index, |
| 73 JSObject* holder, | 78 JSObject* holder, |
| 74 Object* receiver) = 0; | 79 Object* receiver) = 0; |
| 75 | 80 |
| 76 // Element handlers distinguish between indexes and keys when the manipulate | 81 // Element handlers distinguish between indexes and keys when they manipulate |
| 77 // elements. Indexes refer to elements in terms of their location in the | 82 // elements. Indexes refer to elements in terms of their location in the |
| 78 // underlying storage's backing store representation, and are between 0 | 83 // underlying storage's backing store representation, and are between 0 and |
| 79 // GetCapacity. Keys refer to elements in terms of the value that would be | 84 // GetCapacity. Keys refer to elements in terms of the value that would be |
| 80 // specific in JavaScript to access the element. In most implementations, keys | 85 // specified in JavaScript to access the element. In most implementations, |
| 81 // are equivalent to indexes, and GetKeyForIndex returns the same value it is | 86 // keys are equivalent to indexes, and GetKeyForIndex returns the same value |
| 82 // passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps the | 87 // it is passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps |
| 83 // index to a key using the KeyAt method on the NumberDictionary. | 88 // the index to a key using the KeyAt method on the NumberDictionary. |
| 84 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, | 89 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
| 85 uint32_t index) = 0; | 90 uint32_t index) = 0; |
| 86 | 91 |
| 87 private: | 92 private: |
| 88 static ElementsAccessor** elements_accessors_; | 93 static ElementsAccessor** elements_accessors_; |
| 89 | 94 |
| 90 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); | 95 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); |
| 91 }; | 96 }; |
| 92 | 97 |
| 93 } } // namespace v8::internal | 98 } } // namespace v8::internal |
| 94 | 99 |
| 95 #endif // V8_ELEMENTS_H_ | 100 #endif // V8_ELEMENTS_H_ |
| OLD | NEW |