| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 kind === ElementKind.LIBRARY) { | 266 kind === ElementKind.LIBRARY) { |
| 267 String result = getFreshGlobalName(guess); | 267 String result = getFreshGlobalName(guess); |
| 268 globals[element] = result; | 268 globals[element] = result; |
| 269 return result; | 269 return result; |
| 270 } | 270 } |
| 271 compiler.internalError('getName for unknown kind: ${element.kind}', | 271 compiler.internalError('getName for unknown kind: ${element.kind}', |
| 272 node: element.parseNode(compiler)); | 272 node: element.parseNode(compiler)); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 String getLazyInitializerName(Element element) { |
| 277 // TODO(floitsch): mangle while not conflicting with other statics. |
| 278 assert(Elements.isStaticOrTopLevelField(element)); |
| 279 return "get\$${getName(element)}"; |
| 280 } |
| 281 |
| 276 String isolatePropertiesAccess(Element element) { | 282 String isolatePropertiesAccess(Element element) { |
| 277 return "$ISOLATE.$ISOLATE_PROPERTIES.${getName(element)}"; | 283 return "$ISOLATE.$ISOLATE_PROPERTIES.${getName(element)}"; |
| 278 } | 284 } |
| 279 | 285 |
| 280 String isolatePropertiesAccessForConstant(String constantName) { | 286 String isolatePropertiesAccessForConstant(String constantName) { |
| 281 return "$ISOLATE.$ISOLATE_PROPERTIES.$constantName"; | 287 return "$ISOLATE.$ISOLATE_PROPERTIES.$constantName"; |
| 282 } | 288 } |
| 283 | 289 |
| 284 String isolateAccess(Element element) { | 290 String isolateAccess(Element element) { |
| 285 return "$CURRENT_ISOLATE.${getName(element)}"; | 291 return "$CURRENT_ISOLATE.${getName(element)}"; |
| 286 } | 292 } |
| 287 | 293 |
| 288 String isolateBailoutAccess(Element element) { | 294 String isolateBailoutAccess(Element element) { |
| 289 return '${isolateAccess(element)}\$bailout'; | 295 return '${isolateAccess(element)}\$bailout'; |
| 290 } | 296 } |
| 291 | 297 |
| 298 String isolateLazyInitializerAccess(Element element) { |
| 299 return "$CURRENT_ISOLATE.${getLazyInitializerName(element)}"; |
| 300 } |
| 301 |
| 292 String operatorIs(Element element) { | 302 String operatorIs(Element element) { |
| 293 return 'is\$${getName(element)}'; | 303 return 'is\$${getName(element)}'; |
| 294 } | 304 } |
| 295 | 305 |
| 296 String safeName(String name) { | 306 String safeName(String name) { |
| 297 if (jsReserved.contains(name) || name.startsWith('\$')) { | 307 if (jsReserved.contains(name) || name.startsWith('\$')) { |
| 298 name = "\$$name"; | 308 name = "\$$name"; |
| 299 assert(!jsReserved.contains(name)); | 309 assert(!jsReserved.contains(name)); |
| 300 } | 310 } |
| 301 return name; | 311 return name; |
| 302 } | 312 } |
| 303 } | 313 } |
| OLD | NEW |