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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/namer.dart

Issue 11360228: Simplify runtime type support. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 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
Index: sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart b/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
index 69817be1aaa4dd5b84f84382cdf2a1d0f4366d75..e66b8c0486f36d6ebe16c3f00cfaa0591ec25919 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
@@ -208,7 +208,7 @@ class Namer {
* Returns a preferred JS-id for the given top-level or static element.
* The returned id is guaranteed to be a valid JS-id.
*/
- String _computeGuess(Element element) {
+ String _computeGuess(Element element, bool allowUnsafeName) {
assert(!element.isInstanceMember());
LibraryElement lib = element.getLibrary();
String name;
@@ -232,8 +232,8 @@ class Namer {
} else {
name = element.name.slowToString();
}
- // Prefix the name with '$' if it is reserved.
- return safeName(name);
+ // Prefix the name with '$' if it is reserved and we generate safe names.
+ return allowUnsafeName ? name : safeName(name);
}
String getBailoutName(Element element) {
@@ -248,7 +248,7 @@ class Namer {
* For accessing statics consider calling
* [isolateAccess]/[isolateBailoutAccess] or [isolatePropertyAccess] instead.
*/
- String getName(Element element) {
+ String getName(Element element, {bool allowUnsafeName: false}) {
if (element.isInstanceMember()) {
if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY
|| element.kind == ElementKind.FUNCTION) {
@@ -266,12 +266,11 @@ class Namer {
} else {
// Use declaration element to ensure invariant on [globals].
element = element.declaration;
-
// Dealing with a top-level or static element.
String cached = globals[element];
if (cached != null) return cached;
- String guess = _computeGuess(element);
+ String guess = _computeGuess(element, allowUnsafeName);
ElementKind kind = element.kind;
if (identical(kind, ElementKind.VARIABLE) ||
identical(kind, ElementKind.PARAMETER)) {

Powered by Google App Engine
This is Rietveld 408576698