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

Side by Side Diff: lib/compiler/implementation/emitter.dart

Issue 10310040: Sort the output (for now just the classes and instance members). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 8 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) 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 /** 5 /**
6 * A function element that represents a closure call. The signature is copied 6 * A function element that represents a closure call. The signature is copied
7 * from the given element. 7 * from the given element.
8 */ 8 */
9 class ClosureInvocationElement extends FunctionElement { 9 class ClosureInvocationElement extends FunctionElement {
10 ClosureInvocationElement(SourceString name, 10 ClosureInvocationElement(SourceString name,
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 Set<ClassElement> neededClasses = 480 Set<ClassElement> neededClasses =
481 new Set<ClassElement>.from(instantiatedClasses); 481 new Set<ClassElement>.from(instantiatedClasses);
482 for (ClassElement element in instantiatedClasses) { 482 for (ClassElement element in instantiatedClasses) {
483 for (ClassElement superclass = element.superclass; 483 for (ClassElement superclass = element.superclass;
484 superclass !== null; 484 superclass !== null;
485 superclass = superclass.superclass) { 485 superclass = superclass.superclass) {
486 if (neededClasses.contains(superclass)) break; 486 if (neededClasses.contains(superclass)) break;
487 neededClasses.add(superclass); 487 neededClasses.add(superclass);
488 } 488 }
489 } 489 }
490 for (ClassElement element in neededClasses) { 490 List<ClassElement> sortedClasses =
491 new List<ClassElement>.from(neededClasses);
492 sortedClasses.sort((ClassElement class1, ClassElement class2) {
493 // We sort by the ids of the classes. There is no guarantee that these
494 // ids are meaningful (or even deterministic), but in the current
495 // implementation they are increasing within a source file.
496 return class1.id - class2.id;
497 });
498 for (ClassElement element in sortedClasses) {
491 generateClass(element, buffer); 499 generateClass(element, buffer);
492 } 500 }
493 501
494 // The closure class could have become necessary because of the generation 502 // The closure class could have become necessary because of the generation
495 // of stubs. 503 // of stubs.
496 ClassElement closureClass = compiler.closureClass; 504 ClassElement closureClass = compiler.closureClass;
497 if (needsClosureClass && !instantiatedClasses.contains(closureClass)) { 505 if (needsClosureClass && !instantiatedClasses.contains(closureClass)) {
498 generateClass(closureClass, buffer); 506 generateClass(closureClass, buffer);
499 } 507 }
500 } 508 }
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 mainBuffer.add('function init() {\n'); 906 mainBuffer.add('function init() {\n');
899 mainBuffer.add(' $isolateProperties = {};\n'); 907 mainBuffer.add(' $isolateProperties = {};\n');
900 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer); 908 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer);
901 emitFinishIsolateConstructor(mainBuffer); 909 emitFinishIsolateConstructor(mainBuffer);
902 mainBuffer.add('}\n'); 910 mainBuffer.add('}\n');
903 compiler.assembledCode = mainBuffer.toString(); 911 compiler.assembledCode = mainBuffer.toString();
904 }); 912 });
905 return compiler.assembledCode; 913 return compiler.assembledCode;
906 } 914 }
907 } 915 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/elements/elements.dart ('k') | lib/compiler/implementation/scanner/class_element_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698