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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_target.dart

Issue 2691273002: Use kernel transformation and VmTarget. (Closed)
Patch Set: Created 3 years, 10 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
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 fasta.kernel_target; 5 library fasta.kernel_target;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:io' show 10 import 'dart:io' show
(...skipping 10 matching lines...) Expand all
21 ExpressionStatement, 21 ExpressionStatement,
22 Field, 22 Field,
23 FieldInitializer, 23 FieldInitializer,
24 FunctionNode, 24 FunctionNode,
25 Initializer, 25 Initializer,
26 InvalidInitializer, 26 InvalidInitializer,
27 Library, 27 Library,
28 Name, 28 Name,
29 NamedExpression, 29 NamedExpression,
30 NullLiteral, 30 NullLiteral,
31 Procedure,
32 ProcedureKind, 31 ProcedureKind,
33 Program, 32 Program,
34 RedirectingInitializer, 33 RedirectingInitializer,
35 ReturnStatement,
36 Source, 34 Source,
37 StaticGet,
38 StringLiteral, 35 StringLiteral,
39 SuperInitializer, 36 SuperInitializer,
40 Throw, 37 Throw,
41 VariableDeclaration, 38 VariableDeclaration,
42 VariableGet, 39 VariableGet,
43 VoidType; 40 VoidType;
44 41
45 import 'package:kernel/binary/ast_to_binary.dart' show 42 import 'package:kernel/binary/ast_to_binary.dart' show
46 BinaryPrinter; 43 BinaryPrinter;
47 44
48 import 'package:kernel/text/ast_to_text.dart' show 45 import 'package:kernel/text/ast_to_text.dart' show
49 Printer; 46 Printer;
50 47
51 import 'package:kernel/transformations/mixin_full_resolution.dart' show 48 import 'package:kernel/transformations/mixin_full_resolution.dart' show
52 MixinFullResolution; 49 MixinFullResolution;
53 50
51 import 'package:kernel/transformations/setup_builtin_library.dart' as
52 setup_builtin_library;
53
54 import '../source/source_loader.dart' show 54 import '../source/source_loader.dart' show
55 SourceLoader; 55 SourceLoader;
56 56
57 import '../source/source_class_builder.dart' show 57 import '../source/source_class_builder.dart' show
58 SourceClassBuilder; 58 SourceClassBuilder;
59 59
60 import '../target_implementation.dart' show 60 import '../target_implementation.dart' show
61 TargetImplementation; 61 TargetImplementation;
62 62
63 import '../translate_uri.dart' show 63 import '../translate_uri.dart' show
64 TranslateUri; 64 TranslateUri;
65 65
66 import '../dill/dill_target.dart' show 66 import '../dill/dill_target.dart' show
67 DillTarget; 67 DillTarget;
68 68
69 import '../dill/dill_member_builder.dart' show
70 DillMemberBuilder;
71
72 import '../ast_kind.dart' show 69 import '../ast_kind.dart' show
73 AstKind; 70 AstKind;
74 71
75 import '../errors.dart' show 72 import '../errors.dart' show
76 InputError, 73 InputError,
77 internalError, 74 internalError,
78 reportCrash, 75 reportCrash,
79 resetCrashReporting; 76 resetCrashReporting;
80 77
81 import 'kernel_builder.dart' show 78 import 'kernel_builder.dart' show
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // that used when there's no fileUri on an element. Instead, ensure all 308 // that used when there's no fileUri on an element. Instead, ensure all
312 // elements have a fileUri. 309 // elements have a fileUri.
313 uriToSource[""] = new Source(<int>[0], ""); 310 uriToSource[""] = new Source(<int>[0], "");
314 Program program = new Program(libraries, uriToSource); 311 Program program = new Program(libraries, uriToSource);
315 if (loader.first != null) { 312 if (loader.first != null) {
316 Builder builder = loader.first.members["main"]; 313 Builder builder = loader.first.members["main"];
317 if (builder is KernelProcedureBuilder) { 314 if (builder is KernelProcedureBuilder) {
318 program.mainMethod = builder.procedure; 315 program.mainMethod = builder.procedure;
319 } 316 }
320 } 317 }
321 // TODO(ahe): This is kinda hackish. Use the transformer instead. 318 setup_builtin_library.transformProgram(program);
322 LibraryBuilder builtin =
323 dillTarget.loader.builders[Uri.parse("dart:_builtin")];
324 if (builtin != null) {
325 DillMemberBuilder builder = builtin.members["_getMainClosure"];
326 if (builder != null) {
327 Expression getMain = program.mainMethod == null
328 ? new Throw(new StringLiteral("No main method."))
329 : new StaticGet(program.mainMethod);
330 Procedure procedure = builder.member;
331 procedure.function = new FunctionNode(new ReturnStatement(getMain));
332 procedure.function.parent = procedure;
333 }
334 }
335 ticker.logMs("Linked program"); 319 ticker.logMs("Linked program");
336 return program; 320 return program;
337 } 321 }
338 322
339 Future<Program> writeLinkedProgram(Uri uri, Program program, 323 Future<Program> writeLinkedProgram(Uri uri, Program program,
340 {bool isFullProgram}) async { 324 {bool isFullProgram}) async {
341 File output = new File.fromUri(uri); 325 File output = new File.fromUri(uri);
342 IOSink sink = output.openWrite(); 326 IOSink sink = output.openWrite();
343 try { 327 try {
344 new BinaryPrinter(sink).writeProgramFile(program); 328 new BinaryPrinter(sink).writeProgramFile(program);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 superclass = superclass.superclass; 576 superclass = superclass.superclass;
593 } 577 }
594 for (Constructor constructor in superclass.constructors) { 578 for (Constructor constructor in superclass.constructors) {
595 if (constructor.name.name.isEmpty) { 579 if (constructor.name.name.isEmpty) {
596 return constructor.function.requiredParameterCount == 0 ? 580 return constructor.function.requiredParameterCount == 0 ?
597 constructor : null; 581 constructor : null;
598 } 582 }
599 } 583 }
600 return null; 584 return null;
601 } 585 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/analyzer/token_utils.dart ('k') | pkg/front_end/lib/src/fasta/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698