| 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 23 matching lines...) Expand all Loading... |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 // Abstract base class for handles that can operate on objects with differing | 36 // Abstract base class for handles that can operate on objects with differing |
| 37 // ElementsKinds. | 37 // ElementsKinds. |
| 38 class ElementsAccessor { | 38 class ElementsAccessor { |
| 39 public: | 39 public: |
| 40 ElementsAccessor() { } | 40 ElementsAccessor() { } |
| 41 virtual ~ElementsAccessor() { } | 41 virtual ~ElementsAccessor() { } |
| 42 virtual MaybeObject* GetWithReceiver(JSObject* obj, | 42 virtual MaybeObject* GetWithReceiver(JSObject* obj, |
| 43 Object* receiver, | 43 Object* receiver, |
| 44 uint32_t index) = 0; | 44 uint32_t key) = 0; |
| 45 | 45 |
| 46 virtual MaybeObject* Delete(JSObject* obj, | 46 virtual MaybeObject* Delete(JSObject* obj, |
| 47 uint32_t index, | 47 uint32_t key, |
| 48 JSReceiver::DeleteMode mode) = 0; | 48 JSReceiver::DeleteMode mode) = 0; |
| 49 | 49 |
| 50 virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from, | 50 virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from, |
| 51 FixedArray* to) = 0; | 51 FixedArray* to) = 0; |
| 52 | 52 |
| 53 // Returns a shared ElementsAccessor for the specified ElementsKind. | 53 // Returns a shared ElementsAccessor for the specified ElementsKind. |
| 54 static ElementsAccessor* ForKind(JSObject::ElementsKind elements_kind) { | 54 static ElementsAccessor* ForKind(JSObject::ElementsKind elements_kind) { |
| 55 ASSERT(elements_kind < JSObject::kElementsKindCount); | 55 ASSERT(elements_kind < JSObject::kElementsKindCount); |
| 56 return elements_accessors_[elements_kind]; | 56 return elements_accessors_[elements_kind]; |
| 57 } | 57 } |
| 58 | 58 |
| 59 static ElementsAccessor* ForArray(FixedArrayBase* array); |
| 60 |
| 59 static void InitializeOncePerProcess(); | 61 static void InitializeOncePerProcess(); |
| 60 | 62 |
| 63 protected: |
| 64 friend class NonStrictArgumentsElementsAccessor; |
| 65 |
| 66 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0; |
| 67 |
| 68 // TODO(danno): GetElement should be merged with GetWithReceiver. |
| 69 virtual MaybeObject* GetElement(FixedArrayBase* backing_store, |
| 70 uint32_t key) = 0; |
| 71 |
| 72 virtual bool HasElementAtIndex(FixedArrayBase* backing_store, |
| 73 uint32_t index) = 0; |
| 74 |
| 75 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
| 76 uint32_t index) = 0; |
| 77 |
| 61 private: | 78 private: |
| 62 static ElementsAccessor** elements_accessors_; | 79 static ElementsAccessor** elements_accessors_; |
| 63 | 80 |
| 64 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); | 81 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); |
| 65 }; | 82 }; |
| 66 | 83 |
| 67 } } // namespace v8::internal | 84 } } // namespace v8::internal |
| 68 | 85 |
| 69 #endif // V8_ELEMENTS_H_ | 86 #endif // V8_ELEMENTS_H_ |
| OLD | NEW |