| 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 |
| 11 static final CLOSURE_INVOCATION_NAME = const SourceString('\$call'); | 11 static final CLOSURE_INVOCATION_NAME = const SourceString('\$call'); |
| 12 static final STATIC_CLOSURE_NAME_NAME = '\$name'; |
| 12 static final OPERATOR_EQUALS = const SourceString('operator\$eq'); | 13 static final OPERATOR_EQUALS = const SourceString('operator\$eq'); |
| 13 | 14 |
| 14 static Set<String> _jsReserved = null; | 15 static Set<String> _jsReserved = null; |
| 15 Set<String> get jsReserved() { | 16 Set<String> get jsReserved() { |
| 16 if (_jsReserved === null) { | 17 if (_jsReserved === null) { |
| 17 _jsReserved = new Set<String>(); | 18 _jsReserved = new Set<String>(); |
| 18 _jsReserved.addAll(JsNames.javaScriptKeywords); | 19 _jsReserved.addAll(JsNames.javaScriptKeywords); |
| 19 _jsReserved.addAll(JsNames.reservedPropertySymbols); | 20 _jsReserved.addAll(JsNames.reservedPropertySymbols); |
| 20 } | 21 } |
| 21 return _jsReserved; | 22 return _jsReserved; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 242 } |
| 242 | 243 |
| 243 String safeName(String name) { | 244 String safeName(String name) { |
| 244 if (jsReserved.contains(name) || name.startsWith('\$')) { | 245 if (jsReserved.contains(name) || name.startsWith('\$')) { |
| 245 name = "\$$name"; | 246 name = "\$$name"; |
| 246 assert(!jsReserved.contains(name)); | 247 assert(!jsReserved.contains(name)); |
| 247 } | 248 } |
| 248 return name; | 249 return name; |
| 249 } | 250 } |
| 250 } | 251 } |
| OLD | NEW |