Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: src/property.h

Issue 170073003: Consistent use of const for LookupResult. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.h ('k') | src/property-details.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 holder_ = holder; 235 holder_ = holder;
236 details_ = PropertyDetails(NONE, INTERCEPTOR, Representation::Tagged()); 236 details_ = PropertyDetails(NONE, INTERCEPTOR, Representation::Tagged());
237 } 237 }
238 238
239 void NotFound() { 239 void NotFound() {
240 lookup_type_ = NOT_FOUND; 240 lookup_type_ = NOT_FOUND;
241 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None()); 241 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None());
242 holder_ = NULL; 242 holder_ = NULL;
243 } 243 }
244 244
245 JSObject* holder() { 245 JSObject* holder() const {
246 ASSERT(IsFound()); 246 ASSERT(IsFound());
247 return JSObject::cast(holder_); 247 return JSObject::cast(holder_);
248 } 248 }
249 249
250 JSProxy* proxy() { 250 JSProxy* proxy() const {
251 ASSERT(IsFound()); 251 ASSERT(IsFound());
252 return JSProxy::cast(holder_); 252 return JSProxy::cast(holder_);
253 } 253 }
254 254
255 PropertyType type() { 255 PropertyType type() const {
256 ASSERT(IsFound()); 256 ASSERT(IsFound());
257 return details_.type(); 257 return details_.type();
258 } 258 }
259 259
260 Representation representation() { 260 Representation representation() const {
261 ASSERT(IsFound()); 261 ASSERT(IsFound());
262 ASSERT(!IsTransition()); 262 ASSERT(!IsTransition());
263 ASSERT(details_.type() != NONEXISTENT); 263 ASSERT(details_.type() != NONEXISTENT);
264 return details_.representation(); 264 return details_.representation();
265 } 265 }
266 266
267 PropertyAttributes GetAttributes() { 267 PropertyAttributes GetAttributes() const {
268 ASSERT(!IsTransition()); 268 ASSERT(!IsTransition());
269 ASSERT(IsFound()); 269 ASSERT(IsFound());
270 ASSERT(details_.type() != NONEXISTENT); 270 ASSERT(details_.type() != NONEXISTENT);
271 return details_.attributes(); 271 return details_.attributes();
272 } 272 }
273 273
274 PropertyDetails GetPropertyDetails() { 274 PropertyDetails GetPropertyDetails() const {
275 ASSERT(!IsTransition()); 275 ASSERT(!IsTransition());
276 return details_; 276 return details_;
277 } 277 }
278 278
279 bool IsFastPropertyType() { 279 bool IsFastPropertyType() const {
280 ASSERT(IsFound()); 280 ASSERT(IsFound());
281 return IsTransition() || type() != NORMAL; 281 return IsTransition() || type() != NORMAL;
282 } 282 }
283 283
284 // Property callbacks does not include transitions to callbacks. 284 // Property callbacks does not include transitions to callbacks.
285 bool IsPropertyCallbacks() { 285 bool IsPropertyCallbacks() const {
286 ASSERT(!(details_.type() == CALLBACKS && !IsFound())); 286 ASSERT(!(details_.type() == CALLBACKS && !IsFound()));
287 return details_.type() == CALLBACKS; 287 return details_.type() == CALLBACKS;
288 } 288 }
289 289
290 bool IsReadOnly() { 290 bool IsReadOnly() const {
291 ASSERT(IsFound()); 291 ASSERT(IsFound());
292 ASSERT(!IsTransition()); 292 ASSERT(!IsTransition());
293 ASSERT(details_.type() != NONEXISTENT); 293 ASSERT(details_.type() != NONEXISTENT);
294 return details_.IsReadOnly(); 294 return details_.IsReadOnly();
295 } 295 }
296 296
297 bool IsField() { 297 bool IsField() const {
298 ASSERT(!(details_.type() == FIELD && !IsFound())); 298 ASSERT(!(details_.type() == FIELD && !IsFound()));
299 return details_.type() == FIELD; 299 return details_.type() == FIELD;
300 } 300 }
301 301
302 bool IsNormal() { 302 bool IsNormal() const {
303 ASSERT(!(details_.type() == NORMAL && !IsFound())); 303 ASSERT(!(details_.type() == NORMAL && !IsFound()));
304 return details_.type() == NORMAL; 304 return details_.type() == NORMAL;
305 } 305 }
306 306
307 bool IsConstant() { 307 bool IsConstant() const {
308 ASSERT(!(details_.type() == CONSTANT && !IsFound())); 308 ASSERT(!(details_.type() == CONSTANT && !IsFound()));
309 return details_.type() == CONSTANT; 309 return details_.type() == CONSTANT;
310 } 310 }
311 311
312 bool IsConstantFunction() { 312 bool IsConstantFunction() const {
313 return IsConstant() && GetValue()->IsJSFunction(); 313 return IsConstant() && GetValue()->IsJSFunction();
314 } 314 }
315 315
316 bool IsDontDelete() { return details_.IsDontDelete(); } 316 bool IsDontDelete() const { return details_.IsDontDelete(); }
317 bool IsDontEnum() { return details_.IsDontEnum(); } 317 bool IsDontEnum() const { return details_.IsDontEnum(); }
318 bool IsFound() { return lookup_type_ != NOT_FOUND; } 318 bool IsFound() const { return lookup_type_ != NOT_FOUND; }
319 bool IsTransition() { return lookup_type_ == TRANSITION_TYPE; } 319 bool IsTransition() const { return lookup_type_ == TRANSITION_TYPE; }
320 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } 320 bool IsHandler() const { return lookup_type_ == HANDLER_TYPE; }
321 bool IsInterceptor() { return lookup_type_ == INTERCEPTOR_TYPE; } 321 bool IsInterceptor() const { return lookup_type_ == INTERCEPTOR_TYPE; }
322 322
323 // Is the result is a property excluding transitions and the null descriptor? 323 // Is the result is a property excluding transitions and the null descriptor?
324 bool IsProperty() { 324 bool IsProperty() const {
325 return IsFound() && !IsTransition(); 325 return IsFound() && !IsTransition();
326 } 326 }
327 327
328 bool IsDataProperty() { 328 bool IsDataProperty() const {
329 switch (type()) { 329 switch (type()) {
330 case FIELD: 330 case FIELD:
331 case NORMAL: 331 case NORMAL:
332 case CONSTANT: 332 case CONSTANT:
333 return true; 333 return true;
334 case CALLBACKS: { 334 case CALLBACKS: {
335 Object* callback = GetCallbackObject(); 335 Object* callback = GetCallbackObject();
336 return callback->IsAccessorInfo() || callback->IsForeign(); 336 return callback->IsAccessorInfo() || callback->IsForeign();
337 } 337 }
338 case HANDLER: 338 case HANDLER:
339 case INTERCEPTOR: 339 case INTERCEPTOR:
340 case TRANSITION: 340 case TRANSITION:
341 case NONEXISTENT: 341 case NONEXISTENT:
342 return false; 342 return false;
343 } 343 }
344 UNREACHABLE(); 344 UNREACHABLE();
345 return false; 345 return false;
346 } 346 }
347 347
348 bool IsCacheable() { return cacheable_; } 348 bool IsCacheable() const { return cacheable_; }
349 void DisallowCaching() { cacheable_ = false; } 349 void DisallowCaching() { cacheable_ = false; }
350 350
351 Object* GetLazyValue() { 351 Object* GetLazyValue() const {
352 switch (type()) { 352 switch (type()) {
353 case FIELD: 353 case FIELD:
354 return holder()->RawFastPropertyAt(GetFieldIndex().field_index()); 354 return holder()->RawFastPropertyAt(GetFieldIndex().field_index());
355 case NORMAL: { 355 case NORMAL: {
356 Object* value; 356 Object* value;
357 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); 357 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry());
358 if (holder()->IsGlobalObject()) { 358 if (holder()->IsGlobalObject()) {
359 value = PropertyCell::cast(value)->value(); 359 value = PropertyCell::cast(value)->value();
360 } 360 }
361 return value; 361 return value;
362 } 362 }
363 case CONSTANT: 363 case CONSTANT:
364 return GetConstant(); 364 return GetConstant();
365 case CALLBACKS: 365 case CALLBACKS:
366 case HANDLER: 366 case HANDLER:
367 case INTERCEPTOR: 367 case INTERCEPTOR:
368 case TRANSITION: 368 case TRANSITION:
369 case NONEXISTENT: 369 case NONEXISTENT:
370 return isolate()->heap()->the_hole_value(); 370 return isolate()->heap()->the_hole_value();
371 } 371 }
372 UNREACHABLE(); 372 UNREACHABLE();
373 return NULL; 373 return NULL;
374 } 374 }
375 375
376 Map* GetTransitionTarget(Map* map) { 376 Map* GetTransitionTarget(Map* map) const {
377 ASSERT(IsTransition()); 377 ASSERT(IsTransition());
378 TransitionArray* transitions = map->transitions(); 378 TransitionArray* transitions = map->transitions();
379 return transitions->GetTarget(number_); 379 return transitions->GetTarget(number_);
380 } 380 }
381 381
382 Map* GetTransitionTarget() { 382 Map* GetTransitionTarget() const {
383 return GetTransitionTarget(holder()->map()); 383 return GetTransitionTarget(holder()->map());
384 } 384 }
385 385
386 PropertyDetails GetTransitionDetails(Map* map) { 386 PropertyDetails GetTransitionDetails(Map* map) const {
387 ASSERT(IsTransition()); 387 ASSERT(IsTransition());
388 TransitionArray* transitions = map->transitions(); 388 TransitionArray* transitions = map->transitions();
389 return transitions->GetTargetDetails(number_); 389 return transitions->GetTargetDetails(number_);
390 } 390 }
391 391
392 PropertyDetails GetTransitionDetails() { 392 PropertyDetails GetTransitionDetails() const {
393 return GetTransitionDetails(holder()->map()); 393 return GetTransitionDetails(holder()->map());
394 } 394 }
395 395
396 bool IsTransitionToField(Map* map) { 396 bool IsTransitionToField(Map* map) const {
397 return IsTransition() && GetTransitionDetails(map).type() == FIELD; 397 return IsTransition() && GetTransitionDetails(map).type() == FIELD;
398 } 398 }
399 399
400 bool IsTransitionToConstant(Map* map) { 400 bool IsTransitionToConstant(Map* map) const {
401 return IsTransition() && GetTransitionDetails(map).type() == CONSTANT; 401 return IsTransition() && GetTransitionDetails(map).type() == CONSTANT;
402 } 402 }
403 403
404 Map* GetTransitionMap() { 404 Map* GetTransitionMap() const {
405 ASSERT(IsTransition()); 405 ASSERT(IsTransition());
406 return Map::cast(GetValue()); 406 return Map::cast(GetValue());
407 } 407 }
408 408
409 Map* GetTransitionMapFromMap(Map* map) { 409 Map* GetTransitionMapFromMap(Map* map) const {
410 ASSERT(IsTransition()); 410 ASSERT(IsTransition());
411 return map->transitions()->GetTarget(number_); 411 return map->transitions()->GetTarget(number_);
412 } 412 }
413 413
414 int GetTransitionIndex() { 414 int GetTransitionIndex() const {
415 ASSERT(IsTransition()); 415 ASSERT(IsTransition());
416 return number_; 416 return number_;
417 } 417 }
418 418
419 int GetDescriptorIndex() { 419 int GetDescriptorIndex() const {
420 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 420 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
421 return number_; 421 return number_;
422 } 422 }
423 423
424 PropertyIndex GetFieldIndex() { 424 PropertyIndex GetFieldIndex() const {
425 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 425 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
426 return PropertyIndex::NewFieldIndex(GetFieldIndexFromMap(holder()->map())); 426 return PropertyIndex::NewFieldIndex(GetFieldIndexFromMap(holder()->map()));
427 } 427 }
428 428
429 int GetLocalFieldIndexFromMap(Map* map) { 429 int GetLocalFieldIndexFromMap(Map* map) const {
430 return GetFieldIndexFromMap(map) - map->inobject_properties(); 430 return GetFieldIndexFromMap(map) - map->inobject_properties();
431 } 431 }
432 432
433 int GetDictionaryEntry() { 433 int GetDictionaryEntry() const {
434 ASSERT(lookup_type_ == DICTIONARY_TYPE); 434 ASSERT(lookup_type_ == DICTIONARY_TYPE);
435 return number_; 435 return number_;
436 } 436 }
437 437
438 JSFunction* GetConstantFunction() { 438 JSFunction* GetConstantFunction() const {
439 ASSERT(type() == CONSTANT); 439 ASSERT(type() == CONSTANT);
440 return JSFunction::cast(GetValue()); 440 return JSFunction::cast(GetValue());
441 } 441 }
442 442
443 Object* GetConstantFromMap(Map* map) { 443 Object* GetConstantFromMap(Map* map) const {
444 ASSERT(type() == CONSTANT); 444 ASSERT(type() == CONSTANT);
445 return GetValueFromMap(map); 445 return GetValueFromMap(map);
446 } 446 }
447 447
448 JSFunction* GetConstantFunctionFromMap(Map* map) { 448 JSFunction* GetConstantFunctionFromMap(Map* map) const {
449 return JSFunction::cast(GetConstantFromMap(map)); 449 return JSFunction::cast(GetConstantFromMap(map));
450 } 450 }
451 451
452 Object* GetConstant() { 452 Object* GetConstant() const {
453 ASSERT(type() == CONSTANT); 453 ASSERT(type() == CONSTANT);
454 return GetValue(); 454 return GetValue();
455 } 455 }
456 456
457 Object* GetCallbackObject() { 457 Object* GetCallbackObject() const {
458 ASSERT(type() == CALLBACKS && !IsTransition()); 458 ASSERT(type() == CALLBACKS && !IsTransition());
459 return GetValue(); 459 return GetValue();
460 } 460 }
461 461
462 #ifdef OBJECT_PRINT 462 #ifdef OBJECT_PRINT
463 void Print(FILE* out); 463 void Print(FILE* out);
464 #endif 464 #endif
465 465
466 Object* GetValue() { 466 Object* GetValue() const {
467 if (lookup_type_ == DESCRIPTOR_TYPE) { 467 if (lookup_type_ == DESCRIPTOR_TYPE) {
468 return GetValueFromMap(holder()->map()); 468 return GetValueFromMap(holder()->map());
469 } 469 }
470 // In the dictionary case, the data is held in the value field. 470 // In the dictionary case, the data is held in the value field.
471 ASSERT(lookup_type_ == DICTIONARY_TYPE); 471 ASSERT(lookup_type_ == DICTIONARY_TYPE);
472 return holder()->GetNormalizedProperty(this); 472 return holder()->GetNormalizedProperty(this);
473 } 473 }
474 474
475 Object* GetValueFromMap(Map* map) const { 475 Object* GetValueFromMap(Map* map) const {
476 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); 476 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
(...skipping 26 matching lines...) Expand all
503 JSReceiver* holder_; 503 JSReceiver* holder_;
504 int number_; 504 int number_;
505 bool cacheable_; 505 bool cacheable_;
506 PropertyDetails details_; 506 PropertyDetails details_;
507 }; 507 };
508 508
509 509
510 } } // namespace v8::internal 510 } } // namespace v8::internal
511 511
512 #endif // V8_PROPERTY_H_ 512 #endif // V8_PROPERTY_H_
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698