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 2892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2903 | 2903 |
2904 template <typename Shape, typename Key> | 2904 template <typename Shape, typename Key> |
2905 class Dictionary: public HashTable<Shape, Key> { | 2905 class Dictionary: public HashTable<Shape, Key> { |
2906 public: | 2906 public: |
2907 static inline Dictionary<Shape, Key>* cast(Object* obj) { | 2907 static inline Dictionary<Shape, Key>* cast(Object* obj) { |
2908 return reinterpret_cast<Dictionary<Shape, Key>*>(obj); | 2908 return reinterpret_cast<Dictionary<Shape, Key>*>(obj); |
2909 } | 2909 } |
2910 | 2910 |
2911 // Returns the value at entry. | 2911 // Returns the value at entry. |
2912 Object* ValueAt(int entry) { | 2912 Object* ValueAt(int entry) { |
2913 return this->get(HashTable<Shape, Key>::EntryToIndex(entry)+1); | 2913 return this->get(HashTable<Shape, Key>::EntryToIndex(entry)+1); |
Michael Starzinger
2012/02/17 13:44:26
I know you didn't touch this line, but could you a
Sven Panne
2012/02/17 13:46:58
Done.
| |
2914 } | 2914 } |
2915 | 2915 |
2916 // Set the value for entry. | 2916 // Set the value for entry. |
2917 // Returns false if the put wasn't performed due to property being read only. | 2917 void ValueAtPut(int entry, Object* value) { |
2918 // Returns true on successful put. | |
2919 bool ValueAtPut(int entry, Object* value) { | |
2920 // Check that this value can actually be written. | |
2921 PropertyDetails details = DetailsAt(entry); | |
2922 // If a value has not been initilized we allow writing to it even if | |
2923 // it is read only (a declared const that has not been initialized). | |
2924 if (details.IsReadOnly() && !ValueAt(entry)->IsTheHole()) { | |
2925 return false; | |
2926 } | |
2927 this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 1, value); | 2918 this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 1, value); |
2928 return true; | |
2929 } | 2919 } |
2930 | 2920 |
2931 // Returns the property details for the property at entry. | 2921 // Returns the property details for the property at entry. |
2932 PropertyDetails DetailsAt(int entry) { | 2922 PropertyDetails DetailsAt(int entry) { |
2933 ASSERT(entry >= 0); // Not found is -1, which is not caught by get(). | 2923 ASSERT(entry >= 0); // Not found is -1, which is not caught by get(). |
2934 return PropertyDetails( | 2924 return PropertyDetails( |
2935 Smi::cast(this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 2))); | 2925 Smi::cast(this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 2))); |
2936 } | 2926 } |
2937 | 2927 |
2938 // Set the details for entry. | 2928 // Set the details for entry. |
(...skipping 5360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8299 } else { | 8289 } else { |
8300 value &= ~(1 << bit_position); | 8290 value &= ~(1 << bit_position); |
8301 } | 8291 } |
8302 return value; | 8292 return value; |
8303 } | 8293 } |
8304 }; | 8294 }; |
8305 | 8295 |
8306 } } // namespace v8::internal | 8296 } } // namespace v8::internal |
8307 | 8297 |
8308 #endif // V8_OBJECTS_H_ | 8298 #endif // V8_OBJECTS_H_ |
OLD | NEW |