| 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 js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
| 9 * from the given element. | 9 * from the given element. |
| 10 */ | 10 */ |
| (...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 String mainAccess = "${namer.isolateAccess(appMain)}"; | 1414 String mainAccess = "${namer.isolateAccess(appMain)}"; |
| 1415 String currentIsolate = "${namer.CURRENT_ISOLATE}"; | 1415 String currentIsolate = "${namer.CURRENT_ISOLATE}"; |
| 1416 String mainEnsureGetter = ''; | 1416 String mainEnsureGetter = ''; |
| 1417 // Since we pass the closurized version of the main method to | 1417 // Since we pass the closurized version of the main method to |
| 1418 // the isolate method, we must make sure that it exists. | 1418 // the isolate method, we must make sure that it exists. |
| 1419 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { | 1419 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { |
| 1420 Selector selector = new Selector.callClosure(0); | 1420 Selector selector = new Selector.callClosure(0); |
| 1421 String invocationName = "${namer.closureInvocationName(selector)}"; | 1421 String invocationName = "${namer.closureInvocationName(selector)}"; |
| 1422 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; | 1422 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; |
| 1423 } | 1423 } |
| 1424 | |
| 1425 // TODO(ngeoffray): These globals are currently required by the isolate | 1424 // TODO(ngeoffray): These globals are currently required by the isolate |
| 1426 // library. They should be removed. | 1425 // library. They should be removed. |
| 1427 String runtimeTypeCache = | 1426 String runtimeTypeCache = |
| 1428 compiler.enabledRuntimeType ? " context.runtimeTypeCache = {}\n" : ""; | 1427 compiler.needsRuntimeTypeCache() ? " context.runtimeTypeCache = {}\n" |
| 1428 : ""; |
| 1429 | 1429 |
| 1430 buffer.add(""" | 1430 buffer.add(""" |
| 1431 var \$globalThis = $currentIsolate; | 1431 var \$globalThis = $currentIsolate; |
| 1432 var \$globalState; | 1432 var \$globalState; |
| 1433 var \$globals; | 1433 var \$globals; |
| 1434 var \$isWorker = false; | 1434 var \$isWorker = false; |
| 1435 var \$supportsWorkers = false; | 1435 var \$supportsWorkers = false; |
| 1436 var \$thisScriptUrl; | 1436 var \$thisScriptUrl; |
| 1437 function \$static_init(){}; | 1437 function \$static_init(){}; |
| 1438 | 1438 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 emitStaticFunctions(mainBuffer); | 1506 emitStaticFunctions(mainBuffer); |
| 1507 emitStaticFunctionGetters(mainBuffer); | 1507 emitStaticFunctionGetters(mainBuffer); |
| 1508 // We need to finish the classes before we construct compile time | 1508 // We need to finish the classes before we construct compile time |
| 1509 // constants. | 1509 // constants. |
| 1510 emitFinishClassesInvocationIfNecessary(mainBuffer); | 1510 emitFinishClassesInvocationIfNecessary(mainBuffer); |
| 1511 emitCompileTimeConstants(mainBuffer); | 1511 emitCompileTimeConstants(mainBuffer); |
| 1512 // Static field initializations require the classes and compile-time | 1512 // Static field initializations require the classes and compile-time |
| 1513 // constants to be set up. | 1513 // constants to be set up. |
| 1514 emitStaticNonFinalFieldInitializations(mainBuffer); | 1514 emitStaticNonFinalFieldInitializations(mainBuffer); |
| 1515 emitLazilyInitializedStaticFields(mainBuffer); | 1515 emitLazilyInitializedStaticFields(mainBuffer); |
| 1516 if (compiler.enabledRuntimeType && !compiler.hasIsolateSupport()) { | 1516 if (compiler.needsRuntimeTypeCache() && !compiler.hasIsolateSupport()) { |
| 1517 mainBuffer.add('$isolateProperties.runtimeTypeCache = {};\n'); | 1517 mainBuffer.add('$isolateProperties.runtimeTypeCache = {};\n'); |
| 1518 } | 1518 } |
| 1519 | 1519 |
| 1520 isolateProperties = isolatePropertiesName; | 1520 isolateProperties = isolatePropertiesName; |
| 1521 // The following code should not use the short-hand for the | 1521 // The following code should not use the short-hand for the |
| 1522 // initialStatics. | 1522 // initialStatics. |
| 1523 mainBuffer.add('var ${namer.CURRENT_ISOLATE} = null;\n'); | 1523 mainBuffer.add('var ${namer.CURRENT_ISOLATE} = null;\n'); |
| 1524 mainBuffer.add(boundClosureBuffer); | 1524 mainBuffer.add(boundClosureBuffer); |
| 1525 emitFinishClassesInvocationIfNecessary(mainBuffer); | 1525 emitFinishClassesInvocationIfNecessary(mainBuffer); |
| 1526 // After this assignment we will produce invalid JavaScript code if we use | 1526 // After this assignment we will produce invalid JavaScript code if we use |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 const String HOOKS_API_USAGE = """ | 1566 const String HOOKS_API_USAGE = """ |
| 1567 // Generated by dart2js, the Dart to JavaScript compiler. | 1567 // Generated by dart2js, the Dart to JavaScript compiler. |
| 1568 // The code supports the following hooks: | 1568 // The code supports the following hooks: |
| 1569 // dartPrint(message) - if this function is defined it is called | 1569 // dartPrint(message) - if this function is defined it is called |
| 1570 // instead of the Dart [print] method. | 1570 // instead of the Dart [print] method. |
| 1571 // dartMainRunner(main) - if this function is defined, the Dart [main] | 1571 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 1572 // method will not be invoked directly. | 1572 // method will not be invoked directly. |
| 1573 // Instead, a closure that will invoke [main] is | 1573 // Instead, a closure that will invoke [main] is |
| 1574 // passed to [dartMainRunner]. | 1574 // passed to [dartMainRunner]. |
| 1575 """; | 1575 """; |
| OLD | NEW |