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

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

Issue 14018036: Remove holders for runtime type information. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix type annotation. Created 7 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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 name = '$unminifiedName$level'; 629 name = '$unminifiedName$level';
630 } 630 }
631 name = getMappedInstanceName(name); 631 name = getMappedInstanceName(name);
632 } 632 }
633 bailoutNames[element] = name; 633 bailoutNames[element] = name;
634 return name; 634 return name;
635 } 635 }
636 636
637 /// Returns the runtime name for [element]. The result is not safe as an id. 637 /// Returns the runtime name for [element]. The result is not safe as an id.
638 String getRuntimeTypeName(Element element) { 638 String getRuntimeTypeName(Element element) {
639 if (element == compiler.intClass) { 639 JavaScriptBackend backend = compiler.backend;
640 element = backend.getImplementationClass(element);
641 String name = getPrimitiveInterceptorRuntimeName(element);
642 return name != null ? name : getName(element);
643 }
644
645 /**
646 * Return a string to be used as the runtime name of this class (instead of
647 * the class name) or [null] if the class name should be used.
648 */
649 String getPrimitiveInterceptorRuntimeName(Element cls) {
650 JavaScriptBackend backend = compiler.backend;
651 if (cls == backend.jsIntClass) {
640 return 'int'; 652 return 'int';
641 } else if (element == compiler.doubleClass) { 653 } else if (cls == backend.jsNumberClass) {
654 return 'num';
655 } else if (cls == backend.jsBoolClass) {
656 return 'bool';
657 } else if (cls == backend.jsDoubleClass) {
642 return 'double'; 658 return 'double';
659 } else if (cls == backend.jsStringClass) {
660 return 'String';
661 } else if (cls == backend.jsArrayClass) {
662 return 'List';
643 } else { 663 } else {
644 return getName(element); 664 return null;
645 } 665 }
646 } 666 }
647 667
648 /** 668 /**
649 * Returns a preferred JS-id for the given element. The returned id is 669 * Returns a preferred JS-id for the given element. The returned id is
650 * guaranteed to be a valid JS-id. Globals and static fields are furthermore 670 * guaranteed to be a valid JS-id. Globals and static fields are furthermore
651 * guaranteed to be unique. 671 * guaranteed to be unique.
652 * 672 *
653 * For accessing statics consider calling 673 * For accessing statics consider calling
654 * [isolateAccess]/[isolateBailoutAccess] or [isolatePropertyAccess] instead. 674 * [isolateAccess]/[isolateBailoutAccess] or [isolatePropertyAccess] instead.
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 hash = hash ^ (hash >> 6); 1144 hash = hash ^ (hash >> 6);
1125 return hash; 1145 return hash;
1126 } 1146 }
1127 1147
1128 static int _finish(int hash) { 1148 static int _finish(int hash) {
1129 hash = _MASK & (hash + (((_MASK >> 3) & hash) << 3)); 1149 hash = _MASK & (hash + (((_MASK >> 3) & hash) << 3));
1130 hash = hash & (hash >> 11); 1150 hash = hash & (hash >> 11);
1131 return _MASK & (hash + (((_MASK >> 15) & hash) << 15)); 1151 return _MASK & (hash + (((_MASK >> 15) & hash) << 15));
1132 } 1152 }
1133 } 1153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698