| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart2js.js_emitter.main_call_stub_generator; | 5 library dart2js.js_emitter.main_call_stub_generator; |
| 6 | 6 |
| 7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
| 8 | 8 |
| 9 import '../elements/entities.dart'; | 9 import '../elements/entities.dart'; |
| 10 import '../js/js.dart' as jsAst; | 10 import '../js/js.dart' as jsAst; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 jsAst.Expression mainAccess = | 29 jsAst.Expression mainAccess = |
| 30 emitterTask.isolateStaticClosureAccess(appMain); | 30 emitterTask.isolateStaticClosureAccess(appMain); |
| 31 // Since we pass the closurized version of the main method to | 31 // Since we pass the closurized version of the main method to |
| 32 // the isolate method, we must make sure that it exists. | 32 // the isolate method, we must make sure that it exists. |
| 33 return js('function(a){ #(#, a); }', | 33 return js('function(a){ #(#, a); }', |
| 34 [emitterTask.staticFunctionAccess(isolateMain), mainAccess]); | 34 [emitterTask.staticFunctionAccess(isolateMain), mainAccess]); |
| 35 } | 35 } |
| 36 | 36 |
| 37 jsAst.Statement generateInvokeMain(FunctionEntity main) { | 37 jsAst.Statement generateInvokeMain(FunctionEntity main) { |
| 38 jsAst.Expression mainCallClosure = null; | 38 jsAst.Expression mainCallClosure = null; |
| 39 if (backend.hasIsolateSupport) { | 39 if (backend.backendUsage.isIsolateInUse) { |
| 40 FunctionEntity isolateMain = helpers.startRootIsolate; | 40 FunctionEntity isolateMain = helpers.startRootIsolate; |
| 41 mainCallClosure = _buildIsolateSetupClosure(main, isolateMain); | 41 mainCallClosure = _buildIsolateSetupClosure(main, isolateMain); |
| 42 } else { | 42 } else { |
| 43 mainCallClosure = emitterTask.staticFunctionAccess(main); | 43 mainCallClosure = emitterTask.staticFunctionAccess(main); |
| 44 } | 44 } |
| 45 | 45 |
| 46 jsAst.Expression currentScriptAccess = | 46 jsAst.Expression currentScriptAccess = |
| 47 emitterTask.generateEmbeddedGlobalAccess(embeddedNames.CURRENT_SCRIPT); | 47 emitterTask.generateEmbeddedGlobalAccess(embeddedNames.CURRENT_SCRIPT); |
| 48 | 48 |
| 49 // This code finds the currently executing script by listening to the | 49 // This code finds the currently executing script by listening to the |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } else { | 82 } else { |
| 83 #mainCallClosure([]); | 83 #mainCallClosure([]); |
| 84 } | 84 } |
| 85 })''', | 85 })''', |
| 86 { | 86 { |
| 87 'currentScript': currentScriptAccess, | 87 'currentScript': currentScriptAccess, |
| 88 'mainCallClosure': mainCallClosure | 88 'mainCallClosure': mainCallClosure |
| 89 }); | 89 }); |
| 90 } | 90 } |
| 91 } | 91 } |
| OLD | NEW |