OLD | NEW |
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 import '../common/names.dart'; |
| 6 import '../common/tasks.dart' show CompilerTask; |
5 import '../compiler.dart'; | 7 import '../compiler.dart'; |
6 import '../common/names.dart'; | |
7 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
8 import '../kernel/kernel.dart'; | 9 import 'kernel.dart'; |
9 import 'package:kernel/ast.dart' as ir; | 10 import 'package:kernel/ast.dart' as ir; |
10 | 11 |
11 import 'backend.dart'; | |
12 | |
13 /// Visits the compiler main function and builds the kernel representation. | 12 /// Visits the compiler main function and builds the kernel representation. |
14 /// | 13 /// |
15 /// This creates a mapping from kernel nodes to AST nodes to be used later. | 14 /// This creates a mapping from kernel nodes to AST nodes to be used later. |
16 class KernelTask { | 15 class KernelTask extends CompilerTask { |
| 16 get name => "kernel"; |
| 17 |
17 final Compiler _compiler; | 18 final Compiler _compiler; |
18 final Kernel kernel; | 19 final Kernel kernel; |
19 | 20 |
20 KernelTask(JavaScriptBackend backend) | 21 KernelTask(Compiler compiler) |
21 : this._compiler = backend.compiler, | 22 : this._compiler = compiler, |
22 this.kernel = new Kernel(backend.compiler); | 23 this.kernel = new Kernel(compiler), |
| 24 super(compiler.measurer); |
23 | 25 |
24 ir.Program program; | 26 ir.Program program; |
25 | 27 |
26 /// Builds the kernel IR for the main function. | 28 /// Builds the kernel IR for the main function. |
27 /// | 29 /// |
28 /// May enqueue more elements to the resolution queue. | 30 /// May enqueue more elements to the resolution queue. |
29 void buildKernelIr() { | 31 void buildKernelIr() => measure(() { |
30 program = buildProgram(_compiler.mainApp); | 32 program = buildProgram(_compiler.mainApp); |
31 } | 33 }); |
32 | 34 |
33 /// Builds the kernel IR program for the main function exported from | 35 /// Builds the kernel IR program for the main function exported from |
34 /// [library]. | 36 /// [library]. |
35 /// | 37 /// |
36 /// May enqueue more elements to the resolution queue. | 38 /// May enqueue more elements to the resolution queue. |
37 ir.Program buildProgram(LibraryElement library) { | 39 ir.Program buildProgram(LibraryElement library) { |
38 return new ir.Program(kernel.libraryDependencies(library.canonicalUri)) | 40 return new ir.Program(kernel.libraryDependencies(library.canonicalUri)) |
39 ..mainMethod = | 41 ..mainMethod = |
40 kernel.functionToIr(library.findExported(Identifiers.main)); | 42 kernel.functionToIr(library.findExported(Identifiers.main)); |
41 } | 43 } |
42 } | 44 } |
OLD | NEW |