Index: pkg/front_end/lib/kernel_generator.dart |
diff --git a/pkg/front_end/lib/kernel_generator.dart b/pkg/front_end/lib/kernel_generator.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..753f44595d41e7309bac71935056f80f9cc1eb0f |
--- /dev/null |
+++ b/pkg/front_end/lib/kernel_generator.dart |
@@ -0,0 +1,50 @@ |
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+/// Defines the front-end API for converting source code to Dart Kernel objects. |
+library front_end.kernel_generator; |
+ |
+import 'dart:async'; |
+import 'options.dart'; |
+import 'package:kernel/kernel.dart' as kernel; |
+ |
+/// Processes the program whose main library is in the given [source]. |
Siggi Cherem (dart-lang)
2016/10/17 16:27:29
Processes => Generate Kernel for ...
Paul Berry
2016/10/17 17:04:27
Done.
|
+/// |
+/// Intended for whole program (non-modular) compilation. |
+/// |
+/// Given the Uri of a file containing a program's `main` method, this function |
+/// follows `import`, `export`, and `part` declarations to discover the whole |
+/// program, and converts the result to Dart Kernel format. |
+/// |
+/// If summaries are provided in [options], they may be used to speed up |
+/// analysis, but they will not take the place of Dart source code (since the |
+/// Dart source code is still needed to access the contents of method bodies). |
+Future<kernel.Program> compileProgram(Options options, Uri source) => |
Brian Wilkerson
2016/10/17 15:08:14
Using "compile" seems wrong here (and below), beca
Siggi Cherem (dart-lang)
2016/10/17 16:27:29
other ideas:
- generateKernel
- programToKernel
Paul Berry
2016/10/17 17:04:27
I like the "fooFor" convention, but when we need t
|
+ throw new UnimplementedError(); |
+ |
+/// Processes the build unit whose source files are in [sources]. |
+/// |
+/// Intended for modular compilation. |
+/// |
+/// [sources] should be the complete set of source files for a build unit |
+/// (including both library and part files). All of the library files are |
+/// compiled to Dart Kernel objects. |
Brian Wilkerson
2016/10/17 15:08:14
nit: Does Kernel have a name for its representatio
Paul Berry
2016/10/17 17:04:27
Kernel calls them "Library". Changed to "Dart Ker
|
+/// |
+/// The compilation process is hermetic, meaning that the only files which will |
+/// be read are those listed in [sources], [Options.inputSummaries], and |
+/// [Options.sdkSummary]. If a source file attempts to refer to a file which is |
+/// not obtainable from these paths, that will result in an error, even if the |
+/// file exists on the filesystem. |
+/// |
+/// Any `part` declarations found in [sources] must refer to part files which |
+/// are also listed in [sources], otherwise an error results. (It is not |
+/// permitted to refer to a part file declared in another build unit). |
+/// |
+/// The return value is a [kernel.Program] object with no main method set. |
+/// |
+/// TODO(paulberry): does additional information need to be output to allow the |
+/// caller to match up referenced elements to the summary files they were |
+/// obtained from? |
+Future<kernel.Program> compileBuildUnit(Options options, List<Uri> sources) => |
Siggi Cherem (dart-lang)
2016/10/17 16:27:29
if we rename "compileProgram", I'd rename this too
Siggi Cherem (dart-lang)
2016/10/17 16:27:29
nit: change the return type, since a build-unit is
Paul Berry
2016/10/17 17:04:27
Went with "kernelForBuildUnit" here, and "resolved
Paul Berry
2016/10/17 17:04:27
kernel.Program also contains a `uriToLineStarts` m
|
+ throw new UnimplementedError(); |