OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library fasta.target; | 5 library fasta.target; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'ticker.dart' show Ticker; | 9 import 'ticker.dart' show Ticker; |
10 | 10 |
11 /// A compilation target. | 11 /// A compilation target. |
12 /// | 12 /// |
13 /// A target reads source files with [read] and writes out the resulting | 13 /// A target reads source files with [read] and writes out the resulting |
14 /// program when [writeOutline] is called. | 14 /// program when [writeOutline] is called. |
15 abstract class Target { | 15 abstract class Target { |
16 final Ticker ticker; | 16 final Ticker ticker; |
17 | 17 |
18 Target(this.ticker); | 18 /// Denotes whether the output of this target will be used for dart2js, |
| 19 /// otherwise it is assumed it will be used for the VM. |
| 20 // TODO(sigmund): investigate better ways to configure this. This is used for |
| 21 // three purposes today: determine how to handle the `native` clauses (which |
| 22 // are different in the vm and dartjs patch-files), determine which libraries |
| 23 // to include when building the sdk, and which transformations to run when |
| 24 // linking a program. |
| 25 final bool forDart2js; |
| 26 |
| 27 bool get forVm => !forDart2js; |
| 28 |
| 29 Target(this.ticker, this.forDart2js); |
19 | 30 |
20 /// Instructs this target to include [uri] in its result. | 31 /// Instructs this target to include [uri] in its result. |
21 void read(Uri uri); | 32 void read(Uri uri); |
22 | 33 |
23 /// Write the resulting program in the file [uri]. | 34 /// Write the resulting program in the file [uri]. |
24 Future writeProgram(Uri uri); | 35 Future writeProgram(Uri uri); |
25 | 36 |
26 /// Write the resulting outline in the file [uri]. | 37 /// Write the resulting outline in the file [uri]. |
27 Future writeOutline(Uri uri); | 38 Future writeOutline(Uri uri); |
28 } | 39 } |
OLD | NEW |