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

Unified Diff: vm/dart_api_impl.cc

Issue 10826191: Improve the stack trace output to be more readable. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | « tests/vm/dart/isolate_mirror_local_test.dart ('k') | vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/dart_api_impl.cc
===================================================================
--- vm/dart_api_impl.cc (revision 10396)
+++ vm/dart_api_impl.cc (working copy)
@@ -77,81 +77,7 @@
} \
} while (0)
-// Takes a vm internal name and makes it suitable for external user.
-//
-// Examples:
-//
-// Internal getter and setter prefices are removed:
-//
-// get:foo -> foo
-// set:foo -> foo
-//
-// Private name mangling is removed, possibly twice:
-//
-// _ReceivePortImpl@6be832b -> _ReceivePortImpl
-// _ReceivePortImpl@6be832b._internal@6be832b -> +ReceivePortImpl._internal
-//
-// The trailing . on the default constructor name is dropped:
-//
-// List. -> List
-//
-// And so forth:
-//
-// get:foo@6be832b -> foo
-// _MyClass@6b3832b. -> _MyClass
-// _MyClass@6b3832b.named -> _MyClass.named
-//
-static RawString* IdentifierPrettyName(Isolate* isolate, const String& name) {
- intptr_t len = name.Length();
- intptr_t start = 0;
- intptr_t at_pos = len; // Position of '@' in the name.
- intptr_t dot_pos = len; // Position of '.' in the name.
- for (int i = 0; i < name.Length(); i++) {
- if (name.CharAt(i) == ':') {
- ASSERT(start == 0);
- start = i + 1;
- } else if (name.CharAt(i) == '@') {
- ASSERT(at_pos == len);
- at_pos = i;
- } else if (name.CharAt(i) == '.') {
- dot_pos = i;
- break;
- }
- }
- intptr_t limit = (at_pos < dot_pos ? at_pos : dot_pos);
- if (start == 0 && limit == len) {
- // This name is fine as it is.
- return name.raw();
- }
-
- String& result = String::Handle(isolate);
- result = String::SubString(name, start, (limit - start));
-
- // Look for a second '@' now to correctly handle names like
- // "_ReceivePortImpl@6be832b._internal@6be832b".
- at_pos = len;
- for (int i = dot_pos; i < name.Length(); i++) {
- if (name.CharAt(i) == '@') {
- ASSERT(at_pos == len);
- at_pos = i;
- }
- }
-
- intptr_t suffix_len = at_pos - dot_pos;
- if (suffix_len <= 1) {
- // The constructor name is of length 0 or 1. That means that
- // either this isn't a constructor or that this is an unnamed
- // constructor. In either case, we're done.
- return result.raw();
- }
-
- const String& suffix =
- String::Handle(isolate, String::SubString(name, dot_pos, suffix_len));
- return String::Concat(result, suffix);
-}
-
-
// Return error if isolate is in an inconsistent state.
// Return NULL when no error condition exists.
//
@@ -2483,8 +2409,7 @@
if (cls.IsNull()) {
RETURN_TYPE_ERROR(isolate, clazz, Class);
}
- const String& cls_name = String::Handle(isolate, cls.Name());
- return Api::NewHandle(isolate, IdentifierPrettyName(isolate, cls_name));
+ return Api::NewHandle(isolate, cls.UserVisibleName());
}
@@ -2591,12 +2516,6 @@
}
-static RawString* AddExternalSetterSuffix(const String& name) {
- const String& equals = String::Handle(Symbols::New("="));
- return String::Concat(name, equals);
-}
-
-
static RawString* RemoveExternalSetterSuffix(const String& name) {
ASSERT(HasExternalSetterSuffix(name));
return String::SubString(name, 0, name.Length() - 1);
@@ -2632,13 +2551,7 @@
continue;
}
- name = func.name();
- bool is_setter = Field::IsSetterName(name);
- name = IdentifierPrettyName(isolate, name);
-
- if (is_setter) {
- name = AddExternalSetterSuffix(name);
- }
+ name = func.UserVisibleName();
names.Add(name);
}
}
@@ -2650,12 +2563,7 @@
obj = it.GetNext();
if (obj.IsFunction()) {
func ^= obj.raw();
- name = func.name();
- bool is_setter = Field::IsSetterName(name);
- name = IdentifierPrettyName(isolate, name);
- if (is_setter) {
- name = AddExternalSetterSuffix(name);
- }
+ name = func.UserVisibleName();
names.Add(name);
}
}
@@ -2763,14 +2671,7 @@
if (func.IsNull()) {
RETURN_TYPE_ERROR(isolate, function, Function);
}
- String& func_name = String::Handle(isolate);
- func_name = func.name();
- bool is_setter = Field::IsSetterName(func_name);
- func_name = IdentifierPrettyName(isolate, func_name);
- if (is_setter) {
- func_name = AddExternalSetterSuffix(func_name);
- }
- return Api::NewHandle(isolate, func_name.raw());
+ return Api::NewHandle(isolate, func.UserVisibleName());
}
@@ -2939,8 +2840,7 @@
if (!field_array.IsNull()) {
for (intptr_t i = 0; i < field_array.Length(); ++i) {
field ^= field_array.At(i);
- name = field.name();
- name = IdentifierPrettyName(isolate, name);
+ name = field.UserVisibleName();
names.Add(name);
}
}
@@ -2952,8 +2852,7 @@
obj = it.GetNext();
if (obj.IsField()) {
field ^= obj.raw();
- name = field.name();
- name = IdentifierPrettyName(isolate, name);
+ name = field.UserVisibleName();
names.Add(name);
}
}
@@ -3004,8 +2903,7 @@
if (var.IsNull()) {
RETURN_TYPE_ERROR(isolate, variable, Field);
}
- const String& var_name = String::Handle(var.name());
- return Api::NewHandle(isolate, IdentifierPrettyName(isolate, var_name));
+ return Api::NewHandle(isolate, var.UserVisibleName());
}
@@ -4018,8 +3916,7 @@
// TODO(turnidge): Add this to the unit test.
const Function& signature_func = Function::Handle(cls.signature_function());
if (signature_func.IsNull()) {
- name = cls.Name();
- name = IdentifierPrettyName(isolate, name);
+ name = cls.UserVisibleName();
names.Add(name);
}
}
« no previous file with comments | « tests/vm/dart/isolate_mirror_local_test.dart ('k') | vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698