| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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_PROPERTY_H_ | 28 #ifndef V8_PROPERTY_H_ |
| 29 #define V8_PROPERTY_H_ | 29 #define V8_PROPERTY_H_ |
| 30 | 30 |
| 31 #include "allocation.h" |
| 32 |
| 31 namespace v8 { | 33 namespace v8 { |
| 32 namespace internal { | 34 namespace internal { |
| 33 | 35 |
| 34 | 36 |
| 35 // Abstraction for elements in instance-descriptor arrays. | 37 // Abstraction for elements in instance-descriptor arrays. |
| 36 // | 38 // |
| 37 // Each descriptor has a key, property attributes, property type, | 39 // Each descriptor has a key, property attributes, property type, |
| 38 // property index (in the actual instance-descriptor array) and | 40 // property index (in the actual instance-descriptor array) and |
| 39 // optionally a piece of data. | 41 // optionally a piece of data. |
| 40 // | 42 // |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 CallbacksDescriptor(String* key, | 159 CallbacksDescriptor(String* key, |
| 158 Object* proxy, | 160 Object* proxy, |
| 159 PropertyAttributes attributes, | 161 PropertyAttributes attributes, |
| 160 int index = 0) | 162 int index = 0) |
| 161 : Descriptor(key, proxy, attributes, CALLBACKS, index) {} | 163 : Descriptor(key, proxy, attributes, CALLBACKS, index) {} |
| 162 }; | 164 }; |
| 163 | 165 |
| 164 | 166 |
| 165 class LookupResult BASE_EMBEDDED { | 167 class LookupResult BASE_EMBEDDED { |
| 166 public: | 168 public: |
| 167 // Where did we find the result; | |
| 168 enum { | |
| 169 NOT_FOUND, | |
| 170 DESCRIPTOR_TYPE, | |
| 171 DICTIONARY_TYPE, | |
| 172 INTERCEPTOR_TYPE, | |
| 173 CONSTANT_TYPE | |
| 174 } lookup_type_; | |
| 175 | |
| 176 LookupResult() | 169 LookupResult() |
| 177 : lookup_type_(NOT_FOUND), | 170 : lookup_type_(NOT_FOUND), |
| 178 cacheable_(true), | 171 cacheable_(true), |
| 179 details_(NONE, NORMAL) {} | 172 details_(NONE, NORMAL) {} |
| 180 | 173 |
| 181 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { | 174 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { |
| 182 lookup_type_ = DESCRIPTOR_TYPE; | 175 lookup_type_ = DESCRIPTOR_TYPE; |
| 183 holder_ = holder; | 176 holder_ = holder; |
| 184 details_ = details; | 177 details_ = details; |
| 185 number_ = number; | 178 number_ = number; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 202 number_ = -1; | 195 number_ = -1; |
| 203 } | 196 } |
| 204 | 197 |
| 205 void DictionaryResult(JSObject* holder, int entry) { | 198 void DictionaryResult(JSObject* holder, int entry) { |
| 206 lookup_type_ = DICTIONARY_TYPE; | 199 lookup_type_ = DICTIONARY_TYPE; |
| 207 holder_ = holder; | 200 holder_ = holder; |
| 208 details_ = holder->property_dictionary()->DetailsAt(entry); | 201 details_ = holder->property_dictionary()->DetailsAt(entry); |
| 209 number_ = entry; | 202 number_ = entry; |
| 210 } | 203 } |
| 211 | 204 |
| 205 void HandlerResult() { |
| 206 lookup_type_ = HANDLER_TYPE; |
| 207 holder_ = NULL; |
| 208 details_ = PropertyDetails(NONE, HANDLER); |
| 209 } |
| 210 |
| 212 void InterceptorResult(JSObject* holder) { | 211 void InterceptorResult(JSObject* holder) { |
| 213 lookup_type_ = INTERCEPTOR_TYPE; | 212 lookup_type_ = INTERCEPTOR_TYPE; |
| 214 holder_ = holder; | 213 holder_ = holder; |
| 215 details_ = PropertyDetails(NONE, INTERCEPTOR); | 214 details_ = PropertyDetails(NONE, INTERCEPTOR); |
| 216 } | 215 } |
| 217 | 216 |
| 218 void NotFound() { | 217 void NotFound() { |
| 219 lookup_type_ = NOT_FOUND; | 218 lookup_type_ = NOT_FOUND; |
| 220 } | 219 } |
| 221 | 220 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 236 | 235 |
| 237 PropertyDetails GetPropertyDetails() { | 236 PropertyDetails GetPropertyDetails() { |
| 238 return details_; | 237 return details_; |
| 239 } | 238 } |
| 240 | 239 |
| 241 bool IsReadOnly() { return details_.IsReadOnly(); } | 240 bool IsReadOnly() { return details_.IsReadOnly(); } |
| 242 bool IsDontDelete() { return details_.IsDontDelete(); } | 241 bool IsDontDelete() { return details_.IsDontDelete(); } |
| 243 bool IsDontEnum() { return details_.IsDontEnum(); } | 242 bool IsDontEnum() { return details_.IsDontEnum(); } |
| 244 bool IsDeleted() { return details_.IsDeleted(); } | 243 bool IsDeleted() { return details_.IsDeleted(); } |
| 245 bool IsFound() { return lookup_type_ != NOT_FOUND; } | 244 bool IsFound() { return lookup_type_ != NOT_FOUND; } |
| 245 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } |
| 246 | 246 |
| 247 // Is the result is a property excluding transitions and the null | 247 // Is the result is a property excluding transitions and the null |
| 248 // descriptor? | 248 // descriptor? |
| 249 bool IsProperty() { | 249 bool IsProperty() { |
| 250 return IsFound() && (type() < FIRST_PHANTOM_PROPERTY_TYPE); | 250 return IsFound() && (type() < FIRST_PHANTOM_PROPERTY_TYPE); |
| 251 } | 251 } |
| 252 | 252 |
| 253 // Is the result a property or a transition? | 253 // Is the result a property or a transition? |
| 254 bool IsPropertyOrTransition() { | 254 bool IsPropertyOrTransition() { |
| 255 return IsFound() && (type() != NULL_DESCRIPTOR); | 255 return IsFound() && (type() != NULL_DESCRIPTOR); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 if (lookup_type_ == DESCRIPTOR_TYPE) { | 336 if (lookup_type_ == DESCRIPTOR_TYPE) { |
| 337 DescriptorArray* descriptors = holder()->map()->instance_descriptors(); | 337 DescriptorArray* descriptors = holder()->map()->instance_descriptors(); |
| 338 return descriptors->GetValue(number_); | 338 return descriptors->GetValue(number_); |
| 339 } | 339 } |
| 340 // In the dictionary case, the data is held in the value field. | 340 // In the dictionary case, the data is held in the value field. |
| 341 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 341 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
| 342 return holder()->GetNormalizedProperty(this); | 342 return holder()->GetNormalizedProperty(this); |
| 343 } | 343 } |
| 344 | 344 |
| 345 private: | 345 private: |
| 346 // Where did we find the result; |
| 347 enum { |
| 348 NOT_FOUND, |
| 349 DESCRIPTOR_TYPE, |
| 350 DICTIONARY_TYPE, |
| 351 HANDLER_TYPE, |
| 352 INTERCEPTOR_TYPE, |
| 353 CONSTANT_TYPE |
| 354 } lookup_type_; |
| 355 |
| 346 JSObject* holder_; | 356 JSObject* holder_; |
| 347 int number_; | 357 int number_; |
| 348 bool cacheable_; | 358 bool cacheable_; |
| 349 PropertyDetails details_; | 359 PropertyDetails details_; |
| 350 }; | 360 }; |
| 351 | 361 |
| 352 | 362 |
| 353 } } // namespace v8::internal | 363 } } // namespace v8::internal |
| 354 | 364 |
| 355 #endif // V8_PROPERTY_H_ | 365 #endif // V8_PROPERTY_H_ |
| OLD | NEW |