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