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

Side by Side Diff: pkg/kernel/lib/transformations/setup_builtin_library.dart

Issue 2612873005: Allow main to be null for modular tranformation. (Closed)
Patch Set: Created 3 years, 11 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 kernel.transformations.setup_builtin_library; 5 library kernel.transformations.setup_builtin_library;
6 6
7 import '../ast.dart'; 7 import '../ast.dart';
8 8
9 // The DartVM has a special `dart:_builtin` library which exposes a 9 // The DartVM has a special `dart:_builtin` library which exposes a
10 // `_getMainClosure()` method. We need to change this method to return a 10 // `_getMainClosure()` method. We need to change this method to return a
11 // closure of `main()`. 11 // closure of `main()`.
12 Program transformProgram(Program program, 12 Program transformProgram(Program program,
13 {String libraryUri: 'dart:_builtin'}) { 13 {String libraryUri: 'dart:_builtin'}) {
14 Procedure mainMethod = program.mainMethod; 14 Procedure mainMethod = program.mainMethod;
15 15
16 if (mainMethod == null) return program;
17
16 Library builtinLibrary; 18 Library builtinLibrary;
17 for (Library library in program.libraries) { 19 for (Library library in program.libraries) {
18 if (library.importUri.toString() == libraryUri) { 20 if (library.importUri.toString() == libraryUri) {
19 builtinLibrary = library; 21 builtinLibrary = library;
20 break; 22 break;
21 } 23 }
22 } 24 }
23 25
24 if (builtinLibrary == null) { 26 if (builtinLibrary == null) {
25 throw new Exception('Could not find "dart:_builtin" library'); 27 throw new Exception('Could not find "dart:_builtin" library');
(...skipping 10 matching lines...) Expand all
36 if (getMainClosure == null) { 38 if (getMainClosure == null) {
37 throw new Exception('Could not find "_getMainClosure" in "$libraryUri"'); 39 throw new Exception('Could not find "_getMainClosure" in "$libraryUri"');
38 } 40 }
39 41
40 var returnMainStatement = new ReturnStatement(new StaticGet(mainMethod)); 42 var returnMainStatement = new ReturnStatement(new StaticGet(mainMethod));
41 getMainClosure.body = returnMainStatement; 43 getMainClosure.body = returnMainStatement;
42 returnMainStatement.parent = getMainClosure; 44 returnMainStatement.parent = getMainClosure;
43 45
44 return program; 46 return program;
45 } 47 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698