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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 CallbacksDescriptor(String* key, | 159 CallbacksDescriptor(String* key, |
160 Object* proxy, | 160 Object* proxy, |
161 PropertyAttributes attributes, | 161 PropertyAttributes attributes, |
162 int index = 0) | 162 int index = 0) |
163 : Descriptor(key, proxy, attributes, CALLBACKS, index) {} | 163 : Descriptor(key, proxy, attributes, CALLBACKS, index) {} |
164 }; | 164 }; |
165 | 165 |
166 | 166 |
167 class LookupResult BASE_EMBEDDED { | 167 class LookupResult BASE_EMBEDDED { |
168 public: | 168 public: |
169 // Where did we find the result; | |
170 enum { | |
171 NOT_FOUND, | |
172 DESCRIPTOR_TYPE, | |
173 DICTIONARY_TYPE, | |
174 INTERCEPTOR_TYPE, | |
175 CONSTANT_TYPE | |
176 } lookup_type_; | |
177 | |
178 LookupResult() | 169 LookupResult() |
179 : lookup_type_(NOT_FOUND), | 170 : lookup_type_(NOT_FOUND), |
180 cacheable_(true), | 171 cacheable_(true), |
181 details_(NONE, NORMAL) {} | 172 details_(NONE, NORMAL) {} |
182 | 173 |
183 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { | 174 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { |
184 lookup_type_ = DESCRIPTOR_TYPE; | 175 lookup_type_ = DESCRIPTOR_TYPE; |
185 holder_ = holder; | 176 holder_ = holder; |
186 details_ = details; | 177 details_ = details; |
187 number_ = number; | 178 number_ = number; |
(...skipping 16 matching lines...) Expand all Loading... |
204 number_ = -1; | 195 number_ = -1; |
205 } | 196 } |
206 | 197 |
207 void DictionaryResult(JSObject* holder, int entry) { | 198 void DictionaryResult(JSObject* holder, int entry) { |
208 lookup_type_ = DICTIONARY_TYPE; | 199 lookup_type_ = DICTIONARY_TYPE; |
209 holder_ = holder; | 200 holder_ = holder; |
210 details_ = holder->property_dictionary()->DetailsAt(entry); | 201 details_ = holder->property_dictionary()->DetailsAt(entry); |
211 number_ = entry; | 202 number_ = entry; |
212 } | 203 } |
213 | 204 |
| 205 void HandlerResult() { |
| 206 lookup_type_ = HANDLER_TYPE; |
| 207 holder_ = NULL; |
| 208 details_ = PropertyDetails(NONE, HANDLER); |
| 209 } |
| 210 |
214 void InterceptorResult(JSObject* holder) { | 211 void InterceptorResult(JSObject* holder) { |
215 lookup_type_ = INTERCEPTOR_TYPE; | 212 lookup_type_ = INTERCEPTOR_TYPE; |
216 holder_ = holder; | 213 holder_ = holder; |
217 details_ = PropertyDetails(NONE, INTERCEPTOR); | 214 details_ = PropertyDetails(NONE, INTERCEPTOR); |
218 } | 215 } |
219 | 216 |
220 void NotFound() { | 217 void NotFound() { |
221 lookup_type_ = NOT_FOUND; | 218 lookup_type_ = NOT_FOUND; |
222 } | 219 } |
223 | 220 |
(...skipping 14 matching lines...) Expand all Loading... |
238 | 235 |
239 PropertyDetails GetPropertyDetails() { | 236 PropertyDetails GetPropertyDetails() { |
240 return details_; | 237 return details_; |
241 } | 238 } |
242 | 239 |
243 bool IsReadOnly() { return details_.IsReadOnly(); } | 240 bool IsReadOnly() { return details_.IsReadOnly(); } |
244 bool IsDontDelete() { return details_.IsDontDelete(); } | 241 bool IsDontDelete() { return details_.IsDontDelete(); } |
245 bool IsDontEnum() { return details_.IsDontEnum(); } | 242 bool IsDontEnum() { return details_.IsDontEnum(); } |
246 bool IsDeleted() { return details_.IsDeleted(); } | 243 bool IsDeleted() { return details_.IsDeleted(); } |
247 bool IsFound() { return lookup_type_ != NOT_FOUND; } | 244 bool IsFound() { return lookup_type_ != NOT_FOUND; } |
| 245 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } |
248 | 246 |
249 // Is the result is a property excluding transitions and the null | 247 // Is the result is a property excluding transitions and the null |
250 // descriptor? | 248 // descriptor? |
251 bool IsProperty() { | 249 bool IsProperty() { |
252 return IsFound() && (type() < FIRST_PHANTOM_PROPERTY_TYPE); | 250 return IsFound() && (type() < FIRST_PHANTOM_PROPERTY_TYPE); |
253 } | 251 } |
254 | 252 |
255 // Is the result a property or a transition? | 253 // Is the result a property or a transition? |
256 bool IsPropertyOrTransition() { | 254 bool IsPropertyOrTransition() { |
257 return IsFound() && (type() != NULL_DESCRIPTOR); | 255 return IsFound() && (type() != NULL_DESCRIPTOR); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (lookup_type_ == DESCRIPTOR_TYPE) { | 336 if (lookup_type_ == DESCRIPTOR_TYPE) { |
339 DescriptorArray* descriptors = holder()->map()->instance_descriptors(); | 337 DescriptorArray* descriptors = holder()->map()->instance_descriptors(); |
340 return descriptors->GetValue(number_); | 338 return descriptors->GetValue(number_); |
341 } | 339 } |
342 // 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. |
343 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 341 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
344 return holder()->GetNormalizedProperty(this); | 342 return holder()->GetNormalizedProperty(this); |
345 } | 343 } |
346 | 344 |
347 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 |
348 JSObject* holder_; | 356 JSObject* holder_; |
349 int number_; | 357 int number_; |
350 bool cacheable_; | 358 bool cacheable_; |
351 PropertyDetails details_; | 359 PropertyDetails details_; |
352 }; | 360 }; |
353 | 361 |
354 | 362 |
355 } } // namespace v8::internal | 363 } } // namespace v8::internal |
356 | 364 |
357 #endif // V8_PROPERTY_H_ | 365 #endif // V8_PROPERTY_H_ |
OLD | NEW |