| OLD | NEW |
| 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; | |
| 8 final bool cutDeclarationTypes; | 7 final bool cutDeclarationTypes; |
| 9 | 8 |
| 10 Map<Element, TreeElements> get resolvedElements => | 9 Map<Element, TreeElements> get resolvedElements => |
| 11 compiler.enqueuer.resolution.resolvedElements; | 10 compiler.enqueuer.resolution.resolvedElements; |
| 12 | 11 |
| 13 DartBackend(Compiler compiler, this.minify, this.cutDeclarationTypes) | 12 DartBackend(Compiler compiler, this.cutDeclarationTypes) |
| 14 : tasks = <CompilerTask>[], | 13 : tasks = <CompilerTask>[], |
| 15 super(compiler); | 14 super(compiler); |
| 16 | 15 |
| 17 void enqueueHelpers(Enqueuer world) { | 16 void enqueueHelpers(Enqueuer world) { |
| 18 // Right now resolver doesn't always resolve interfaces needed | 17 // Right now resolver doesn't always resolve interfaces needed |
| 19 // for literals, so force them. TODO(antonm): fix in the resolver. | 18 // for literals, so force them. TODO(antonm): fix in the resolver. |
| 20 final LITERAL_TYPE_NAMES = const [ | 19 final LITERAL_TYPE_NAMES = const [ |
| 21 'Map', 'List', 'num', 'int', 'double', 'bool' | 20 'Map', 'List', 'num', 'int', 'double', 'bool' |
| 22 ]; | 21 ]; |
| 23 final coreLibrary = compiler.coreLibrary; | 22 final coreLibrary = compiler.coreLibrary; |
| 24 for (final name in LITERAL_TYPE_NAMES) { | 23 for (final name in LITERAL_TYPE_NAMES) { |
| 25 ClassElement classElement = coreLibrary.findLocal(new SourceString(name)); | 24 ClassElement classElement = coreLibrary.findLocal(new SourceString(name)); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 classMembers[element].forEach(makePlaceholders); | 139 classMembers[element].forEach(makePlaceholders); |
| 141 } | 140 } |
| 142 } | 141 } |
| 143 topLevelElements.forEach(makePlaceholders); | 142 topLevelElements.forEach(makePlaceholders); |
| 144 | 143 |
| 145 // Create renames. | 144 // Create renames. |
| 146 Map<Node, String> renames = new Map<Node, String>(); | 145 Map<Node, String> renames = new Map<Node, String>(); |
| 147 Map<LibraryElement, String> imports = new Map<LibraryElement, String>(); | 146 Map<LibraryElement, String> imports = new Map<LibraryElement, String>(); |
| 148 renamePlaceholders( | 147 renamePlaceholders( |
| 149 compiler, collector, renames, imports, | 148 compiler, collector, renames, imports, |
| 150 fixedMemberNames, minify, cutDeclarationTypes); | 149 fixedMemberNames, cutDeclarationTypes); |
| 151 | 150 |
| 152 // Sort elements. | 151 // Sort elements. |
| 153 final sortedTopLevels = sortElements(topLevelElements); | 152 final sortedTopLevels = sortElements(topLevelElements); |
| 154 final sortedClassMembers = new Map<ClassElement, List<Element>>(); | 153 final sortedClassMembers = new Map<ClassElement, List<Element>>(); |
| 155 classMembers.forEach((classElement, members) { | 154 classMembers.forEach((classElement, members) { |
| 156 sortedClassMembers[classElement] = sortElements(members); | 155 sortedClassMembers[classElement] = sortElements(members); |
| 157 }); | 156 }); |
| 158 | 157 |
| 159 final unparser = new Unparser.withRenamer((Node node) => renames[node]); | 158 final unparser = new Unparser.withRenamer((Node node) => renames[node]); |
| 160 compiler.assembledCode = emitCode( | 159 compiler.assembledCode = emitCode( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 222 |
| 224 List<Element> sortElements(Collection<Element> elements) { | 223 List<Element> sortElements(Collection<Element> elements) { |
| 225 compareElements(e0, e1) { | 224 compareElements(e0, e1) { |
| 226 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); | 225 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); |
| 227 if (result != 0) return result; | 226 if (result != 0) return result; |
| 228 return compareBy((e) => e.position().charOffset)(e0, e1); | 227 return compareBy((e) => e.position().charOffset)(e0, e1); |
| 229 } | 228 } |
| 230 | 229 |
| 231 return sorted(elements, compareElements); | 230 return sorted(elements, compareElements); |
| 232 } | 231 } |
| OLD | NEW |