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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 new MyClass(); | 1292 new MyClass(); |
1293 #; | 1293 #; |
1294 return properties; | 1294 return properties; |
1295 }''', [debugCode]); | 1295 }''', [debugCode]); |
1296 | 1296 |
1297 mainBuffer.add(jsAst.prettyPrint(convertToFastObject, compiler)); | 1297 mainBuffer.add(jsAst.prettyPrint(convertToFastObject, compiler)); |
1298 mainBuffer.add(N); | 1298 mainBuffer.add(N); |
1299 } | 1299 } |
1300 | 1300 |
1301 void writeLibraryDescriptors(LibraryElement library) { | 1301 void writeLibraryDescriptors(LibraryElement library) { |
1302 var uri = library.canonicalUri; | 1302 var uri = ""; |
1303 if (uri.scheme == 'file' && compiler.outputUri != null) { | 1303 if (!compiler.enableMinification || backend.mustRetainUris) { |
1304 uri = relativize(compiler.outputUri, library.canonicalUri, false); | 1304 uri = library.canonicalUri; |
| 1305 if (uri.scheme == 'file' && compiler.outputUri != null) { |
| 1306 uri = relativize(compiler.outputUri, library.canonicalUri, false); |
| 1307 } |
1305 } | 1308 } |
| 1309 String libraryName = |
| 1310 (!compiler.enableMinification || backend.mustRetainLibraryNames) ? |
| 1311 library.getLibraryName() : |
| 1312 ""; |
1306 Map<OutputUnit, ClassBuilder> descriptors = | 1313 Map<OutputUnit, ClassBuilder> descriptors = |
1307 elementDescriptors[library]; | 1314 elementDescriptors[library]; |
1308 | 1315 |
1309 for (OutputUnit outputUnit in compiler.deferredLoadTask.allOutputUnits) { | 1316 for (OutputUnit outputUnit in compiler.deferredLoadTask.allOutputUnits) { |
1310 ClassBuilder descriptor = | 1317 ClassBuilder descriptor = |
1311 descriptors.putIfAbsent(outputUnit, () => new ClassBuilder(namer)); | 1318 descriptors.putIfAbsent(outputUnit, () => new ClassBuilder(namer)); |
1312 if (descriptor.properties.isEmpty) continue; | 1319 if (descriptor.properties.isEmpty) continue; |
1313 bool isDeferred = | 1320 bool isDeferred = |
1314 outputUnit != compiler.deferredLoadTask.mainOutputUnit; | 1321 outputUnit != compiler.deferredLoadTask.mainOutputUnit; |
1315 jsAst.Fun metadata = metadataEmitter.buildMetadataFunction(library); | 1322 jsAst.Fun metadata = metadataEmitter.buildMetadataFunction(library); |
1316 | 1323 |
1317 jsAst.ObjectInitializer initializers = | 1324 jsAst.ObjectInitializer initializers = |
1318 descriptor.toObjectInitializer(); | 1325 descriptor.toObjectInitializer(); |
1319 CodeBuffer outputBuffer = | 1326 CodeBuffer outputBuffer = |
1320 outputBuffers.putIfAbsent(outputUnit, () => new CodeBuffer()); | 1327 outputBuffers.putIfAbsent(outputUnit, () => new CodeBuffer()); |
1321 int sizeBefore = outputBuffer.length; | 1328 int sizeBefore = outputBuffer.length; |
1322 outputBuffers[outputUnit] | 1329 outputBuffers[outputUnit] |
1323 ..write('["${library.getLibraryName()}",$_') | 1330 ..write('["$libraryName",$_') |
1324 ..write('"${uri}",$_') | 1331 ..write('"${uri}",$_') |
1325 ..write(metadata == null ? "" : jsAst.prettyPrint(metadata, compiler)) | 1332 ..write(metadata == null ? "" : jsAst.prettyPrint(metadata, compiler)) |
1326 ..write(',$_') | 1333 ..write(',$_') |
1327 ..write(namer.globalObjectFor(library)) | 1334 ..write(namer.globalObjectFor(library)) |
1328 ..write(',$_') | 1335 ..write(',$_') |
1329 ..write(jsAst.prettyPrint(initializers, compiler)) | 1336 ..write(jsAst.prettyPrint(initializers, compiler)) |
1330 ..write(library == compiler.mainApp ? ',${n}1' : "") | 1337 ..write(library == compiler.mainApp ? ',${n}1' : "") |
1331 ..write('],$n'); | 1338 ..write('],$n'); |
1332 int sizeAfter = outputBuffer.length; | 1339 int sizeAfter = outputBuffer.length; |
1333 compiler.dumpInfoTask.codeSizeCounter | 1340 compiler.dumpInfoTask.codeSizeCounter |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 1804 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
1798 if (element.isInstanceMember) { | 1805 if (element.isInstanceMember) { |
1799 cachedClassBuilders.remove(element.enclosingClass); | 1806 cachedClassBuilders.remove(element.enclosingClass); |
1800 | 1807 |
1801 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 1808 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
1802 | 1809 |
1803 } | 1810 } |
1804 } | 1811 } |
1805 } | 1812 } |
1806 } | 1813 } |
OLD | NEW |