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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart

Issue 24527005: Manually enqueue compareTo, hashCode, ==, and toString in the Dart-to-Dart backend to avoid tree sh… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | tests/corelib/regress_11099_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 dart_backend; 5 part of dart_backend;
6 6
7 // TODO(ahe): This class is simply wrong. This backend should use 7 // TODO(ahe): This class is simply wrong. This backend should use
8 // elements when it can, not AST nodes. Perhaps a [Map<Element, 8 // elements when it can, not AST nodes. Perhaps a [Map<Element,
9 // TreeElements>] is what is needed. 9 // TreeElements>] is what is needed.
10 class ElementAst { 10 class ElementAst {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Right now resolver doesn't always resolve interfaces needed 204 // Right now resolver doesn't always resolve interfaces needed
205 // for literals, so force them. TODO(antonm): fix in the resolver. 205 // for literals, so force them. TODO(antonm): fix in the resolver.
206 final LITERAL_TYPE_NAMES = const [ 206 final LITERAL_TYPE_NAMES = const [
207 'Map', 'List', 'num', 'int', 'double', 'bool' 207 'Map', 'List', 'num', 'int', 'double', 'bool'
208 ]; 208 ];
209 final coreLibrary = compiler.coreLibrary; 209 final coreLibrary = compiler.coreLibrary;
210 for (final name in LITERAL_TYPE_NAMES) { 210 for (final name in LITERAL_TYPE_NAMES) {
211 ClassElement classElement = coreLibrary.findLocal(new SourceString(name)); 211 ClassElement classElement = coreLibrary.findLocal(new SourceString(name));
212 classElement.ensureResolved(compiler); 212 classElement.ensureResolved(compiler);
213 } 213 }
214 // Enqueue the methods that the VM might invoke on user objects because
215 // we don't trust the resolution to always get these included.
216 world.registerInvocation(
217 new Selector.call(const SourceString("toString"), null, 0));
218 world.registerInvokedGetter(
219 new Selector.getter(const SourceString("hashCode"), null));
220 world.registerInvocation(
221 new Selector.binaryOperator(const SourceString("==")));
222 world.registerInvocation(
223 new Selector.call(const SourceString("compareTo"), null, 1));
214 } 224 }
225
215 void codegen(CodegenWorkItem work) { } 226 void codegen(CodegenWorkItem work) { }
216 void processNativeClasses(Enqueuer world, 227 void processNativeClasses(Enqueuer world,
217 Iterable<LibraryElement> libraries) { } 228 Iterable<LibraryElement> libraries) { }
218 229
219 bool isUserLibrary(LibraryElement lib) { 230 bool isUserLibrary(LibraryElement lib) {
220 final INTERNAL_HELPERS = [ 231 final INTERNAL_HELPERS = [
221 compiler.jsHelperLibrary, 232 compiler.jsHelperLibrary,
222 compiler.interceptorsLibrary, 233 compiler.interceptorsLibrary,
223 ]; 234 ];
224 return INTERNAL_HELPERS.indexOf(lib) == -1 && !lib.isPlatformLibrary; 235 return INTERNAL_HELPERS.indexOf(lib) == -1 && !lib.isPlatformLibrary;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 628 }
618 629
619 compareElements(e0, e1) { 630 compareElements(e0, e1) {
620 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); 631 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1);
621 if (result != 0) return result; 632 if (result != 0) return result;
622 return compareBy((e) => e.position().charOffset)(e0, e1); 633 return compareBy((e) => e.position().charOffset)(e0, e1);
623 } 634 }
624 635
625 List<Element> sortElements(Iterable<Element> elements) => 636 List<Element> sortElements(Iterable<Element> elements) =>
626 sorted(elements, compareElements); 637 sorted(elements, compareElements);
OLDNEW
« no previous file with comments | « no previous file | tests/corelib/regress_11099_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698