| 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 Set<String> _jsReserved = null; | 11 static Set<String> _jsReserved = null; |
| 12 Set<String> get jsReserved() { | 12 Set<String> get jsReserved { |
| 13 if (_jsReserved === null) { | 13 if (_jsReserved === null) { |
| 14 _jsReserved = new Set<String>(); | 14 _jsReserved = new Set<String>(); |
| 15 _jsReserved.addAll(JsNames.javaScriptKeywords); | 15 _jsReserved.addAll(JsNames.javaScriptKeywords); |
| 16 _jsReserved.addAll(JsNames.reservedPropertySymbols); | 16 _jsReserved.addAll(JsNames.reservedPropertySymbols); |
| 17 } | 17 } |
| 18 return _jsReserved; | 18 return _jsReserved; |
| 19 } | 19 } |
| 20 | 20 |
| 21 Map<Element, String> globals; | 21 Map<Element, String> globals; |
| 22 Map<String, int> usedGlobals; | 22 Map<String, int> usedGlobals; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 292 } |
| 293 | 293 |
| 294 String safeName(String name) { | 294 String safeName(String name) { |
| 295 if (jsReserved.contains(name) || name.startsWith('\$')) { | 295 if (jsReserved.contains(name) || name.startsWith('\$')) { |
| 296 name = "\$$name"; | 296 name = "\$$name"; |
| 297 assert(!jsReserved.contains(name)); | 297 assert(!jsReserved.contains(name)); |
| 298 } | 298 } |
| 299 return name; | 299 return name; |
| 300 } | 300 } |
| 301 } | 301 } |
| OLD | NEW |