| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 3 for details. All rights reserved. Use of this source code is governed by a | 3 for details. All rights reserved. Use of this source code is governed by a |
| 4 BSD-style license that can be found in the LICENSE file. | 4 BSD-style license that can be found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 # Fasta -- Fully-resolved AST, Accelerated. | 6 # Fasta -- Fully-resolved AST, Accelerated. |
| 7 | 7 |
| 8 Fasta is a compiler framework for compiling Dart sources to Kernel IR. When Fast
a works well, you won't even know you're using it, as it will be transparently i
ntegrated in tools like *dart*, *dartanalyzer*, *dart2js*, etc. | 8 Fasta is a compiler framework for compiling Dart sources to Kernel IR. When Fast
a works well, you won't even know you're using it, as it will be transparently i
ntegrated in tools like *dart*, *dartanalyzer*, *dart2js*, etc. |
| 9 | 9 |
| 10 Hopefully, you'll notice that Fasta-based tools are fast, with good error messag
es. If not, please let us [know](https://github.com/dart-lang/sdk/issues/new). | 10 Hopefully, you'll notice that Fasta-based tools are fast, with good error messag
es. If not, please let us [know](https://github.com/dart-lang/sdk/issues/new). |
| 11 | 11 |
| 12 Fasta sounds like faster, and that's a promise we intend to keep. | 12 Fasta sounds like faster, and that's a promise we intend to keep. |
| 13 | 13 |
| 14 ## Getting Started | 14 ## Getting Started |
| 15 | 15 |
| 16 1. [Build](https://github.com/dart-lang/sdk/wiki/Building#building) the VM and p
atched SDK. Note: you only need to build the target `runtime`, so you only need
to run this command: | 16 1. [Build](https://github.com/dart-lang/sdk/wiki/Building#building) the VM and p
atched SDK. Note: you only need to build the targets `runtime_kernel`, and `dart
_precompiled_runtime`, so you only need to run this command: |
| 17 | 17 |
| 18 ```bash | 18 ```bash |
| 19 ./tools/build.py --mode release --arch x64 runtime | 19 ./tools/build.py --mode release --arch x64 runtime_kernel dart_precompiled_runti
me |
| 20 ``` | 20 ``` |
| 21 | 21 |
| 22 Make sure to define these environment variables, for example, by adding them to
`~/.bashrc`: | |
| 23 | |
| 24 ```bash | |
| 25 # Linux | |
| 26 DART_SDK=<Location of Dart SDK source check out> | |
| 27 export DART_AOT_VM=${DART_SDK}/out/ReleaseIA32/dart | |
| 28 export DART_AOT_SDK=${DART_SDK}/out/ReleaseIA32/patched_sdk | |
| 29 ``` | |
| 30 | |
| 31 ```bash | |
| 32 # Mac OS X | |
| 33 DART_SDK=<Location of Dart SDK source check out> | |
| 34 export DART_AOT_VM=${DART_SDK}/xcodebuild/ReleaseIA32/dart | |
| 35 export DART_AOT_SDK=${DART_SDK}/xcodebuild/ReleaseIA32/patched_sdk | |
| 36 ``` | |
| 37 | |
| 38 If you want to help us translate these instructions to another OS, please let us
[know](https://github.com/dart-lang/sdk/issues/new). | |
| 39 | |
| 40 ## Create an Outline File | 22 ## Create an Outline File |
| 41 | 23 |
| 42 1. Run `dart pkg/front_end/lib/src/fasta/bin/outline.dart pkg/compiler/lib/src/d
art2js.dart` | 24 1. Run `./pkg/front_end/tool/fasta outline pkg/compiler/lib/src/dart2js.dart` |
| 43 | 25 |
| 44 2. Optionally, run `dart pkg/kernel/bin/dartk.dart pkg/compiler/lib/src/dart2js.
dart.dill` to view the generated outline. | 26 2. Optionally, run `./pkg/front_end/tool/fasta dump-ir pkg/kernel/bin/dump.dart
pkg/compiler/lib/src/dart2js.dart.dill` to view the generated outline. |
| 45 | 27 |
| 46 This will generate a file named `pkg/compiler/lib/src/dart2js.dart.dill` which c
ontains a serialized reprsentation of the input program excluding method bodies.
This is similar to an analyzer summary. | 28 This will generate a file named `pkg/compiler/lib/src/dart2js.dart.dill` which c
ontains a serialized representation of the input program excluding method bodies
. This is similar to an analyzer summary. |
| 47 | 29 |
| 48 | 30 |
| 49 ## Create a Platform Dill File | 31 ## Create a Platform Dill File |
| 50 | 32 |
| 51 A `platform.dill` is a dill file that contains the Dart SDK platform libraries.
For now, this is generated with dartk until fasta reaches a higher rate of test
passes. | 33 A `platform.dill` is a dill file that contains the Dart SDK platform libraries. |
| 52 | 34 |
| 53 ```bash | 35 ```bash |
| 54 dart pkg/front_end/lib/src/fasta/bin/compile_platform.dart platform.dill | 36 ./pkg/front_end/tool/fasta compile-platform platform.dill |
| 55 ``` | 37 ``` |
| 56 | 38 |
| 57 Make sure to define `$DART_AOT_SDK` as described [above](#Building-The-Dart-SDK)
. | |
| 58 | |
| 59 ## Compiling a Program | 39 ## Compiling a Program |
| 60 | 40 |
| 61 ```bash | 41 ```bash |
| 62 dart pkg/front_end/lib/src/fasta/bin/compile.dart pkg/front_end/test/fasta/hello
.dart | 42 ./pkg/front_end/tool/fasta compile pkg/front_end/test/fasta/hello.dart |
| 63 ``` | 43 ``` |
| 64 | 44 |
| 65 This will generate `pkg/front_end/test/fasta/hello.dart.dill` which can be run t
his way: | 45 This will generate `pkg/front_end/test/fasta/hello.dart.dill` which can be run t
his way: |
| 66 | 46 |
| 67 ```bash | 47 ```bash |
| 68 $DART_AOT_VM pkg/front_end/test/fasta/hello.dart.dill | 48 ./sdk/bin/dart pkg/front_end/test/fasta/hello.dart.dill |
| 69 ``` | 49 ``` |
| 70 | 50 |
| 71 Where `$DART_AOT_VM` is defined as described [above](#Building-The-Dart-SDK). | |
| 72 | |
| 73 ### Using dartk and the Analyzer AST | 51 ### Using dartk and the Analyzer AST |
| 74 | 52 |
| 75 ```bash | 53 ```bash |
| 76 dart pkg/front_end/lib/src/fasta/bin/kompile.dart pkg/front_end/test/fasta/hello
.dart | 54 ./pkg/front_end/tool/fasta analyzer-compile pkg/front_end/test/fasta/hello.dart |
| 77 ``` | 55 ``` |
| 78 | 56 |
| 79 This will generate `pkg/front_end/test/fasta/hello.dart.dill` which can be run t
his way: | 57 This will generate `pkg/front_end/test/fasta/hello.dart.dill` which can be run t
his way: |
| 80 | 58 |
| 81 ```bash | 59 ```bash |
| 82 $DART_AOT_VM pkg/front_end/test/fasta/hello.dart.dill | 60 ./sdk/bin/dart pkg/front_end/test/fasta/hello.dart.dill |
| 83 ``` | 61 ``` |
| 84 | 62 |
| 85 Where `$DART_AOT_VM` is defined as described [above](#Building-The-Dart-SDK). | |
| 86 | |
| 87 ## Running Tests | 63 ## Running Tests |
| 88 | 64 |
| 89 See [How to test Fasta](TESTING.md) | 65 See [How to test Fasta](TESTING.md) |
| 90 | 66 |
| 91 ## Running dart2js | 67 ## Running dart2js |
| 92 | 68 |
| 93 ```bash | 69 ```bash |
| 94 dart pkg/front_end/lib/src/fasta/bin/compile.dart pkg/compiler/lib/src/dart2js.d
art | 70 ./pkg/front_end/tool/fasta compile pkg/compiler/lib/src/dart2js.dart |
| 95 $DART_AOT_VM pkg/compiler/lib/src/dart2js.dart.dill pkg/front_end/test/fasta/hel
lo.dart | 71 ./sdk/bin/dart pkg/compiler/lib/src/dart2js.dart.dill pkg/front_end/test/fasta/h
ello.dart |
| 96 ``` | 72 ``` |
| 97 | 73 |
| 98 The output of dart2js will be `out.js`, and it can be run on any Javascript engi
ne, for example, d8 which is included with the Dart SDK sources: | 74 The output of dart2js will be `out.js`, and it can be run on any Javascript engi
ne, for example, d8 which is included with the Dart SDK sources: |
| 99 | 75 |
| 100 ``` | 76 ``` |
| 101 ./third_party/d8/<OS>/d8 out.js | 77 ./third_party/d8/<OS>/d8 out.js |
| 102 ``` | 78 ``` |
| 103 | 79 |
| 104 Where `<OS>` is one of `linux`, `macos`, or `windows`. | 80 Where `<OS>` is one of `linux`, `macos`, or `windows`. |
| OLD | NEW |