OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 10 matching lines...) Expand all Loading... | |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_ELEMENTS_H_ | 28 #ifndef V8_ELEMENTS_H_ |
29 #define V8_ELEMENTS_H_ | 29 #define V8_ELEMENTS_H_ |
30 | 30 |
31 #include "elements-kind.h" | |
31 #include "objects.h" | 32 #include "objects.h" |
32 #include "heap.h" | 33 #include "heap.h" |
33 #include "isolate.h" | 34 #include "isolate.h" |
34 | 35 |
35 namespace v8 { | 36 namespace v8 { |
36 namespace internal { | 37 namespace internal { |
37 | 38 |
38 // Abstract base class for handles that can operate on objects with differing | 39 // Abstract base class for handles that can operate on objects with differing |
39 // ElementsKinds. | 40 // ElementsKinds. |
40 class ElementsAccessor { | 41 class ElementsAccessor { |
41 public: | 42 public: |
42 explicit ElementsAccessor(const char* name) : name_(name) { } | 43 explicit ElementsAccessor(const char* name) : name_(name) { } |
43 virtual ~ElementsAccessor() { } | 44 virtual ~ElementsAccessor() { } |
44 | 45 |
45 virtual ElementsKind kind() const = 0; | 46 virtual ElementsKind kind() const = 0; |
46 const char* name() const { return name_; } | 47 const char* name() const { return name_; } |
47 | 48 |
49 // Checks the elements of an object for consistency, asserting when a problem | |
50 // is found. | |
51 virtual void Validate(JSObject* obj) = 0; | |
52 | |
48 // Returns true if a holder contains an element with the specified key | 53 // Returns true if a holder contains an element with the specified key |
49 // without iterating up the prototype chain. The caller can optionally pass | 54 // without iterating up the prototype chain. The caller can optionally pass |
50 // in the backing store to use for the check, which must be compatible with | 55 // in the backing store to use for the check, which must be compatible with |
51 // the ElementsKind of the ElementsAccessor. If backing_store is NULL, the | 56 // the ElementsKind of the ElementsAccessor. If backing_store is NULL, the |
52 // holder->elements() is used as the backing store. | 57 // holder->elements() is used as the backing store. |
53 virtual bool HasElement(Object* receiver, | 58 virtual bool HasElement(Object* receiver, |
54 JSObject* holder, | 59 JSObject* holder, |
55 uint32_t key, | 60 uint32_t key, |
56 FixedArrayBase* backing_store = NULL) = 0; | 61 FixedArrayBase* backing_store = NULL) = 0; |
57 | 62 |
(...skipping 14 matching lines...) Expand all Loading... | |
72 // element that is non-deletable. | 77 // element that is non-deletable. |
73 virtual MaybeObject* SetLength(JSArray* holder, | 78 virtual MaybeObject* SetLength(JSArray* holder, |
74 Object* new_length) = 0; | 79 Object* new_length) = 0; |
75 | 80 |
76 // Modifies both the length and capacity of a JSArray, resizing the underlying | 81 // Modifies both the length and capacity of a JSArray, resizing the underlying |
77 // backing store as necessary. This method does NOT honor the semantics of | 82 // backing store as necessary. This method does NOT honor the semantics of |
78 // EcmaScript 5.1 15.4.5.2, arrays can be shrunk beyond non-deletable | 83 // EcmaScript 5.1 15.4.5.2, arrays can be shrunk beyond non-deletable |
79 // elements. This method should only be called for array expansion OR by | 84 // elements. This method should only be called for array expansion OR by |
80 // runtime JavaScript code that use InternalArrays and don't care about | 85 // runtime JavaScript code that use InternalArrays and don't care about |
81 // EcmaScript 5.1 semantics. | 86 // EcmaScript 5.1 semantics. |
82 virtual MaybeObject* SetCapacityAndLength(JSArray* array, | 87 virtual MaybeObject* SetCapacityAndLength( |
Jakob Kummerow
2012/05/13 21:55:27
nit: why this formatting change?
danno
2012/05/22 11:05:21
Done.
| |
83 int capacity, | 88 JSArray* array, |
84 int length) = 0; | 89 int capacity, |
90 int length) = 0; | |
85 | 91 |
86 // Deletes an element in an object, returning a new elements backing store. | 92 // Deletes an element in an object, returning a new elements backing store. |
87 virtual MaybeObject* Delete(JSObject* holder, | 93 virtual MaybeObject* Delete(JSObject* holder, |
88 uint32_t key, | 94 uint32_t key, |
89 JSReceiver::DeleteMode mode) = 0; | 95 JSReceiver::DeleteMode mode) = 0; |
90 | 96 |
91 // If kCopyToEnd is specified as the copy_size to CopyElements, it copies all | 97 // If kCopyToEnd is specified as the copy_size to CopyElements, it copies all |
92 // of elements from source after source_start to the destination array. | 98 // of elements from source after source_start to the destination array. |
93 static const int kCopyToEnd = -1; | 99 static const int kCopyToEnd = -1; |
94 // If kCopyToEndAndInitializeToHole is specified as the copy_size to | 100 // If kCopyToEndAndInitializeToHole is specified as the copy_size to |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 uint32_t from_start, | 168 uint32_t from_start, |
163 FixedArray* to_obj, | 169 FixedArray* to_obj, |
164 ElementsKind to_kind, | 170 ElementsKind to_kind, |
165 uint32_t to_start, | 171 uint32_t to_start, |
166 int copy_size); | 172 int copy_size); |
167 | 173 |
168 | 174 |
169 } } // namespace v8::internal | 175 } } // namespace v8::internal |
170 | 176 |
171 #endif // V8_ELEMENTS_H_ | 177 #endif // V8_ELEMENTS_H_ |
OLD | NEW |