| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import '../compiler.dart'; | |
| 6 import '../common/names.dart'; | |
| 7 import '../elements/elements.dart'; | |
| 8 import '../kernel/kernel.dart'; | |
| 9 import 'package:kernel/ast.dart' as ir; | |
| 10 | |
| 11 import 'backend.dart'; | |
| 12 | |
| 13 /// Visits the compiler main function and builds the kernel representation. | |
| 14 /// | |
| 15 /// This creates a mapping from kernel nodes to AST nodes to be used later. | |
| 16 class KernelTask { | |
| 17 final Compiler _compiler; | |
| 18 final Kernel kernel; | |
| 19 | |
| 20 KernelTask(JavaScriptBackend backend) | |
| 21 : this._compiler = backend.compiler, | |
| 22 this.kernel = new Kernel(backend.compiler); | |
| 23 | |
| 24 ir.Program program; | |
| 25 | |
| 26 /// Builds the kernel IR for the main function. | |
| 27 /// | |
| 28 /// May enqueue more elements to the resolution queue. | |
| 29 void buildKernelIr() { | |
| 30 program = buildProgram(_compiler.mainApp); | |
| 31 } | |
| 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 = | |
| 40 kernel.functionToIr(library.findExported(Identifiers.main)); | |
| 41 } | |
| 42 } | |
| OLD | NEW |