| 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 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 elementDescriptors[library] = const {}; | 1374 elementDescriptors[library] = const {}; |
| 1375 } | 1375 } |
| 1376 if (!pendingStatics.isEmpty) { | 1376 if (!pendingStatics.isEmpty) { |
| 1377 compiler.internalError('Pending statics (see above).'); | 1377 compiler.internalError('Pending statics (see above).'); |
| 1378 } | 1378 } |
| 1379 mainBuffer.write('])$N'); | 1379 mainBuffer.write('])$N'); |
| 1380 | 1380 |
| 1381 emitFinishClassesInvocationIfNecessary(mainBuffer); | 1381 emitFinishClassesInvocationIfNecessary(mainBuffer); |
| 1382 classesCollector = oldClassesCollector; | 1382 classesCollector = oldClassesCollector; |
| 1383 } | 1383 } |
| 1384 | 1384 OutputUnit mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
| 1385 typeTestEmitter.emitRuntimeTypeSupport(mainBuffer); | 1385 typeTestEmitter.emitRuntimeTypeSupport(mainBuffer, mainOutputUnit); |
| 1386 interceptorEmitter.emitGetInterceptorMethods(mainBuffer); | 1386 interceptorEmitter.emitGetInterceptorMethods(mainBuffer); |
| 1387 interceptorEmitter.emitOneShotInterceptors(mainBuffer); | 1387 interceptorEmitter.emitOneShotInterceptors(mainBuffer); |
| 1388 // Constants in checked mode call into RTI code to set type information | 1388 // Constants in checked mode call into RTI code to set type information |
| 1389 // which may need getInterceptor (and one-shot interceptor) methods, so | 1389 // which may need getInterceptor (and one-shot interceptor) methods, so |
| 1390 // we have to make sure that [emitGetInterceptorMethods] and | 1390 // we have to make sure that [emitGetInterceptorMethods] and |
| 1391 // [emitOneShotInterceptors] have been called. | 1391 // [emitOneShotInterceptors] have been called. |
| 1392 emitCompileTimeConstants( | 1392 emitCompileTimeConstants(mainBuffer, mainOutputUnit); |
| 1393 mainBuffer, compiler.deferredLoadTask.mainOutputUnit); | |
| 1394 | 1393 |
| 1395 // We write a javascript mapping from DeferredLibrary elements | 1394 // We write a javascript mapping from DeferredLibrary elements |
| 1396 // (really their String argument) to the js hunk to load. | 1395 // (really their String argument) to the js hunk to load. |
| 1397 // TODO(sigurdm): Create a syntax tree for this. | 1396 // TODO(sigurdm): Create a syntax tree for this. |
| 1398 // TODO(sigurdm): Also find out where to place it. | 1397 // TODO(sigurdm): Also find out where to place it. |
| 1399 mainBuffer.write("\$.libraries_to_load = {"); | 1398 mainBuffer.write("\$.libraries_to_load = {"); |
| 1400 for (String constant in compiler.deferredLoadTask.hunksToLoad.keys) { | 1399 for (String constant in compiler.deferredLoadTask.hunksToLoad.keys) { |
| 1401 // TODO(sigurdm): Escape these strings. | 1400 // TODO(sigurdm): Escape these strings. |
| 1402 mainBuffer.write('"$constant":['); | 1401 mainBuffer.write('"$constant":['); |
| 1403 for (OutputUnit outputUnit in | 1402 for (OutputUnit outputUnit in |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 '$_$isolatePropertiesName)$N'); | 1561 '$_$isolatePropertiesName)$N'); |
| 1563 } | 1562 } |
| 1564 | 1563 |
| 1565 buffer.write( | 1564 buffer.write( |
| 1566 // Reset the classesCollector ($$). | 1565 // Reset the classesCollector ($$). |
| 1567 '$classesCollector$_=${_}null$N$n' | 1566 '$classesCollector$_=${_}null$N$n' |
| 1568 '${namer.currentIsolate}$_=${_}old${namer.currentIsolate}$N'); | 1567 '${namer.currentIsolate}$_=${_}old${namer.currentIsolate}$N'); |
| 1569 | 1568 |
| 1570 classesCollector = oldClassesCollector; | 1569 classesCollector = oldClassesCollector; |
| 1571 | 1570 |
| 1571 typeTestEmitter.emitRuntimeTypeSupport(buffer, outputUnit); |
| 1572 |
| 1572 emitCompileTimeConstants(buffer, outputUnit); | 1573 emitCompileTimeConstants(buffer, outputUnit); |
| 1573 | 1574 |
| 1574 String code = buffer.getText(); | 1575 String code = buffer.getText(); |
| 1575 compiler.outputProvider(outputUnit.name, 'js') | 1576 compiler.outputProvider(outputUnit.name, 'js') |
| 1576 ..add(code) | 1577 ..add(code) |
| 1577 ..close(); | 1578 ..close(); |
| 1578 outputSourceMap(compiler.assembledCode, outputUnit.name); | 1579 outputSourceMap(compiler.assembledCode, outputUnit.name); |
| 1579 } | 1580 } |
| 1580 } | 1581 } |
| 1581 | 1582 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1601 String sourceMap = buildSourceMap(mainBuffer, compiledFile); | 1602 String sourceMap = buildSourceMap(mainBuffer, compiledFile); |
| 1602 compiler.outputProvider(name, 'js.map') | 1603 compiler.outputProvider(name, 'js.map') |
| 1603 ..add(sourceMap) | 1604 ..add(sourceMap) |
| 1604 ..close(); | 1605 ..close(); |
| 1605 } | 1606 } |
| 1606 | 1607 |
| 1607 void registerReadTypeVariable(TypeVariableElement element) { | 1608 void registerReadTypeVariable(TypeVariableElement element) { |
| 1608 readTypeVariables.add(element); | 1609 readTypeVariables.add(element); |
| 1609 } | 1610 } |
| 1610 } | 1611 } |
| OLD | NEW |