OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 return reinterpret_cast<Dictionary<Shape, Key>*>(obj); | 2144 return reinterpret_cast<Dictionary<Shape, Key>*>(obj); |
2145 } | 2145 } |
2146 | 2146 |
2147 // Returns the value at entry. | 2147 // Returns the value at entry. |
2148 Object* ValueAt(int entry) { | 2148 Object* ValueAt(int entry) { |
2149 return this->get(HashTable<Shape, Key>::EntryToIndex(entry)+1); | 2149 return this->get(HashTable<Shape, Key>::EntryToIndex(entry)+1); |
2150 } | 2150 } |
2151 | 2151 |
2152 // Set the value for entry. | 2152 // Set the value for entry. |
2153 void ValueAtPut(int entry, Object* value) { | 2153 void ValueAtPut(int entry, Object* value) { |
| 2154 // Check that this value can actually be written. |
| 2155 PropertyDetails details = DetailsAt(entry); |
| 2156 // If a value has not been initilized we allow writing to it even if |
| 2157 // it is read only (a declared const that has not been initialized). |
| 2158 if (details.IsReadOnly() && !ValueAt(entry)->IsTheHole()) return; |
2154 this->set(HashTable<Shape, Key>::EntryToIndex(entry)+1, value); | 2159 this->set(HashTable<Shape, Key>::EntryToIndex(entry)+1, value); |
2155 } | 2160 } |
2156 | 2161 |
2157 // Returns the property details for the property at entry. | 2162 // Returns the property details for the property at entry. |
2158 PropertyDetails DetailsAt(int entry) { | 2163 PropertyDetails DetailsAt(int entry) { |
2159 ASSERT(entry >= 0); // Not found is -1, which is not caught by get(). | 2164 ASSERT(entry >= 0); // Not found is -1, which is not caught by get(). |
2160 return PropertyDetails( | 2165 return PropertyDetails( |
2161 Smi::cast(this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 2))); | 2166 Smi::cast(this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 2))); |
2162 } | 2167 } |
2163 | 2168 |
(...skipping 3114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5278 } else { | 5283 } else { |
5279 value &= ~(1 << bit_position); | 5284 value &= ~(1 << bit_position); |
5280 } | 5285 } |
5281 return value; | 5286 return value; |
5282 } | 5287 } |
5283 }; | 5288 }; |
5284 | 5289 |
5285 } } // namespace v8::internal | 5290 } } // namespace v8::internal |
5286 | 5291 |
5287 #endif // V8_OBJECTS_H_ | 5292 #endif // V8_OBJECTS_H_ |
OLD | NEW |