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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 | 401 |
402 String getLazyInitializerName(Element element) { | 402 String getLazyInitializerName(Element element) { |
403 assert(Elements.isStaticOrTopLevelField(element)); | 403 assert(Elements.isStaticOrTopLevelField(element)); |
404 return getMappedGlobalName("get\$${getName(element)}"); | 404 return getMappedGlobalName("get\$${getName(element)}"); |
405 } | 405 } |
406 | 406 |
407 String isolatePropertiesAccess(Element element) { | 407 String isolatePropertiesAccess(Element element) { |
408 return "$ISOLATE.$ISOLATE_PROPERTIES.${getName(element)}"; | 408 return "$ISOLATE.$ISOLATE_PROPERTIES.${getName(element)}"; |
409 } | 409 } |
410 | 410 |
411 String isolatePropertiesAccessForConstant(String constantName) { | 411 js.Expression isolatePropertiesAccessForConstant(String constantName) { |
ngeoffray
2012/11/27 09:26:28
I'd prefer not having this method here. The namer
sra1
2012/11/28 03:59:44
I might agree, but that leaves the question of whe
ngeoffray
2012/11/28 09:25:21
So maybe the isolateAccess, isolateBailoutAccess..
floitsch
2012/11/28 10:04:32
I agree. And it should probably be the emitter any
| |
412 return "$ISOLATE.$ISOLATE_PROPERTIES.$constantName"; | 412 // $ISOLATE.$ISOLATE_PROPERTIES.$constantName |
413 return new js.PropertyAccess.field( | |
414 new js.PropertyAccess.field( | |
415 new js.VariableUse(ISOLATE), ISOLATE_PROPERTIES), | |
416 constantName); | |
413 } | 417 } |
414 | 418 |
415 String isolateAccess(Element element) { | 419 String isolateAccess(Element element) { |
416 return "$CURRENT_ISOLATE.${getName(element)}"; | 420 return "$CURRENT_ISOLATE.${getName(element)}"; |
417 } | 421 } |
418 | 422 |
419 String isolateBailoutAccess(Element element) { | 423 String isolateBailoutAccess(Element element) { |
420 String newName = getMappedGlobalName('${getName(element)}\$bailout'); | 424 String newName = getMappedGlobalName('${getName(element)}\$bailout'); |
421 return '$CURRENT_ISOLATE.$newName'; | 425 return '$CURRENT_ISOLATE.$newName'; |
422 } | 426 } |
423 | 427 |
424 String isolateLazyInitializerAccess(Element element) { | 428 String isolateLazyInitializerAccess(Element element) { |
425 return "$CURRENT_ISOLATE.${getLazyInitializerName(element)}"; | 429 return "$CURRENT_ISOLATE.${getLazyInitializerName(element)}"; |
426 } | 430 } |
427 | 431 |
428 String operatorIs(Element element) { | 432 String operatorIs(Element element) { |
429 // TODO(erikcorry): Reduce from is$x to ix when we are minifying. | 433 // TODO(erikcorry): Reduce from is$x to ix when we are minifying. |
430 return 'is\$${getName(element)}'; | 434 return 'is\$${getName(element)}'; |
431 } | 435 } |
432 | 436 |
433 String safeName(String name) { | 437 String safeName(String name) { |
434 if (jsReserved.contains(name) || name.startsWith('\$')) { | 438 if (jsReserved.contains(name) || name.startsWith('\$')) { |
435 name = "\$$name"; | 439 name = "\$$name"; |
436 assert(!jsReserved.contains(name)); | 440 assert(!jsReserved.contains(name)); |
437 } | 441 } |
438 return name; | 442 return name; |
439 } | 443 } |
440 } | 444 } |
OLD | NEW |