| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 class CallbacksDescriptor: public Descriptor { | 157 class CallbacksDescriptor: public Descriptor { |
| 158 public: | 158 public: |
| 159 CallbacksDescriptor(String* key, | 159 CallbacksDescriptor(String* key, |
| 160 Object* foreign, | 160 Object* foreign, |
| 161 PropertyAttributes attributes, | 161 PropertyAttributes attributes, |
| 162 int index = 0) | 162 int index = 0) |
| 163 : Descriptor(key, foreign, attributes, CALLBACKS, index) {} | 163 : Descriptor(key, foreign, attributes, CALLBACKS, index) {} |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 | 166 |
| 167 template <class T> |
| 168 bool IsPropertyDescriptor(T* desc) { |
| 169 switch (desc->type()) { |
| 170 case NORMAL: |
| 171 case FIELD: |
| 172 case CONSTANT_FUNCTION: |
| 173 case HANDLER: |
| 174 case INTERCEPTOR: |
| 175 return true; |
| 176 case CALLBACKS: { |
| 177 Object* callback_object = desc->GetCallbackObject(); |
| 178 // Non-JavaScript (i.e. native) accessors are always a property, otherwise |
| 179 // either the getter or the setter must be an accessor. Put another way: |
| 180 // If we only see map transitions and holes in a pair, this is not a |
| 181 // property. |
| 182 return (!callback_object->IsAccessorPair() || |
| 183 AccessorPair::cast(callback_object)->ContainsAccessor()); |
| 184 } |
| 185 case MAP_TRANSITION: |
| 186 case ELEMENTS_TRANSITION: |
| 187 case CONSTANT_TRANSITION: |
| 188 case NULL_DESCRIPTOR: |
| 189 return false; |
| 190 } |
| 191 UNREACHABLE(); // keep the compiler happy |
| 192 return false; |
| 193 } |
| 194 |
| 195 |
| 167 class LookupResult BASE_EMBEDDED { | 196 class LookupResult BASE_EMBEDDED { |
| 168 public: | 197 public: |
| 169 explicit LookupResult(Isolate* isolate) | 198 explicit LookupResult(Isolate* isolate) |
| 170 : isolate_(isolate), | 199 : isolate_(isolate), |
| 171 next_(isolate->top_lookup_result()), | 200 next_(isolate->top_lookup_result()), |
| 172 lookup_type_(NOT_FOUND), | 201 lookup_type_(NOT_FOUND), |
| 173 holder_(NULL), | 202 holder_(NULL), |
| 174 cacheable_(true), | 203 cacheable_(true), |
| 175 details_(NONE, NORMAL) { | 204 details_(NONE, NORMAL) { |
| 176 isolate->SetTopLookupResult(this); | 205 isolate->SetTopLookupResult(this); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 return details_; | 283 return details_; |
| 255 } | 284 } |
| 256 | 285 |
| 257 bool IsReadOnly() { return details_.IsReadOnly(); } | 286 bool IsReadOnly() { return details_.IsReadOnly(); } |
| 258 bool IsDontDelete() { return details_.IsDontDelete(); } | 287 bool IsDontDelete() { return details_.IsDontDelete(); } |
| 259 bool IsDontEnum() { return details_.IsDontEnum(); } | 288 bool IsDontEnum() { return details_.IsDontEnum(); } |
| 260 bool IsDeleted() { return details_.IsDeleted(); } | 289 bool IsDeleted() { return details_.IsDeleted(); } |
| 261 bool IsFound() { return lookup_type_ != NOT_FOUND; } | 290 bool IsFound() { return lookup_type_ != NOT_FOUND; } |
| 262 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } | 291 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } |
| 263 | 292 |
| 264 // Is the result is a property excluding transitions and the null | 293 // Is the result is a property excluding transitions and the null descriptor? |
| 265 // descriptor? | |
| 266 bool IsProperty() { | 294 bool IsProperty() { |
| 267 return IsFound() && IsRealProperty(GetPropertyDetails().type()); | 295 return IsFound() && IsPropertyDescriptor(this); |
| 268 } | 296 } |
| 269 | 297 |
| 270 bool IsCacheable() { return cacheable_; } | 298 bool IsCacheable() { return cacheable_; } |
| 271 void DisallowCaching() { cacheable_ = false; } | 299 void DisallowCaching() { cacheable_ = false; } |
| 272 | 300 |
| 273 Object* GetLazyValue() { | 301 Object* GetLazyValue() { |
| 274 switch (type()) { | 302 switch (type()) { |
| 275 case FIELD: | 303 case FIELD: |
| 276 return holder()->FastPropertyAt(GetFieldIndex()); | 304 return holder()->FastPropertyAt(GetFieldIndex()); |
| 277 case NORMAL: { | 305 case NORMAL: { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 JSReceiver* holder_; | 403 JSReceiver* holder_; |
| 376 int number_; | 404 int number_; |
| 377 bool cacheable_; | 405 bool cacheable_; |
| 378 PropertyDetails details_; | 406 PropertyDetails details_; |
| 379 }; | 407 }; |
| 380 | 408 |
| 381 | 409 |
| 382 } } // namespace v8::internal | 410 } } // namespace v8::internal |
| 383 | 411 |
| 384 #endif // V8_PROPERTY_H_ | 412 #endif // V8_PROPERTY_H_ |
| OLD | NEW |