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

Unified Diff: runtime/vm/object.cc

Issue 8761004: Better fix for printing (after discussing it with Ivan and Regis) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 1950)
+++ runtime/vm/object.cc (working copy)
@@ -2209,15 +2209,27 @@
const char* ParameterizedType::ToCString() const {
if (IsResolved()) {
- const char* format = "ParameterizedType: class '%s', args:[%s]";
- const char* class_name =
- String::Handle(Class::Handle(type_class()).Name()).ToCString();
- const char* args_cstr = TypeArguments::Handle(arguments()).ToCString();
- intptr_t len = OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1;
- char* chars = reinterpret_cast<char*>(
- Isolate::Current()->current_zone()->Allocate(len));
- OS::SNPrint(chars, len, format, class_name, args_cstr);
- return chars;
+ const TypeArguments& type_arguments = TypeArguments::Handle(arguments());
+ if (type_arguments.IsNull()) {
+ const char* format = "ParameterizedType: class '%s'";
+ const char* class_name =
+ String::Handle(Class::Handle(type_class()).Name()).ToCString();
+ intptr_t len = OS::SNPrint(NULL, 0, format, class_name) + 1;
+ char* chars = reinterpret_cast<char*>(
+ Isolate::Current()->current_zone()->Allocate(len));
+ OS::SNPrint(chars, len, format, class_name);
+ return chars;
+ } else {
+ const char* format = "ParameterizedType: class '%s', args:[%s]";
+ const char* class_name =
+ String::Handle(Class::Handle(type_class()).Name()).ToCString();
+ const char* args_cstr = TypeArguments::Handle(arguments()).ToCString();
+ intptr_t len = OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1;
+ char* chars = reinterpret_cast<char*>(
+ Isolate::Current()->current_zone()->Allocate(len));
+ OS::SNPrint(chars, len, format, class_name, args_cstr);
+ return chars;
+ }
} else {
return "Unresolved ParameterizedType";
}
@@ -2463,10 +2475,7 @@
const char* TypeArguments::ToCString() const {
- // TypeArguments is an abstract class, however it may wrap a null.
- if (IsNull()) {
- return "NULL TypeArguments";
- }
+ // TypeArguments is an abstract class.
UNREACHABLE();
return "TypeArguments";
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698