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