Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: pkg/compiler/lib/src/js_emitter/main_call_stub_generator.dart

Issue 1413213004: Move remaining helpers to BackendHelpers (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 BackendHelpers get helpers => backend.helpers;
15
14 /// Returns the code equivalent to: 16 /// Returns the code equivalent to:
15 /// `function(args) { $.startRootIsolate(X.main$closure(), args); }` 17 /// `function(args) { $.startRootIsolate(X.main$closure(), args); }`
16 jsAst.Expression _buildIsolateSetupClosure(Element appMain, 18 jsAst.Expression _buildIsolateSetupClosure(Element appMain,
17 Element isolateMain) { 19 Element isolateMain) {
18 jsAst.Expression mainAccess = 20 jsAst.Expression mainAccess =
19 emitterTask.isolateStaticClosureAccess(appMain); 21 emitterTask.isolateStaticClosureAccess(appMain);
20 // Since we pass the closurized version of the main method to 22 // Since we pass the closurized version of the main method to
21 // the isolate method, we must make sure that it exists. 23 // the isolate method, we must make sure that it exists.
22 return js('function(a){ #(#, a); }', 24 return js('function(a){ #(#, a); }',
23 [emitterTask.staticFunctionAccess(isolateMain), mainAccess]); 25 [emitterTask.staticFunctionAccess(isolateMain), mainAccess]);
24 } 26 }
25 27
26
27 jsAst.Statement generateInvokeMain() { 28 jsAst.Statement generateInvokeMain() {
28 Element main = compiler.mainFunction; 29 Element main = compiler.mainFunction;
29 jsAst.Expression mainCallClosure = null; 30 jsAst.Expression mainCallClosure = null;
30 if (compiler.hasIsolateSupport) { 31 if (compiler.hasIsolateSupport) {
31 Element isolateMain = 32 Element isolateMain =
32 backend.isolateHelperLibrary.find(JavaScriptBackend.START_ROOT_ISOLATE); 33 helpers.isolateHelperLibrary.find(BackendHelpers.START_ROOT_ISOLATE);
33 mainCallClosure = _buildIsolateSetupClosure(main, isolateMain); 34 mainCallClosure = _buildIsolateSetupClosure(main, isolateMain);
34 } else if (compiler.hasIncrementalSupport) { 35 } else if (compiler.hasIncrementalSupport) {
35 mainCallClosure = js( 36 mainCallClosure = js(
36 'function() { return #(); }', 37 'function() { return #(); }',
37 emitterTask.staticFunctionAccess(main)); 38 emitterTask.staticFunctionAccess(main));
38 } else { 39 } else {
39 mainCallClosure = emitterTask.staticFunctionAccess(main); 40 mainCallClosure = emitterTask.staticFunctionAccess(main);
40 } 41 }
41 42
42 jsAst.Expression currentScriptAccess = 43 jsAst.Expression currentScriptAccess =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 if (typeof dartMainRunner === "function") { 76 if (typeof dartMainRunner === "function") {
76 dartMainRunner(#mainCallClosure, []); 77 dartMainRunner(#mainCallClosure, []);
77 } else { 78 } else {
78 #mainCallClosure([]); 79 #mainCallClosure([]);
79 } 80 }
80 })''', 81 })''',
81 {'currentScript': currentScriptAccess, 82 {'currentScript': currentScriptAccess,
82 'mainCallClosure': mainCallClosure}); 83 'mainCallClosure': mainCallClosure});
83 } 84 }
84 } 85 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/js_emitter.dart ('k') | pkg/compiler/lib/src/js_emitter/native_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698