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 | |
196 class LookupResult BASE_EMBEDDED { | 167 class LookupResult BASE_EMBEDDED { |
197 public: | 168 public: |
198 explicit LookupResult(Isolate* isolate) | 169 explicit LookupResult(Isolate* isolate) |
199 : isolate_(isolate), | 170 : isolate_(isolate), |
200 next_(isolate->top_lookup_result()), | 171 next_(isolate->top_lookup_result()), |
201 lookup_type_(NOT_FOUND), | 172 lookup_type_(NOT_FOUND), |
202 holder_(NULL), | 173 holder_(NULL), |
203 cacheable_(true), | 174 cacheable_(true), |
204 details_(NONE, NORMAL) { | 175 details_(NONE, NORMAL) { |
205 isolate->SetTopLookupResult(this); | 176 isolate->SetTopLookupResult(this); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 return details_; | 254 return details_; |
284 } | 255 } |
285 | 256 |
286 bool IsReadOnly() { return details_.IsReadOnly(); } | 257 bool IsReadOnly() { return details_.IsReadOnly(); } |
287 bool IsDontDelete() { return details_.IsDontDelete(); } | 258 bool IsDontDelete() { return details_.IsDontDelete(); } |
288 bool IsDontEnum() { return details_.IsDontEnum(); } | 259 bool IsDontEnum() { return details_.IsDontEnum(); } |
289 bool IsDeleted() { return details_.IsDeleted(); } | 260 bool IsDeleted() { return details_.IsDeleted(); } |
290 bool IsFound() { return lookup_type_ != NOT_FOUND; } | 261 bool IsFound() { return lookup_type_ != NOT_FOUND; } |
291 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } | 262 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } |
292 | 263 |
293 // Is the result is a property excluding transitions and the null descriptor? | 264 // Is the result is a property excluding transitions and the null |
| 265 // descriptor? |
294 bool IsProperty() { | 266 bool IsProperty() { |
295 return IsFound() && IsPropertyDescriptor(this); | 267 return IsFound() && IsRealProperty(GetPropertyDetails().type()); |
296 } | 268 } |
297 | 269 |
298 bool IsCacheable() { return cacheable_; } | 270 bool IsCacheable() { return cacheable_; } |
299 void DisallowCaching() { cacheable_ = false; } | 271 void DisallowCaching() { cacheable_ = false; } |
300 | 272 |
301 Object* GetLazyValue() { | 273 Object* GetLazyValue() { |
302 switch (type()) { | 274 switch (type()) { |
303 case FIELD: | 275 case FIELD: |
304 return holder()->FastPropertyAt(GetFieldIndex()); | 276 return holder()->FastPropertyAt(GetFieldIndex()); |
305 case NORMAL: { | 277 case NORMAL: { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 JSReceiver* holder_; | 375 JSReceiver* holder_; |
404 int number_; | 376 int number_; |
405 bool cacheable_; | 377 bool cacheable_; |
406 PropertyDetails details_; | 378 PropertyDetails details_; |
407 }; | 379 }; |
408 | 380 |
409 | 381 |
410 } } // namespace v8::internal | 382 } } // namespace v8::internal |
411 | 383 |
412 #endif // V8_PROPERTY_H_ | 384 #endif // V8_PROPERTY_H_ |
OLD | NEW |