| 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 part of js_backend; |
| 6 |
| 5 /** | 7 /** |
| 6 * Assigns JavaScript identifiers to Dart variables, class-names and members. | 8 * Assigns JavaScript identifiers to Dart variables, class-names and members. |
| 7 */ | 9 */ |
| 8 class Namer { | 10 class Namer { |
| 9 final Compiler compiler; | 11 final Compiler compiler; |
| 10 | 12 |
| 11 static Set<String> _jsReserved = null; | 13 static Set<String> _jsReserved = null; |
| 12 Set<String> get jsReserved { | 14 Set<String> get jsReserved { |
| 13 if (_jsReserved == null) { | 15 if (_jsReserved == null) { |
| 14 _jsReserved = new Set<String>(); | 16 _jsReserved = new Set<String>(); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 } | 324 } |
| 323 | 325 |
| 324 String safeName(String name) { | 326 String safeName(String name) { |
| 325 if (jsReserved.contains(name) || name.startsWith('\$')) { | 327 if (jsReserved.contains(name) || name.startsWith('\$')) { |
| 326 name = "\$$name"; | 328 name = "\$$name"; |
| 327 assert(!jsReserved.contains(name)); | 329 assert(!jsReserved.contains(name)); |
| 328 } | 330 } |
| 329 return name; | 331 return name; |
| 330 } | 332 } |
| 331 } | 333 } |
| OLD | NEW |