Chromium Code Reviews| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 // Report a formatted message (needs JS allocation). | 450 // Report a formatted message (needs JS allocation). |
| 451 static void ReportMessage(Isolate* isolate, MessageLocation* loc, | 451 static void ReportMessage(Isolate* isolate, MessageLocation* loc, |
| 452 Handle<JSMessageObject> message); | 452 Handle<JSMessageObject> message); |
| 453 | 453 |
| 454 static void DefaultMessageReport(Isolate* isolate, const MessageLocation* loc, | 454 static void DefaultMessageReport(Isolate* isolate, const MessageLocation* loc, |
| 455 Handle<Object> message_obj); | 455 Handle<Object> message_obj); |
| 456 static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); | 456 static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); |
| 457 static base::SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate, | 457 static base::SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate, |
| 458 Handle<Object> data); | 458 Handle<Object> data); |
| 459 }; | 459 }; |
| 460 | |
| 461 | |
| 462 class ErrorToStringHelper { | |
| 463 public: | |
| 464 ErrorToStringHelper() : visited_(0) {} | |
| 465 | |
| 466 MUST_USE_RESULT MaybeHandle<String> Stringify(Isolate* isolate, | |
| 467 Handle<JSObject> error); | |
| 468 | |
| 469 private: | |
| 470 class VisitedScope { | |
| 471 public: | |
| 472 VisitedScope(ErrorToStringHelper* helper, Handle<JSObject> error) | |
| 473 : helper_(helper), has_visited_(false) { | |
| 474 for (const auto& visited : helper->visited_) { | |
|
Jakob Kummerow
2015/08/08 21:56:09
nit: I'd prefer the explicitness of s/auto/Handle<
| |
| 475 if (visited.is_identical_to(error)) { | |
| 476 has_visited_ = true; | |
| 477 break; | |
| 478 } | |
| 479 } | |
| 480 helper->visited_.Add(error); | |
| 481 } | |
| 482 ~VisitedScope() { helper_->visited_.RemoveLast(); } | |
| 483 bool HasVisited() { return has_visited_; } | |
|
Jakob Kummerow
2015/08/08 21:56:09
nit: unix_hacker_style() for simple getters
| |
| 484 | |
| 485 private: | |
| 486 ErrorToStringHelper* helper_; | |
| 487 bool has_visited_; | |
| 488 }; | |
| 489 | |
| 490 | |
|
Jakob Kummerow
2015/08/08 21:56:09
nit: one empty line is enough here
| |
| 491 bool ShadowsInternalError(Isolate* isolate, LookupIterator* property_lookup, | |
|
Jakob Kummerow
2015/08/08 21:56:09
this could be declared static, right?
| |
| 492 LookupIterator* internal_error_lookup); | |
| 493 | |
| 494 MUST_USE_RESULT MaybeHandle<String> GetStringifiedProperty( | |
|
Jakob Kummerow
2015/08/08 21:56:09
this could be declared static too, right?
| |
| 495 Isolate* isolate, LookupIterator* property_lookup, | |
| 496 Handle<String> default_value); | |
| 497 | |
| 498 List<Handle<JSObject> > visited_; | |
| 499 }; | |
| 460 } } // namespace v8::internal | 500 } } // namespace v8::internal |
| 461 | 501 |
| 462 #endif // V8_MESSAGES_H_ | 502 #endif // V8_MESSAGES_H_ |
| OLD | NEW |