| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * Assigns JavaScript identifiers to Dart variables, class-names and members. | 6 * Assigns JavaScript identifiers to Dart variables, class-names and members. |
| 7 */ | 7 */ |
| 8 class Namer { | 8 class Namer { |
| 9 final Compiler compiler; | 9 final Compiler compiler; |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Returns a preferred JS-id for the given top-level or static element. | 57 * Returns a preferred JS-id for the given top-level or static element. |
| 58 * The returned id is guaranteed to be a valid JS-id. | 58 * The returned id is guaranteed to be a valid JS-id. |
| 59 */ | 59 */ |
| 60 String _computeGuess(Element element) { | 60 String _computeGuess(Element element) { |
| 61 assert(!element.isInstanceMember()); | 61 assert(!element.isInstanceMember()); |
| 62 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { | 62 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { |
| 63 SourceString name = getConstructorName(element); | 63 SourceString name = getConstructorName(element); |
| 64 return instanceMethodName(name, element.parameterCount(compiler)); | 64 FunctionElement functionElement = element; |
| 65 return instanceMethodName(name, functionElement.parameterCount(compiler)); |
| 65 } else { | 66 } else { |
| 66 // TODO(floitsch): deal with named constructors. | 67 // TODO(floitsch): deal with named constructors. |
| 67 String name = '${element.name}'; | 68 String name = '${element.name}'; |
| 68 if (element.kind == ElementKind.FUNCTION) { | 69 if (element.kind == ElementKind.FUNCTION) { |
| 69 FunctionElement functionElement = element; | 70 FunctionElement functionElement = element; |
| 70 name = '$name\$${functionElement.parameterCount(compiler)}'; | 71 name = '$name\$${functionElement.parameterCount(compiler)}'; |
| 71 } | 72 } |
| 72 // Prefix the name with '$' if it is reserved. | 73 // Prefix the name with '$' if it is reserved. |
| 73 if (jsReserved.contains(name)) { | 74 if (jsReserved.contains(name)) { |
| 74 name = "\$$name"; | 75 name = "\$$name"; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 166 } |
| 166 | 167 |
| 167 String isolateBailoutAccess(Element element) { | 168 String isolateBailoutAccess(Element element) { |
| 168 return '${isolateAccess(element)}\$bailout'; | 169 return '${isolateAccess(element)}\$bailout'; |
| 169 } | 170 } |
| 170 | 171 |
| 171 String operatorIs(ClassElement element) { | 172 String operatorIs(ClassElement element) { |
| 172 return 'is\$${getName(element)}'; | 173 return 'is\$${getName(element)}'; |
| 173 } | 174 } |
| 174 } | 175 } |
| OLD | NEW |