Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 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* 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* Set(JSObject* holder, | |
| 48 uint32_t key, | |
| 49 Object* value, | |
| 50 PropertyAttributes attributes = ABSENT) = 0; | |
| 51 | |
| 47 virtual MaybeObject* Delete(JSObject* holder, | 52 virtual MaybeObject* Delete(JSObject* holder, |
| 48 uint32_t key, | 53 uint32_t key, |
| 49 JSReceiver::DeleteMode mode) = 0; | 54 JSReceiver::DeleteMode mode) = 0; |
| 50 | 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. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 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 |
| 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 // specific in JavaScript to access the element. In most implementations, keys |
| 81 // are equivalent to indexes, and GetKeyForIndex returns the same value it is | 86 // are equivalent to indexes, and GetKeyForIndex returns the same value it is |
| 82 // passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps the | 87 // passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps the |
| 83 // index to a key using the KeyAt method on the NumberDictionary. | 88 // 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 |
| 92 // Internal element setter which does not update the objects backing store | |
| 93 // containing the elements, but returns the new backing store. The caller | |
| 94 // is responsible for updating the object reference to the backing store. | |
|
danno
2011/10/24 21:09:02
The separation of responsibility seems clear in th
| |
| 95 virtual MaybeObject* SetInternal(FixedArrayBase* backing_store, | |
| 96 uint32_t index, | |
| 97 Object* value, | |
| 98 PropertyAttributes attributes) = 0; | |
| 99 | |
| 87 private: | 100 private: |
| 88 static ElementsAccessor** elements_accessors_; | 101 static ElementsAccessor** elements_accessors_; |
| 89 | 102 |
| 90 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); | 103 DISALLOW_COPY_AND_ASSIGN(ElementsAccessor); |
| 91 }; | 104 }; |
| 92 | 105 |
| 93 } } // namespace v8::internal | 106 } } // namespace v8::internal |
| 94 | 107 |
| 95 #endif // V8_ELEMENTS_H_ | 108 #endif // V8_ELEMENTS_H_ |
| OLD | NEW |