| 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 // The name is not guaranteed to be unique. | 373 // The name is not guaranteed to be unique. |
| 374 return safeName(guess); | 374 return safeName(guess); |
| 375 } | 375 } |
| 376 if (kind == ElementKind.GENERATIVE_CONSTRUCTOR || | 376 if (kind == ElementKind.GENERATIVE_CONSTRUCTOR || |
| 377 kind == ElementKind.FUNCTION || | 377 kind == ElementKind.FUNCTION || |
| 378 kind == ElementKind.CLASS || | 378 kind == ElementKind.CLASS || |
| 379 kind == ElementKind.FIELD || | 379 kind == ElementKind.FIELD || |
| 380 kind == ElementKind.GETTER || | 380 kind == ElementKind.GETTER || |
| 381 kind == ElementKind.SETTER || | 381 kind == ElementKind.SETTER || |
| 382 kind == ElementKind.TYPEDEF || | 382 kind == ElementKind.TYPEDEF || |
| 383 kind == ElementKind.LIBRARY) { | 383 kind == ElementKind.LIBRARY || |
| 384 kind == ElementKind.MALFORMED_TYPE) { |
| 384 bool isNative = false; | 385 bool isNative = false; |
| 385 if (identical(kind, ElementKind.CLASS)) { | 386 if (identical(kind, ElementKind.CLASS)) { |
| 386 ClassElement class_elt = element; | 387 ClassElement class_elt = element; |
| 387 isNative = class_elt.isNative(); | 388 isNative = class_elt.isNative(); |
| 388 } | 389 } |
| 389 if (Elements.isInstanceField(element)) { | 390 if (Elements.isInstanceField(element)) { |
| 390 isNative = element.isNative(); | 391 isNative = element.isNative(); |
| 391 } | 392 } |
| 392 String result = isNative ? guess : getFreshName(guess, usedGlobalNames); | 393 String result = isNative ? guess : getFreshName(guess, usedGlobalNames); |
| 393 globals[element] = result; | 394 globals[element] = result; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 431 } |
| 431 | 432 |
| 432 String safeName(String name) { | 433 String safeName(String name) { |
| 433 if (jsReserved.contains(name) || name.startsWith('\$')) { | 434 if (jsReserved.contains(name) || name.startsWith('\$')) { |
| 434 name = "\$$name"; | 435 name = "\$$name"; |
| 435 assert(!jsReserved.contains(name)); | 436 assert(!jsReserved.contains(name)); |
| 436 } | 437 } |
| 437 return name; | 438 return name; |
| 438 } | 439 } |
| 439 } | 440 } |
| OLD | NEW |