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

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

Issue 10875040: Support customizing API (and hence mock) compiler to minify the output. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 class DartBackend extends Backend { 5 class DartBackend extends Backend {
6 final List<CompilerTask> tasks; 6 final List<CompilerTask> tasks;
7 final bool minify;
7 8
8 Map<Element, TreeElements> get resolvedElements => 9 Map<Element, TreeElements> get resolvedElements =>
9 compiler.enqueuer.resolution.resolvedElements; 10 compiler.enqueuer.resolution.resolvedElements;
10 11
11 DartBackend(Compiler compiler) 12 DartBackend(Compiler compiler, this.minify)
12 : tasks = <CompilerTask>[], 13 : tasks = <CompilerTask>[],
13 super(compiler); 14 super(compiler);
14 15
15 void enqueueHelpers(Enqueuer world) { } 16 void enqueueHelpers(Enqueuer world) { }
16 void codegen(WorkItem work) { } 17 void codegen(WorkItem work) { }
17 void processNativeClasses(Enqueuer world, 18 void processNativeClasses(Enqueuer world,
18 Collection<LibraryElement> libraries) { } 19 Collection<LibraryElement> libraries) { }
19 20
20 void assembleProgram() { 21 void assembleProgram() {
21 /** 22 /**
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 collector.collect(element, treeElements); 95 collector.collect(element, treeElements);
95 if (element is ClassElement) { 96 if (element is ClassElement) {
96 classMembers[element].forEach(makePlaceholders); 97 classMembers[element].forEach(makePlaceholders);
97 } 98 }
98 } 99 }
99 topLevelElements.forEach(makePlaceholders); 100 topLevelElements.forEach(makePlaceholders);
100 101
101 // Create renames. 102 // Create renames.
102 Map<Node, String> renames = new Map<Node, String>(); 103 Map<Node, String> renames = new Map<Node, String>();
103 Map<LibraryElement, String> imports = new Map<LibraryElement, String>(); 104 Map<LibraryElement, String> imports = new Map<LibraryElement, String>();
104 renamePlaceholders(compiler, collector, renames, imports); 105 renamePlaceholders(compiler, collector, renames, imports, minify);
105 106
106 // Sort elements. 107 // Sort elements.
107 final sortedTopLevels = sortElements(topLevelElements); 108 final sortedTopLevels = sortElements(topLevelElements);
108 final sortedClassMembers = new Map<ClassElement, List<Element>>(); 109 final sortedClassMembers = new Map<ClassElement, List<Element>>();
109 classMembers.forEach((classElement, members) { 110 classMembers.forEach((classElement, members) {
110 sortedClassMembers[classElement] = sortElements(members); 111 sortedClassMembers[classElement] = sortElements(members);
111 }); 112 });
112 113
113 final unparser = new Unparser.withRenamer((Node node) => renames[node]); 114 final unparser = new Unparser.withRenamer((Node node) => renames[node]);
114 compiler.assembledCode = emitCode( 115 compiler.assembledCode = emitCode(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 192
192 List<Element> sortElements(Collection<Element> elements) { 193 List<Element> sortElements(Collection<Element> elements) {
193 compareElements(e0, e1) { 194 compareElements(e0, e1) {
194 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); 195 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1);
195 if (result != 0) return result; 196 if (result != 0) return result;
196 return compareBy((e) => e.position().charOffset)(e0, e1); 197 return compareBy((e) => e.position().charOffset)(e0, e1);
197 } 198 }
198 199
199 return sorted(elements, compareElements); 200 return sorted(elements, compareElements);
200 } 201 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/dart_backend/renamer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698