2016-04-26 08:29:55 +00:00
|
|
|
Dart Kernel
|
2016-04-26 08:39:15 +00:00
|
|
|
===========
|
|
|
|
**Dart Kernel** is a small high-level language derived from Dart.
|
|
|
|
It is designed for use as an intermediate format for whole-program analysis
|
|
|
|
and transformations, and as a frontend for codegen and execution backends.
|
|
|
|
|
|
|
|
The kernel language has in-memory representations in Dart and C++, and
|
|
|
|
can be serialized as binary or text.
|
|
|
|
|
2016-08-26 08:16:54 +00:00
|
|
|
Both the kernel language and its implementations are unstable and are under development.
|
2016-04-26 08:39:15 +00:00
|
|
|
|
|
|
|
This package contains the Dart part of the implementation and contains:
|
|
|
|
- A transformable IR for the kernel language
|
|
|
|
- A frontend based on the analyzer
|
|
|
|
- Serialization of kernel code
|
|
|
|
|
2017-05-03 21:34:53 +00:00
|
|
|
_Note:_ The APIs in this package are in an early state; developers should be
|
|
|
|
careful about depending on this package.
|
|
|
|
|
2016-08-26 08:16:54 +00:00
|
|
|
Getting Kernel
|
|
|
|
------------
|
2016-04-26 08:39:15 +00:00
|
|
|
|
2016-08-26 08:16:54 +00:00
|
|
|
Checkout the repository and run pub get:
|
|
|
|
```bash
|
|
|
|
git clone https://github.com/dart-lang/kernel
|
|
|
|
cd kernel
|
|
|
|
pub get
|
|
|
|
```
|
2016-04-26 08:39:15 +00:00
|
|
|
|
|
|
|
Command-Line Tool
|
|
|
|
-----------------
|
|
|
|
|
2017-04-28 22:39:13 +00:00
|
|
|
Run `tool/dartk.dart` from the command-line to convert between .dart files
|
2016-04-26 08:39:15 +00:00
|
|
|
and the serialized binary and textual formats.
|
|
|
|
|
2016-07-19 15:52:33 +00:00
|
|
|
`dartk` expects the `.dill` extension for files in the binary format.
|
2016-04-26 08:39:15 +00:00
|
|
|
The textual format has no preferred extension right now.
|
|
|
|
|
|
|
|
Example commands:
|
|
|
|
```bash
|
|
|
|
dartk foo.dart # print text IR for foo.dart
|
2016-07-19 15:52:33 +00:00
|
|
|
dartk foo.dart -ofoo.dill # write binary IR for foo.dart to foo.dill
|
|
|
|
dartk foo.dill # print text IR for binary file foo.dill
|
2016-04-26 08:39:15 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Pass the `--link` or `-l` flag to link all transitive dependencies into one file:
|
|
|
|
```bash
|
2016-07-19 15:52:33 +00:00
|
|
|
dartk myapp.dart -ppackages -l -omyapp.dill # Bundle everything.
|
|
|
|
dartk myapp.dill # Print it back out in a (very, very long) textual format.
|
2016-04-26 08:39:15 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
See [ast.dart](lib/ast.dart) for the in-memory IR, or [binary.md](binary.md) for
|
|
|
|
a description of the binary format. For now, the textual format is very ad-hoc
|
|
|
|
and cannot be parsed back in.
|
|
|
|
|
|
|
|
|
2016-08-26 08:16:54 +00:00
|
|
|
Testing
|
|
|
|
-------
|
|
|
|
|
|
|
|
If you plan to make changes to kernel, get a checkout of the Dartk SDK and run:
|
|
|
|
```bash
|
|
|
|
tool/regenerate_dill_files.dart --sdk <path to SDK checkout>
|
|
|
|
pub run test
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2016-10-20 11:12:41 +00:00
|
|
|
Linking
|
2016-04-26 08:39:15 +00:00
|
|
|
-------------------------
|
2016-10-20 11:12:41 +00:00
|
|
|
Linking from binary files is not yet implemented. In order to compile a whole
|
|
|
|
program, currently everything must be compiled from source at once.
|