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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:nativewrappers"; 5 import "dart:nativewrappers";
6 // TODO(ahe): Move _symbol_dev.Symbol to its own "private" library? 6 // TODO(ahe): Move _symbol_dev.Symbol to its own "private" library?
7 import "dart:_collection-dev" as _symbol_dev; 7 import "dart:_collection-dev" as _symbol_dev;
8 8
9 /** 9 /**
10 * Returns a [MirrorSystem] for the current isolate. 10 * Returns a [MirrorSystem] for the current isolate.
(...skipping 30 matching lines...) Expand all
41 return _Mirrors.reflectClass(key); 41 return _Mirrors.reflectClass(key);
42 } 42 }
43 43
44 patch TypeMirror reflectType(Type key) { 44 patch TypeMirror reflectType(Type key) {
45 return _Mirrors.reflectType(key); 45 return _Mirrors.reflectType(key);
46 } 46 }
47 47
48 patch class MirrorSystem { 48 patch class MirrorSystem {
49 /* patch */ static String getName(Symbol symbol) { 49 /* patch */ static String getName(Symbol symbol) {
50 String string = _symbol_dev.Symbol.getName(symbol); 50 String string = _symbol_dev.Symbol.getName(symbol);
51 if (string.contains(' with ')) return string; 51
52 return _unmangleName(string); 52 // get:foo -> foo
53 // set:foo -> foo=
54 // get:_foo@xxx -> _foo
55 // set:_foo@xxx -> _foo=
56 // Class._constructor@xxx -> Class._constructor
57 // _Class@xxx._constructor@xxx -> _Class._constructor
58 // lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2
59 StringBuffer result = new StringBuffer();
60 bool keep = true;
61 bool add_setter_suffix = false;
62 var pos = 0;
63 if (string.length >= 4 && string[3] == ':') {
64 // Drop 'get:' or 'set:' prefix.
65 pos = 4;
66 if (string[0] == 's') {
67 add_setter_suffix;
68 }
69 }
70 // Skip everything between AT and PERIOD, SPACE, COMMA or END
71 for (; pos < string.length; pos++) {
72 var char = string[pos];
73 if (char == '@') {
74 keep = false;
75 } else if (char == '.' || char == ' ' || char == ',') {
76 keep = true;
77 }
78 if (keep) {
79 result.write(char);
80 }
81 }
82 if (add_setter_suffix) {
83 result.write('=');
84 }
85 return result.toString();
53 } 86 }
87
54 /* patch */ static Symbol getSymbol(String name, [LibraryMirror library]) { 88 /* patch */ static Symbol getSymbol(String name, [LibraryMirror library]) {
55 if (library is! LibraryMirror || 89 if (library is! LibraryMirror ||
56 ((name[0] == '_') && (library == null))) { 90 ((name.length > 0) && (name[0] == '_') && (library == null))) {
57 throw new ArgumentError(library); 91 throw new ArgumentError(library);
58 } 92 }
59 if (library != null) name = _mangleName(name, library._reflectee); 93 if (library != null) name = _mangleName(name, library._reflectee);
60 return new _symbol_dev.Symbol.unvalidated(name); 94 return new _symbol_dev.Symbol.unvalidated(name);
61 } 95 }
62 96
63 static _unmangleName(String name)
64 native "Mirrors_unmangleName";
65 static _mangleName(String name, _MirrorReference lib) 97 static _mangleName(String name, _MirrorReference lib)
66 native "Mirrors_mangleName"; 98 native "Mirrors_mangleName";
67 } 99 }
68 100
69 // TODO(rmacnak): Eliminate this class. 101 // TODO(rmacnak): Eliminate this class.
70 class MirroredCompilationError { 102 class MirroredCompilationError {
71 final String message; 103 final String message;
72 104
73 MirroredCompilationError(this.message); 105 MirroredCompilationError(this.message);
74 106
75 String toString() { 107 String toString() {
76 return "Compile-time error during mirrored execution: <$message>"; 108 return "Compile-time error during mirrored execution: <$message>";
77 } 109 }
78 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698