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; | 5 part of js_backend; |
6 | 6 |
7 /** | 7 /** |
8 * Assigns JavaScript identifiers to Dart variables, class-names and members. | 8 * Assigns JavaScript identifiers to Dart variables, class-names and members. |
9 */ | 9 */ |
10 class Namer { | 10 class Namer { |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 // The name is not guaranteed to be unique. | 375 // The name is not guaranteed to be unique. |
376 return safeName(guess); | 376 return safeName(guess); |
377 } | 377 } |
378 if (kind == ElementKind.GENERATIVE_CONSTRUCTOR || | 378 if (kind == ElementKind.GENERATIVE_CONSTRUCTOR || |
379 kind == ElementKind.FUNCTION || | 379 kind == ElementKind.FUNCTION || |
380 kind == ElementKind.CLASS || | 380 kind == ElementKind.CLASS || |
381 kind == ElementKind.FIELD || | 381 kind == ElementKind.FIELD || |
382 kind == ElementKind.GETTER || | 382 kind == ElementKind.GETTER || |
383 kind == ElementKind.SETTER || | 383 kind == ElementKind.SETTER || |
384 kind == ElementKind.TYPEDEF || | 384 kind == ElementKind.TYPEDEF || |
385 kind == ElementKind.LIBRARY) { | 385 kind == ElementKind.LIBRARY || |
| 386 kind == ElementKind.MALFORMED_TYPE) { |
386 bool isNative = false; | 387 bool isNative = false; |
387 if (identical(kind, ElementKind.CLASS)) { | 388 if (identical(kind, ElementKind.CLASS)) { |
388 ClassElement class_elt = element; | 389 ClassElement class_elt = element; |
389 isNative = class_elt.isNative(); | 390 isNative = class_elt.isNative(); |
390 } | 391 } |
391 if (Elements.isInstanceField(element)) { | 392 if (Elements.isInstanceField(element)) { |
392 isNative = element.isNative(); | 393 isNative = element.isNative(); |
393 } | 394 } |
394 String result = isNative ? guess : getFreshName(guess, usedGlobalNames); | 395 String result = isNative ? guess : getFreshName(guess, usedGlobalNames); |
395 globals[element] = result; | 396 globals[element] = result; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 } | 433 } |
433 | 434 |
434 String safeName(String name) { | 435 String safeName(String name) { |
435 if (jsReserved.contains(name) || name.startsWith('\$')) { | 436 if (jsReserved.contains(name) || name.startsWith('\$')) { |
436 name = "\$$name"; | 437 name = "\$$name"; |
437 assert(!jsReserved.contains(name)); | 438 assert(!jsReserved.contains(name)); |
438 } | 439 } |
439 return name; | 440 return name; |
440 } | 441 } |
441 } | 442 } |
OLD | NEW |