Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/namer.dart

Issue 12211012: Revert "Implement substitution for type variables." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 implements ClosureNamer { 10 class Namer implements ClosureNamer {
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 String newName = getMappedGlobalName('${getName(element)}\$bailout'); 663 String newName = getMappedGlobalName('${getName(element)}\$bailout');
664 return '$CURRENT_ISOLATE.$newName'; 664 return '$CURRENT_ISOLATE.$newName';
665 } 665 }
666 666
667 String isolateLazyInitializerAccess(Element element) { 667 String isolateLazyInitializerAccess(Element element) {
668 return "$CURRENT_ISOLATE.${getLazyInitializerName(element)}"; 668 return "$CURRENT_ISOLATE.${getLazyInitializerName(element)}";
669 } 669 }
670 670
671 String operatorIsPrefix() => r'$is'; 671 String operatorIsPrefix() => r'$is';
672 672
673 String operatorAsPrefix() => r'$as';
674
675 String operatorIs(Element element) { 673 String operatorIs(Element element) {
676 // TODO(erikcorry): Reduce from $isx to ix when we are minifying. 674 // TODO(erikcorry): Reduce from $isx to ix when we are minifying.
677 return '${operatorIsPrefix()}${getName(element)}'; 675 return '${operatorIsPrefix()}${getName(element)}';
678 } 676 }
679 677
680 /* 678 /*
681 * Returns a name that does not clash with reserved JS keywords, 679 * Returns a name that does not clash with reserved JS keywords,
682 * and also ensures it won't clash with other identifiers. 680 * and also ensures it won't clash with other identifiers.
683 */ 681 */
684 String _safeName(String name, Set<String> reserved) { 682 String _safeName(String name, Set<String> reserved) {
685 if (reserved.contains(name) || name.startsWith(r'$')) { 683 if (reserved.contains(name) || name.startsWith(r'$')) {
686 name = '\$$name'; 684 name = '\$$name';
687 } 685 }
688 assert(!reserved.contains(name)); 686 assert(!reserved.contains(name));
689 return name; 687 return name;
690 } 688 }
691 689
692 String substitutionName(Element element) {
693 return '${operatorAsPrefix()}${getName(element)}';
694 }
695
696 String safeName(String name) => _safeName(name, jsReserved); 690 String safeName(String name) => _safeName(name, jsReserved);
697 String safeVariableName(String name) => _safeName(name, jsVariableReserved); 691 String safeVariableName(String name) => _safeName(name, jsVariableReserved);
698 692
699 String oneShotInterceptorName(Selector selector) { 693 String oneShotInterceptorName(Selector selector) {
700 // TODO(ngeoffray): What to do about typed selectors? We could 694 // TODO(ngeoffray): What to do about typed selectors? We could
701 // filter them out, or keep them and hope the generated one shot 695 // filter them out, or keep them and hope the generated one shot
702 // interceptor takes advantage of the type. 696 // interceptor takes advantage of the type.
703 String cached = oneShotInterceptorNames[selector]; 697 String cached = oneShotInterceptorNames[selector];
704 if (cached != null) return cached; 698 if (cached != null) return cached;
705 SourceString name = operatorNameToIdentifier(selector.name); 699 SourceString name = operatorNameToIdentifier(selector.name);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 return const SourceString(r'$or'); 746 return const SourceString(r'$or');
753 } else if (value == '-') { 747 } else if (value == '-') {
754 return const SourceString(r'$sub'); 748 return const SourceString(r'$sub');
755 } else if (value == 'unary-') { 749 } else if (value == 'unary-') {
756 return const SourceString(r'$negate'); 750 return const SourceString(r'$negate');
757 } else { 751 } else {
758 return name; 752 return name;
759 } 753 }
760 } 754 }
761 } 755 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698