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

Side by Side Diff: src/messages.h

Issue 1281833002: Rewrite Error.prototype.toString in C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test case Created 5 years, 4 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
« no previous file with comments | « src/isolate.h ('k') | src/messages.cc » ('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 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
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 Handle<JSObject>& visited : helper->visited_) {
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 has_visited() { return has_visited_; }
484
485 private:
486 ErrorToStringHelper* helper_;
487 bool has_visited_;
488 };
489
490 static bool ShadowsInternalError(Isolate* isolate,
491 LookupIterator* property_lookup,
492 LookupIterator* internal_error_lookup);
493
494 static MUST_USE_RESULT MaybeHandle<String> GetStringifiedProperty(
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_
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698