| 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 class MainCallStubGenerator { | 7 class MainCallStubGenerator { |
| 8 final Compiler compiler; | 8 final Compiler compiler; |
| 9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
| 10 final CodeEmitterTask emitterTask; | 10 final CodeEmitterTask emitterTask; |
| 11 | 11 |
| 12 MainCallStubGenerator(this.compiler, this.backend, this.emitterTask); | 12 MainCallStubGenerator(this.compiler, this.backend, this.emitterTask); |
| 13 | 13 |
| 14 /// Returns the code equivalent to: | 14 /// Returns the code equivalent to: |
| 15 /// `function(args) { $.startRootIsolate(X.main$closure(), args); }` | 15 /// `function(args) { $.startRootIsolate(X.main$closure(), args); }` |
| 16 jsAst.Expression _buildIsolateSetupClosure(Element appMain, | 16 jsAst.Expression _buildIsolateSetupClosure(Element appMain, |
| 17 Element isolateMain) { | 17 Element isolateMain) { |
| 18 jsAst.Expression mainAccess = | 18 jsAst.Expression mainAccess = |
| 19 emitterTask.isolateStaticClosureAccess(appMain); | 19 emitterTask.isolateStaticClosureAccess(appMain); |
| 20 // Since we pass the closurized version of the main method to | 20 // Since we pass the closurized version of the main method to |
| 21 // the isolate method, we must make sure that it exists. | 21 // the isolate method, we must make sure that it exists. |
| 22 return js('function(a){ #(#, a); }', | 22 return js('function(a){ #(#, a); }', |
| 23 [emitterTask.staticFunctionAccess(isolateMain), mainAccess]); | 23 [emitterTask.staticFunctionAccess(isolateMain), mainAccess]); |
| 24 } | 24 } |
| 25 | 25 |
| 26 | 26 |
| 27 jsAst.Statement generateInvokeMain() { | 27 jsAst.Statement generateInvokeMain() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (typeof dartMainRunner === "function") { | 73 if (typeof dartMainRunner === "function") { |
| 74 dartMainRunner(#mainCallClosure, []); | 74 dartMainRunner(#mainCallClosure, []); |
| 75 } else { | 75 } else { |
| 76 #mainCallClosure([]); | 76 #mainCallClosure([]); |
| 77 } | 77 } |
| 78 })''', | 78 })''', |
| 79 {'currentScript': currentScriptAccess, | 79 {'currentScript': currentScriptAccess, |
| 80 'mainCallClosure': mainCallClosure}); | 80 'mainCallClosure': mainCallClosure}); |
| 81 } | 81 } |
| 82 } | 82 } |
| OLD | NEW |