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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // The name is not guaranteed to be unique. | 263 // The name is not guaranteed to be unique. |
264 return guess; | 264 return guess; |
265 } | 265 } |
266 if (kind === ElementKind.GENERATIVE_CONSTRUCTOR || | 266 if (kind === ElementKind.GENERATIVE_CONSTRUCTOR || |
267 kind === ElementKind.FUNCTION || | 267 kind === ElementKind.FUNCTION || |
268 kind === ElementKind.CLASS || | 268 kind === ElementKind.CLASS || |
269 kind === ElementKind.FIELD || | 269 kind === ElementKind.FIELD || |
270 kind === ElementKind.GETTER || | 270 kind === ElementKind.GETTER || |
271 kind === ElementKind.SETTER || | 271 kind === ElementKind.SETTER || |
272 kind === ElementKind.TYPEDEF || | 272 kind === ElementKind.TYPEDEF || |
273 kind === ElementKind.LIBRARY) { | 273 kind === ElementKind.LIBRARY || |
| 274 kind === ElementKind.MALFORMED_TYPE) { |
274 String result = getFreshGlobalName(guess); | 275 String result = getFreshGlobalName(guess); |
275 globals[element] = result; | 276 globals[element] = result; |
276 return result; | 277 return result; |
277 } | 278 } |
278 compiler.internalError('getName for unknown kind: ${element.kind}', | 279 compiler.internalError('getName for unknown kind: ${element.kind}', |
279 node: element.parseNode(compiler)); | 280 node: element.parseNode(compiler)); |
280 } | 281 } |
281 } | 282 } |
282 | 283 |
283 String getLazyInitializerName(Element element) { | 284 String getLazyInitializerName(Element element) { |
(...skipping 27 matching lines...) Expand all Loading... |
311 } | 312 } |
312 | 313 |
313 String safeName(String name) { | 314 String safeName(String name) { |
314 if (jsReserved.contains(name) || name.startsWith('\$')) { | 315 if (jsReserved.contains(name) || name.startsWith('\$')) { |
315 name = "\$$name"; | 316 name = "\$$name"; |
316 assert(!jsReserved.contains(name)); | 317 assert(!jsReserved.contains(name)); |
317 } | 318 } |
318 return name; | 319 return name; |
319 } | 320 } |
320 } | 321 } |
OLD | NEW |