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