Chromium Code Reviews| 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 1236aa6d9f53ec48e24144c588f420c7b02b82be..55a4f9917a904ba0553f408c394c0b9a290b5eeb 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart |
| @@ -206,7 +206,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, {allowUnsafeName: false}) { |
|
ngeoffray
2012/11/15 08:58:09
bool and no need to make it optional
karlklose
2012/11/16 13:37:19
Done.
|
| assert(!element.isInstanceMember()); |
| LibraryElement lib = element.getLibrary(); |
| String name; |
| @@ -230,8 +230,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) { |
| @@ -246,7 +246,7 @@ class Namer { |
| * For accessing statics consider calling |
| * [isolateAccess]/[isolateBailoutAccess] or [isolatePropertyAccess] instead. |
| */ |
| - String getName(Element element) { |
| + String getName(Element element, {allowUnsafeName: false}) { |
|
ngeoffray
2012/11/15 08:58:09
bool
karlklose
2012/11/16 13:37:19
Done.
|
| if (element.isInstanceMember()) { |
| if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY |
| || element.kind == ElementKind.FUNCTION) { |
| @@ -264,12 +264,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: allowUnsafeName); |
| ElementKind kind = element.kind; |
| if (identical(kind, ElementKind.VARIABLE) || |
| identical(kind, ElementKind.PARAMETER)) { |