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

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

Issue 236313012: Don't hide interceptors in mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 7 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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 return getMappedGlobalName(root, ensureSafe: false); 719 return getMappedGlobalName(root, ensureSafe: false);
720 } else { 720 } else {
721 String suffix = getInterceptorSuffix(classes); 721 String suffix = getInterceptorSuffix(classes);
722 return getMappedGlobalName("$root\$$suffix", ensureSafe: false); 722 return getMappedGlobalName("$root\$$suffix", ensureSafe: false);
723 } 723 }
724 } 724 }
725 725
726 /// Returns the runtime name for [element]. The result is not safe as an id. 726 /// Returns the runtime name for [element]. The result is not safe as an id.
727 String getRuntimeTypeName(Element element) { 727 String getRuntimeTypeName(Element element) {
728 if (identical(element, compiler.dynamicClass)) return 'dynamic'; 728 if (identical(element, compiler.dynamicClass)) return 'dynamic';
729 JavaScriptBackend backend = compiler.backend; 729 return getNameForRti(element);
730 element = backend.getImplementationClass(element);
731 String name = getPrimitiveInterceptorRuntimeName(element);
732 // TODO(ahe): Creating a string here is unfortunate. It is slow (due to
733 // string concatenation in the implementation), and may prevent
734 // segmentation of '$'.
735 return name != null ? name : getNameForRti(element);
736 } 730 }
737 731
738 /** 732 /**
739 * Return a string to be used as the runtime name of this class (instead of
740 * the class name) or [:null:] if the class name should be used.
741 */
742 String getPrimitiveInterceptorRuntimeName(Element cls) {
743 JavaScriptBackend backend = compiler.backend;
744 if (cls == backend.jsIntClass) {
745 return 'int';
746 } else if (cls == backend.jsNumberClass) {
747 return 'num';
748 } else if (cls == backend.jsBoolClass) {
749 return 'bool';
750 } else if (cls == backend.jsDoubleClass) {
751 return 'double';
752 } else if (cls == backend.jsStringClass) {
753 return 'String';
754 } else if (cls == backend.jsArrayClass) {
755 return 'List';
756 } else if (cls == backend.jsNullClass) {
757 return 'Null';
758 } else {
759 return null;
760 }
761 }
762
763 /**
764 * Returns a preferred JS-id for the given element. The returned id is 733 * Returns a preferred JS-id for the given element. The returned id is
765 * guaranteed to be a valid JS-id. Globals and static fields are furthermore 734 * guaranteed to be a valid JS-id. Globals and static fields are furthermore
766 * guaranteed to be unique. 735 * guaranteed to be unique.
767 * 736 *
768 * For accessing statics consider calling 737 * For accessing statics consider calling
769 * [isolateAccess] or [isolatePropertyAccess] instead. 738 * [isolateAccess] or [isolatePropertyAccess] instead.
770 */ 739 */
771 // TODO(ahe): This is an internal method to the Namer (and its subclasses) 740 // TODO(ahe): This is an internal method to the Namer (and its subclasses)
772 // and should not be call from outside. 741 // and should not be call from outside.
773 String getNameX(Element element) { 742 String getNameX(Element element) {
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 if (!first) { 1374 if (!first) {
1406 sb.write('_'); 1375 sb.write('_');
1407 } 1376 }
1408 sb.write('_'); 1377 sb.write('_');
1409 visit(link.head); 1378 visit(link.head);
1410 first = true; 1379 first = true;
1411 } 1380 }
1412 } 1381 }
1413 } 1382 }
1414 } 1383 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698