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

Unified Diff: runtime/lib/mirrors_patch.dart

Issue 53883002: Ensure constructorName symbols include private manglings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
Index: runtime/lib/mirrors_patch.dart
diff --git a/runtime/lib/mirrors_patch.dart b/runtime/lib/mirrors_patch.dart
index b3f2d4d530907dc4328caa590c307ab8ec493c58..cab93727b122b6a358d59e5e7e45d97a00140a0c 100644
--- a/runtime/lib/mirrors_patch.dart
+++ b/runtime/lib/mirrors_patch.dart
@@ -48,20 +48,52 @@ patch TypeMirror reflectType(Type key) {
patch class MirrorSystem {
/* patch */ static String getName(Symbol symbol) {
String string = _symbol_dev.Symbol.getName(symbol);
- if (string.contains(' with ')) return string;
- return _unmangleName(string);
+
+ // get:foo -> foo
+ // set:foo -> foo=
+ // get:_foo@xxx -> _foo
+ // set:_foo@xxx -> _foo=
+ // Class._constructor@xxx -> Class._constructor
+ // _Class@xxx._constructor@xxx -> _Class._constructor
+ // lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2
+ StringBuffer result = new StringBuffer();
+ bool keep = true;
+ bool add_setter_suffix = false;
+ var pos = 0;
+ if (string.length >= 4 && string[3] == ':') {
+ // Drop 'get:' or 'set:' prefix.
+ pos = 4;
+ if (string[0] == 's') {
+ add_setter_suffix;
+ }
+ }
+ // Skip everything between AT and PERIOD, SPACE, COMMA or END
+ for (; pos < string.length; pos++) {
+ var char = string[pos];
+ if (char == '@') {
+ keep = false;
+ } else if (char == '.' || char == ' ' || char == ',') {
+ keep = true;
+ }
+ if (keep) {
+ result.write(char);
+ }
+ }
+ if (add_setter_suffix) {
+ result.write('=');
+ }
+ return result.toString();
}
+
/* patch */ static Symbol getSymbol(String name, [LibraryMirror library]) {
if (library is! LibraryMirror ||
- ((name[0] == '_') && (library == null))) {
+ ((name.length > 0) && (name[0] == '_') && (library == null))) {
throw new ArgumentError(library);
}
if (library != null) name = _mangleName(name, library._reflectee);
return new _symbol_dev.Symbol.unvalidated(name);
}
- static _unmangleName(String name)
- native "Mirrors_unmangleName";
static _mangleName(String name, _MirrorReference lib)
native "Mirrors_mangleName";
}

Powered by Google App Engine
This is Rietveld 408576698