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 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 String mainAccess = "${namer.isolateAccess(appMain)}"; | 1435 String mainAccess = "${namer.isolateAccess(appMain)}"; |
1436 String currentIsolate = "${namer.CURRENT_ISOLATE}"; | 1436 String currentIsolate = "${namer.CURRENT_ISOLATE}"; |
1437 String mainEnsureGetter = ''; | 1437 String mainEnsureGetter = ''; |
1438 // Since we pass the closurized version of the main method to | 1438 // Since we pass the closurized version of the main method to |
1439 // the isolate method, we must make sure that it exists. | 1439 // the isolate method, we must make sure that it exists. |
1440 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { | 1440 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { |
1441 Selector selector = new Selector.callClosure(0); | 1441 Selector selector = new Selector.callClosure(0); |
1442 String invocationName = "${namer.closureInvocationName(selector)}"; | 1442 String invocationName = "${namer.closureInvocationName(selector)}"; |
1443 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; | 1443 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; |
1444 } | 1444 } |
1445 | |
1446 // TODO(ngeoffray): These globals are currently required by the isolate | 1445 // TODO(ngeoffray): These globals are currently required by the isolate |
1447 // library. They should be removed. | 1446 // library. They should be removed. |
1448 String runtimeTypeCache = | 1447 String runtimeTypeCache = |
1449 compiler.enabledRuntimeType ? " context.runtimeTypeCache = {}\n" : ""; | 1448 compiler.needsRuntimeTypeCache() ? " context.runtimeTypeCache = {}\n" |
| 1449 : ""; |
1450 | 1450 |
1451 buffer.add(""" | 1451 buffer.add(""" |
1452 var \$globalThis = $currentIsolate; | 1452 var \$globalThis = $currentIsolate; |
1453 var \$globalState; | 1453 var \$globalState; |
1454 var \$globals; | 1454 var \$globals; |
1455 var \$isWorker = false; | 1455 var \$isWorker = false; |
1456 var \$supportsWorkers = false; | 1456 var \$supportsWorkers = false; |
1457 var \$thisScriptUrl; | 1457 var \$thisScriptUrl; |
1458 function \$static_init(){}; | 1458 function \$static_init(){}; |
1459 | 1459 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 emitStaticFunctions(mainBuffer); | 1527 emitStaticFunctions(mainBuffer); |
1528 emitStaticFunctionGetters(mainBuffer); | 1528 emitStaticFunctionGetters(mainBuffer); |
1529 // We need to finish the classes before we construct compile time | 1529 // We need to finish the classes before we construct compile time |
1530 // constants. | 1530 // constants. |
1531 emitFinishClassesInvocationIfNecessary(mainBuffer); | 1531 emitFinishClassesInvocationIfNecessary(mainBuffer); |
1532 emitCompileTimeConstants(mainBuffer); | 1532 emitCompileTimeConstants(mainBuffer); |
1533 // Static field initializations require the classes and compile-time | 1533 // Static field initializations require the classes and compile-time |
1534 // constants to be set up. | 1534 // constants to be set up. |
1535 emitStaticNonFinalFieldInitializations(mainBuffer); | 1535 emitStaticNonFinalFieldInitializations(mainBuffer); |
1536 emitLazilyInitializedStaticFields(mainBuffer); | 1536 emitLazilyInitializedStaticFields(mainBuffer); |
1537 if (compiler.enabledRuntimeType && !compiler.hasIsolateSupport()) { | 1537 if (compiler.needsRuntimeTypeCache() && !compiler.hasIsolateSupport()) { |
1538 mainBuffer.add('$isolateProperties.runtimeTypeCache = {};\n'); | 1538 mainBuffer.add('$isolateProperties.runtimeTypeCache = {};\n'); |
1539 } | 1539 } |
1540 | 1540 |
1541 isolateProperties = isolatePropertiesName; | 1541 isolateProperties = isolatePropertiesName; |
1542 // The following code should not use the short-hand for the | 1542 // The following code should not use the short-hand for the |
1543 // initialStatics. | 1543 // initialStatics. |
1544 mainBuffer.add('var ${namer.CURRENT_ISOLATE} = null;\n'); | 1544 mainBuffer.add('var ${namer.CURRENT_ISOLATE} = null;\n'); |
1545 mainBuffer.add(boundClosureBuffer); | 1545 mainBuffer.add(boundClosureBuffer); |
1546 emitFinishClassesInvocationIfNecessary(mainBuffer); | 1546 emitFinishClassesInvocationIfNecessary(mainBuffer); |
1547 // After this assignment we will produce invalid JavaScript code if we use | 1547 // 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... |
1587 const String HOOKS_API_USAGE = """ | 1587 const String HOOKS_API_USAGE = """ |
1588 // Generated by dart2js, the Dart to JavaScript compiler. | 1588 // Generated by dart2js, the Dart to JavaScript compiler. |
1589 // The code supports the following hooks: | 1589 // The code supports the following hooks: |
1590 // dartPrint(message) - if this function is defined it is called | 1590 // dartPrint(message) - if this function is defined it is called |
1591 // instead of the Dart [print] method. | 1591 // instead of the Dart [print] method. |
1592 // dartMainRunner(main) - if this function is defined, the Dart [main] | 1592 // dartMainRunner(main) - if this function is defined, the Dart [main] |
1593 // method will not be invoked directly. | 1593 // method will not be invoked directly. |
1594 // Instead, a closure that will invoke [main] is | 1594 // Instead, a closure that will invoke [main] is |
1595 // passed to [dartMainRunner]. | 1595 // passed to [dartMainRunner]. |
1596 """; | 1596 """; |
OLD | NEW |