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 target `runtime`, so you only need
to run this command: |
17 | 17 |
18 ```bash | 18 ```bash |
19 ./tools/build.py --mode release --arch ia32 runtime | 19 ./tools/build.py --mode release --arch x64 runtime |
20 ``` | 20 ``` |
21 | 21 |
22 Make sure to define these environment variables, for example, by adding them to
`~/.bashrc`: | 22 Make sure to define these environment variables, for example, by adding them to
`~/.bashrc`: |
23 | 23 |
24 ```bash | 24 ```bash |
25 # Linux | 25 # Linux |
26 DART_SDK=<Location of Dart SDK source check out> | 26 DART_SDK=<Location of Dart SDK source check out> |
27 export DART_AOT_VM=${DART_SDK}/out/ReleaseIA32/dart | 27 export DART_AOT_VM=${DART_SDK}/out/ReleaseIA32/dart |
28 export DART_AOT_SDK=${DART_SDK}/out/ReleaseIA32/patched_sdk | 28 export DART_AOT_SDK=${DART_SDK}/out/ReleaseIA32/patched_sdk |
29 ``` | 29 ``` |
30 | 30 |
31 ```bash | 31 ```bash |
32 # Mac OS X | 32 # Mac OS X |
33 DART_SDK=<Location of Dart SDK source check out> | 33 DART_SDK=<Location of Dart SDK source check out> |
34 export DART_AOT_VM=${DART_SDK}/xcodebuild/ReleaseIA32/dart | 34 export DART_AOT_VM=${DART_SDK}/xcodebuild/ReleaseIA32/dart |
35 export DART_AOT_SDK=${DART_SDK}/xcodebuild/ReleaseIA32/patched_sdk | 35 export DART_AOT_SDK=${DART_SDK}/xcodebuild/ReleaseIA32/patched_sdk |
36 ``` | 36 ``` |
37 | 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). | 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 | 39 |
40 ## Create an Outline File | 40 ## Create an Outline File |
41 | 41 |
42 1. Run `dart pkg/fasta/bin/outline.dart pkg/compiler/lib/src/dart2js.dart` | 42 1. Run `dart pkg/front_end/lib/src/fasta/bin/outline.dart pkg/compiler/lib/src/d
art2js.dart` |
43 | 43 |
44 2. Optionally, run `dart pkg/kernel/bin/dartk.dart outline.dill` to view the gen
erated outline. | 44 2. Optionally, run `dart pkg/kernel/bin/dartk.dart pkg/compiler/lib/src/dart2js.
dart.dill` to view the generated outline. |
45 | 45 |
46 This will generate a file named `outline.dill` which contains a serialized reprs
entation of the input program excluding method bodies. This is similar to an ana
lyzer summary. | 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. |
47 | 47 |
48 | 48 |
49 ## Create a Platform Dill File | 49 ## Create a Platform Dill File |
50 | 50 |
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. | 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. |
52 | 52 |
53 ```bash | 53 ```bash |
54 dart pkg/fasta/bin/compile_platform.dart platform.dill | 54 dart pkg/front_end/lib/src/fasta/bin/compile_platform.dart platform.dill |
55 ``` | 55 ``` |
56 | 56 |
57 Make sure to define `$DART_AOT_SDK` as described [above](#Building-The-Dart-SDK)
. | 57 Make sure to define `$DART_AOT_SDK` as described [above](#Building-The-Dart-SDK)
. |
58 | 58 |
59 ## Compiling a Program | 59 ## Compiling a Program |
60 | 60 |
61 ```bash | 61 ```bash |
62 dart pkg/fasta/bin/compile.dart test/hello.dart | 62 dart pkg/front_end/lib/src/fasta/bin/compile.dart pkg/front_end/test/fasta/hello
.dart |
63 ``` | 63 ``` |
64 | 64 |
65 This will generate `program.dill` which can be run this way: | 65 This will generate `pkg/front_end/test/fasta/hello.dart.dill` which can be run t
his way: |
66 | 66 |
67 ```bash | 67 ```bash |
68 $DART_AOT_VM program.dill | 68 $DART_AOT_VM pkg/front_end/test/fasta/hello.dart.dill |
69 ``` | 69 ``` |
70 | 70 |
71 Where `$DART_AOT_VM` is defined as described [above](#Building-The-Dart-SDK). | 71 Where `$DART_AOT_VM` is defined as described [above](#Building-The-Dart-SDK). |
72 | 72 |
73 ### Using dartk and the Analyzer AST | 73 ### Using dartk and the Analyzer AST |
74 | 74 |
75 ```bash | 75 ```bash |
76 dart pkg/fasta/bin/kompile.dart test/hello.dart | 76 dart pkg/front_end/lib/src/fasta/bin/kompile.dart pkg/front_end/test/fasta/hello
.dart |
77 ``` | 77 ``` |
78 | 78 |
79 This will generate `program.dill` which can be run this way: | 79 This will generate `pkg/front_end/test/fasta/hello.dart.dill` which can be run t
his way: |
80 | 80 |
81 ```bash | 81 ```bash |
82 $DART_AOT_VM program.dill | 82 $DART_AOT_VM pkg/front_end/test/fasta/hello.dart.dill |
83 ``` | 83 ``` |
84 | 84 |
85 Where `$DART_AOT_VM` is defined as described [above](#Building-The-Dart-SDK). | 85 Where `$DART_AOT_VM` is defined as described [above](#Building-The-Dart-SDK). |
86 | 86 |
87 ## Running Tests | 87 ## Running Tests |
88 | 88 |
89 Run: | 89 Run: |
90 | 90 |
91 ```bash | 91 ```bash |
92 dart -c pkg/testing/bin/testing.dart --config=pkg/fasta/testing.json | 92 dart -c pkg/testing/bin/testing.dart --config=pkg/front_end/test/fasta/testing.j
son |
93 ``` | 93 ``` |
94 | 94 |
95 ## Running dart2js | 95 ## Running dart2js |
96 | 96 |
97 ```bash | 97 ```bash |
98 dart pkg/fasta/bin/compile.dart pkg/compiler/lib/src/dart2js.dart | 98 dart pkg/front_end/lib/src/fasta/bin/compile.dart pkg/compiler/lib/src/dart2js.d
art |
99 $DART_AOT_VM pkg/compiler/lib/src/dart2js.dart.dill pkg/fasta/test/test/hello.da
rt | 99 $DART_AOT_VM pkg/compiler/lib/src/dart2js.dart.dill pkg/front_end/test/fasta/hel
lo.dart |
100 ``` | 100 ``` |
| 101 |
| 102 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: |
| 103 |
| 104 ``` |
| 105 ./third_party/d8/<OS>/d8 out.js |
| 106 ``` |
| 107 |
| 108 Where `<OS>` is one of `linux`, `macos`, or `windows`. |
OLD | NEW |