| 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Generates the code for all used classes in the program. Static fields (even | 8 * Generates the code for all used classes in the program. Static fields (even |
| 9 * in classes) are ignored, since they can be treated as non-class elements. | 9 * in classes) are ignored, since they can be treated as non-class elements. |
| 10 * | 10 * |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 for (String outputUnit in outputBuffers.keys) { | 1169 for (String outputUnit in outputBuffers.keys) { |
| 1170 ClassBuilder descriptor = | 1170 ClassBuilder descriptor = |
| 1171 descriptors.putIfAbsent(outputUnit, () | 1171 descriptors.putIfAbsent(outputUnit, () |
| 1172 => new ClassBuilder()); | 1172 => new ClassBuilder()); |
| 1173 if (descriptor.properties.isEmpty) continue; | 1173 if (descriptor.properties.isEmpty) continue; |
| 1174 bool isDeferred = outputUnit != "main"; | 1174 bool isDeferred = outputUnit != "main"; |
| 1175 jsAst.Fun metadata = metadataEmitter.buildMetadataFunction(library); | 1175 jsAst.Fun metadata = metadataEmitter.buildMetadataFunction(library); |
| 1176 | 1176 |
| 1177 jsAst.ObjectInitializer initializers = | 1177 jsAst.ObjectInitializer initializers = |
| 1178 descriptor.toObjectInitializer(); | 1178 descriptor.toObjectInitializer(); |
| 1179 int sizeBefore = outputBuffers[outputUnit].length; |
| 1179 outputBuffers[outputUnit] | 1180 outputBuffers[outputUnit] |
| 1180 ..write('["${library.getLibraryName()}",$_') | 1181 ..write('["${library.getLibraryName()}",$_') |
| 1181 ..write('"${uri}",$_') | 1182 ..write('"${uri}",$_') |
| 1182 ..write(metadata == null ? "" : jsAst.prettyPrint(metadata, compiler)) | 1183 ..write(metadata == null ? "" : jsAst.prettyPrint(metadata, compiler)) |
| 1183 ..write(isDeferred ? '[]' : '') | 1184 ..write(isDeferred ? '[]' : '') |
| 1184 ..write(',$_') | 1185 ..write(',$_') |
| 1185 ..write(namer.globalObjectFor(library)) | 1186 ..write(namer.globalObjectFor(library)) |
| 1186 ..write(',$_') | 1187 ..write(',$_') |
| 1187 ..write(jsAst.prettyPrint(initializers, compiler)) | 1188 ..write(jsAst.prettyPrint(initializers, compiler)) |
| 1188 ..write(library == compiler.mainApp ? ',${n}1' : "") | 1189 ..write(library == compiler.mainApp ? ',${n}1' : "") |
| 1189 ..write('],$n'); | 1190 ..write('],$n'); |
| 1191 int sizeAfter = outputBuffers[outputUnit].length; |
| 1192 compiler.backend. |
| 1193 codeSizeCounter.countCode(library, sizeAfter - sizeBefore); |
| 1190 } | 1194 } |
| 1191 } | 1195 } |
| 1192 | 1196 |
| 1193 String assembleProgram() { | 1197 String assembleProgram() { |
| 1194 measure(() { | 1198 measure(() { |
| 1195 // Compute the required type checks to know which classes need a | 1199 // Compute the required type checks to know which classes need a |
| 1196 // 'is$' method. | 1200 // 'is$' method. |
| 1197 typeTestEmitter.computeRequiredTypeChecks(); | 1201 typeTestEmitter.computeRequiredTypeChecks(); |
| 1198 | 1202 |
| 1199 computeNeededClasses(); | 1203 computeNeededClasses(); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 } | 1603 } |
| 1600 | 1604 |
| 1601 bool isDeferred(Element element) { | 1605 bool isDeferred(Element element) { |
| 1602 return compiler.deferredLoadTask.isDeferred(element); | 1606 return compiler.deferredLoadTask.isDeferred(element); |
| 1603 } | 1607 } |
| 1604 | 1608 |
| 1605 bool get areAnyElementsDeferred { | 1609 bool get areAnyElementsDeferred { |
| 1606 return compiler.deferredLoadTask.areAnyElementsDeferred; | 1610 return compiler.deferredLoadTask.areAnyElementsDeferred; |
| 1607 } | 1611 } |
| 1608 } | 1612 } |
| OLD | NEW |