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

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, 3 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 Generator topLevelGenerator =
Roman 2012/08/24 07:21:04 It is weird that generators are defined in renamer
Roman 2012/08/24 07:27:01 I just thought it would be better to pass the flag
Anton Muhin 2012/08/24 08:42:53 Done.
106 minify ? new MinifyingGenerator('ABCD').generate : conservativeGenerator ;
Roman 2012/08/24 07:21:04 80 chars
Anton Muhin 2012/08/24 08:42:53 Now obsolete On 2012/08/24 07:21:04, Roman wrote:
107 renamePlaceholders(
108 compiler, collector, renames, imports, topLevelGenerator);
105 109
106 // Sort elements. 110 // Sort elements.
107 final sortedTopLevels = sortElements(topLevelElements); 111 final sortedTopLevels = sortElements(topLevelElements);
108 final sortedClassMembers = new Map<ClassElement, List<Element>>(); 112 final sortedClassMembers = new Map<ClassElement, List<Element>>();
109 classMembers.forEach((classElement, members) { 113 classMembers.forEach((classElement, members) {
110 sortedClassMembers[classElement] = sortElements(members); 114 sortedClassMembers[classElement] = sortElements(members);
111 }); 115 });
112 116
113 final unparser = new Unparser.withRenamer((Node node) => renames[node]); 117 final unparser = new Unparser.withRenamer((Node node) => renames[node]);
114 compiler.assembledCode = emitCode( 118 compiler.assembledCode = emitCode(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 195
192 List<Element> sortElements(Collection<Element> elements) { 196 List<Element> sortElements(Collection<Element> elements) {
193 compareElements(e0, e1) { 197 compareElements(e0, e1) {
194 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); 198 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1);
195 if (result != 0) return result; 199 if (result != 0) return result;
196 return compareBy((e) => e.position().charOffset)(e0, e1); 200 return compareBy((e) => e.position().charOffset)(e0, e1);
197 } 201 }
198 202
199 return sorted(elements, compareElements); 203 return sorted(elements, compareElements);
200 } 204 }
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