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 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 OutputUnit mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 1432 OutputUnit mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
1433 typeTestEmitter.emitRuntimeTypeSupport(mainBuffer, mainOutputUnit); | 1433 typeTestEmitter.emitRuntimeTypeSupport(mainBuffer, mainOutputUnit); |
1434 interceptorEmitter.emitGetInterceptorMethods(mainBuffer); | 1434 interceptorEmitter.emitGetInterceptorMethods(mainBuffer); |
1435 interceptorEmitter.emitOneShotInterceptors(mainBuffer); | 1435 interceptorEmitter.emitOneShotInterceptors(mainBuffer); |
1436 // Constants in checked mode call into RTI code to set type information | 1436 // Constants in checked mode call into RTI code to set type information |
1437 // which may need getInterceptor (and one-shot interceptor) methods, so | 1437 // which may need getInterceptor (and one-shot interceptor) methods, so |
1438 // we have to make sure that [emitGetInterceptorMethods] and | 1438 // we have to make sure that [emitGetInterceptorMethods] and |
1439 // [emitOneShotInterceptors] have been called. | 1439 // [emitOneShotInterceptors] have been called. |
1440 emitCompileTimeConstants(mainBuffer, mainOutputUnit); | 1440 emitCompileTimeConstants(mainBuffer, mainOutputUnit); |
1441 | 1441 |
1442 // We write a javascript mapping from DeferredLibrary elements | 1442 // Write a javascript mapping from Deferred import load ids (derrived from |
1443 // (really their String argument) to the js hunk to load. | 1443 // the import prefix.) to a list of lists of js hunks to load. |
1444 // TODO(sigurdm): Create a syntax tree for this. | 1444 // TODO(sigurdm): Create a syntax tree for this. |
1445 // TODO(sigurdm): Also find out where to place it. | 1445 // TODO(sigurdm): Also find out where to place it. |
1446 mainBuffer.write("\$.libraries_to_load = {"); | 1446 mainBuffer.write("\$.libraries_to_load = {"); |
1447 for (String constant in compiler.deferredLoadTask.hunksToLoad.keys) { | 1447 for (String loadId in compiler.deferredLoadTask.hunksToLoad.keys) { |
1448 // TODO(sigurdm): Escape these strings. | 1448 // TODO(sigurdm): Escape these strings. |
1449 mainBuffer.write('"$constant":['); | 1449 mainBuffer.write('"$loadId":['); |
1450 for (OutputUnit outputUnit in | 1450 for (List<OutputUnit> outputUnits in |
1451 compiler.deferredLoadTask.hunksToLoad[constant]) { | 1451 compiler.deferredLoadTask.hunksToLoad[loadId]) { |
1452 mainBuffer.write('"${outputUnit.partFileName(compiler)}.part.js", '); | 1452 mainBuffer.write("["); |
| 1453 for (OutputUnit outputUnit in outputUnits) { |
| 1454 mainBuffer |
| 1455 .write('"${outputUnit.partFileName(compiler)}.part.js", '); |
| 1456 } |
| 1457 mainBuffer.write("],"); |
1453 } | 1458 } |
1454 mainBuffer.write("],\n"); | 1459 mainBuffer.write("],\n"); |
1455 } | 1460 } |
1456 mainBuffer.write("}$N"); | 1461 mainBuffer.write("}$N"); |
1457 // Static field initializations require the classes and compile-time | 1462 // Static field initializations require the classes and compile-time |
1458 // constants to be set up. | 1463 // constants to be set up. |
1459 emitStaticNonFinalFieldInitializations(mainBuffer); | 1464 emitStaticNonFinalFieldInitializations(mainBuffer); |
1460 interceptorEmitter.emitInterceptedNames(mainBuffer); | 1465 interceptorEmitter.emitInterceptedNames(mainBuffer); |
1461 interceptorEmitter.emitMapTypeToInterceptor(mainBuffer); | 1466 interceptorEmitter.emitMapTypeToInterceptor(mainBuffer); |
1462 emitLazilyInitializedStaticFields(mainBuffer); | 1467 emitLazilyInitializedStaticFields(mainBuffer); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 String sourceMap = sourceMapBuilder.build(compiledFile); | 1706 String sourceMap = sourceMapBuilder.build(compiledFile); |
1702 compiler.outputProvider(name, 'js.map') | 1707 compiler.outputProvider(name, 'js.map') |
1703 ..add(sourceMap) | 1708 ..add(sourceMap) |
1704 ..close(); | 1709 ..close(); |
1705 } | 1710 } |
1706 | 1711 |
1707 void registerReadTypeVariable(TypeVariableElement element) { | 1712 void registerReadTypeVariable(TypeVariableElement element) { |
1708 readTypeVariables.add(element); | 1713 readTypeVariables.add(element); |
1709 } | 1714 } |
1710 } | 1715 } |
OLD | NEW |