| 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 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 for (String outputUnit in outputBuffers.keys) { | 1156 for (String outputUnit in outputBuffers.keys) { |
| 1157 ClassBuilder descriptor = | 1157 ClassBuilder descriptor = |
| 1158 descriptors.putIfAbsent(outputUnit, () | 1158 descriptors.putIfAbsent(outputUnit, () |
| 1159 => new ClassBuilder()); | 1159 => new ClassBuilder()); |
| 1160 if (descriptor.properties.isEmpty) continue; | 1160 if (descriptor.properties.isEmpty) continue; |
| 1161 bool isDeferred = outputUnit != "main"; | 1161 bool isDeferred = outputUnit != "main"; |
| 1162 jsAst.Fun metadata = metadataEmitter.buildMetadataFunction(library); | 1162 jsAst.Fun metadata = metadataEmitter.buildMetadataFunction(library); |
| 1163 | 1163 |
| 1164 jsAst.ObjectInitializer initializers = | 1164 jsAst.ObjectInitializer initializers = |
| 1165 descriptor.toObjectInitializer(); | 1165 descriptor.toObjectInitializer(); |
| 1166 int sizeBefore = outputBuffers[outputUnit].length; |
| 1166 outputBuffers[outputUnit] | 1167 outputBuffers[outputUnit] |
| 1167 ..write('["${library.getLibraryName()}",$_') | 1168 ..write('["${library.getLibraryName()}",$_') |
| 1168 ..write('"${uri}",$_') | 1169 ..write('"${uri}",$_') |
| 1169 ..write(metadata == null ? "" : jsAst.prettyPrint(metadata, compiler)) | 1170 ..write(metadata == null ? "" : jsAst.prettyPrint(metadata, compiler)) |
| 1170 ..write(isDeferred ? '[]' : '') | 1171 ..write(isDeferred ? '[]' : '') |
| 1171 ..write(',$_') | 1172 ..write(',$_') |
| 1172 ..write(namer.globalObjectFor(library)) | 1173 ..write(namer.globalObjectFor(library)) |
| 1173 ..write(',$_') | 1174 ..write(',$_') |
| 1174 ..write(jsAst.prettyPrint(initializers, compiler)) | 1175 ..write(jsAst.prettyPrint(initializers, compiler)) |
| 1175 ..write(library == compiler.mainApp ? ',${n}1' : "") | 1176 ..write(library == compiler.mainApp ? ',${n}1' : "") |
| 1176 ..write('],$n'); | 1177 ..write('],$n'); |
| 1178 int sizeAfter = outputBuffers[outputUnit].length; |
| 1179 compiler.dumpInfoTask.codeSizeCounter |
| 1180 .countCode(library, sizeAfter - sizeBefore); |
| 1177 } | 1181 } |
| 1178 } | 1182 } |
| 1179 | 1183 |
| 1180 String assembleProgram() { | 1184 String assembleProgram() { |
| 1181 measure(() { | 1185 measure(() { |
| 1182 // Compute the required type checks to know which classes need a | 1186 // Compute the required type checks to know which classes need a |
| 1183 // 'is$' method. | 1187 // 'is$' method. |
| 1184 typeTestEmitter.computeRequiredTypeChecks(); | 1188 typeTestEmitter.computeRequiredTypeChecks(); |
| 1185 | 1189 |
| 1186 computeNeededClasses(); | 1190 computeNeededClasses(); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 } | 1590 } |
| 1587 | 1591 |
| 1588 bool isDeferred(Element element) { | 1592 bool isDeferred(Element element) { |
| 1589 return compiler.deferredLoadTask.isDeferred(element); | 1593 return compiler.deferredLoadTask.isDeferred(element); |
| 1590 } | 1594 } |
| 1591 | 1595 |
| 1592 bool get areAnyElementsDeferred { | 1596 bool get areAnyElementsDeferred { |
| 1593 return compiler.deferredLoadTask.areAnyElementsDeferred; | 1597 return compiler.deferredLoadTask.areAnyElementsDeferred; |
| 1594 } | 1598 } |
| 1595 } | 1599 } |
| OLD | NEW |