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

Unified 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: add 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/isolate.h ('k') | src/messages.cc » ('j') | src/messages.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/messages.h
diff --git a/src/messages.h b/src/messages.h
index 529c659e181d8f35cca3e05909d8e3a76fa9a3b4..5c8e0504752a6d71beee12c7d6bd11753bda8e8c 100644
--- a/src/messages.h
+++ b/src/messages.h
@@ -457,6 +457,46 @@ class MessageHandler {
static base::SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate,
Handle<Object> data);
};
+
+
+class ErrorToStringHelper {
+ public:
+ ErrorToStringHelper() : visited_(0) {}
+
+ MUST_USE_RESULT MaybeHandle<String> Stringify(Isolate* isolate,
+ Handle<JSObject> error);
+
+ private:
+ class VisitedScope {
+ public:
+ VisitedScope(ErrorToStringHelper* helper, Handle<JSObject> error)
+ : helper_(helper), has_visited_(false) {
+ for (const auto& visited : helper->visited_) {
Jakob Kummerow 2015/08/08 21:56:09 nit: I'd prefer the explicitness of s/auto/Handle<
+ if (visited.is_identical_to(error)) {
+ has_visited_ = true;
+ break;
+ }
+ }
+ helper->visited_.Add(error);
+ }
+ ~VisitedScope() { helper_->visited_.RemoveLast(); }
+ bool HasVisited() { return has_visited_; }
Jakob Kummerow 2015/08/08 21:56:09 nit: unix_hacker_style() for simple getters
+
+ private:
+ ErrorToStringHelper* helper_;
+ bool has_visited_;
+ };
+
+
Jakob Kummerow 2015/08/08 21:56:09 nit: one empty line is enough here
+ bool ShadowsInternalError(Isolate* isolate, LookupIterator* property_lookup,
Jakob Kummerow 2015/08/08 21:56:09 this could be declared static, right?
+ LookupIterator* internal_error_lookup);
+
+ MUST_USE_RESULT MaybeHandle<String> GetStringifiedProperty(
Jakob Kummerow 2015/08/08 21:56:09 this could be declared static too, right?
+ Isolate* isolate, LookupIterator* property_lookup,
+ Handle<String> default_value);
+
+ List<Handle<JSObject> > visited_;
+};
} } // namespace v8::internal
#endif // V8_MESSAGES_H_
« no previous file with comments | « src/isolate.h ('k') | src/messages.cc » ('j') | src/messages.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698