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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // The infrastructure used for (localized) message reporting in V8. | 5 // The infrastructure used for (localized) message reporting in V8. |
6 // | 6 // |
7 // Note: there's a big unresolved issue about ownership of the data | 7 // Note: there's a big unresolved issue about ownership of the data |
8 // structures used by this framework. | 8 // structures used by this framework. |
9 | 9 |
10 #ifndef V8_MESSAGES_H_ | 10 #ifndef V8_MESSAGES_H_ |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 Handle<JSMessageObject> message); | 477 Handle<JSMessageObject> message); |
478 | 478 |
479 static void DefaultMessageReport(Isolate* isolate, const MessageLocation* loc, | 479 static void DefaultMessageReport(Isolate* isolate, const MessageLocation* loc, |
480 Handle<Object> message_obj); | 480 Handle<Object> message_obj); |
481 static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); | 481 static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); |
482 static base::SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate, | 482 static base::SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate, |
483 Handle<Object> data); | 483 Handle<Object> data); |
484 }; | 484 }; |
485 | 485 |
486 | 486 |
487 class ErrorToStringHelper { | |
488 public: | |
489 ErrorToStringHelper() : visited_(0) {} | |
490 | |
491 MUST_USE_RESULT MaybeHandle<String> Stringify(Isolate* isolate, | |
492 Handle<JSObject> error); | |
493 | |
494 private: | |
495 class VisitedScope { | |
496 public: | |
497 VisitedScope(ErrorToStringHelper* helper, Handle<JSObject> error) | |
498 : helper_(helper), has_visited_(false) { | |
499 for (const Handle<JSObject>& visited : helper->visited_) { | |
500 if (visited.is_identical_to(error)) { | |
501 has_visited_ = true; | |
502 break; | |
503 } | |
504 } | |
505 helper->visited_.Add(error); | |
506 } | |
507 ~VisitedScope() { helper_->visited_.RemoveLast(); } | |
508 bool has_visited() { return has_visited_; } | |
509 | |
510 private: | |
511 ErrorToStringHelper* helper_; | |
512 bool has_visited_; | |
513 }; | |
514 | |
515 static bool ShadowsInternalError(Isolate* isolate, | |
516 LookupIterator* property_lookup, | |
517 LookupIterator* internal_error_lookup); | |
518 | |
519 static MUST_USE_RESULT MaybeHandle<String> GetStringifiedProperty( | |
520 Isolate* isolate, LookupIterator* property_lookup, | |
521 Handle<String> default_value); | |
522 | |
523 List<Handle<JSObject> > visited_; | |
524 }; | |
525 } // namespace internal | 487 } // namespace internal |
526 } // namespace v8 | 488 } // namespace v8 |
527 | 489 |
528 #endif // V8_MESSAGES_H_ | 490 #endif // V8_MESSAGES_H_ |
OLD | NEW |