OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 dart2js.script; | 5 library dart2js.script; |
6 | 6 |
7 import 'io/source_file.dart'; | 7 import 'io/source_file.dart'; |
8 | 8 |
9 class Script { | 9 class Script { |
10 final SourceFile file; | 10 final SourceFile file; |
11 | 11 |
12 /** | 12 /** |
13 * The readable URI from which this script was loaded. | 13 * The readable URI from which this script was loaded. |
14 * | 14 * |
15 * See [LibraryLoader] for terminology on URIs. | 15 * See [LibraryLoader] for terminology on URIs. |
16 */ | 16 */ |
17 final Uri readableUri; | 17 final Uri readableUri; |
18 | 18 |
19 | |
20 /** | 19 /** |
21 * The resource URI from which this script was loaded. | 20 * The resource URI from which this script was loaded. |
22 * | 21 * |
23 * See [LibraryLoader] for terminology on URIs. | 22 * See [LibraryLoader] for terminology on URIs. |
24 */ | 23 */ |
25 final Uri resourceUri; | 24 final Uri resourceUri; |
26 | 25 |
27 /// This script was synthesized. | 26 /// This script was synthesized. |
28 final bool isSynthesized; | 27 final bool isSynthesized; |
29 | 28 |
30 Script(this.readableUri, this.resourceUri, this.file) | 29 Script(this.readableUri, this.resourceUri, this.file) : isSynthesized = false; |
31 : isSynthesized = false; | |
32 | 30 |
33 Script.synthetic(Uri uri) | 31 Script.synthetic(Uri uri) |
34 : readableUri = uri, | 32 : readableUri = uri, |
35 resourceUri = uri, | 33 resourceUri = uri, |
36 file = new StringSourceFile.fromUri(uri, | 34 file = new StringSourceFile.fromUri( |
37 "// Synthetic source file generated for '$uri'."), | 35 uri, "// Synthetic source file generated for '$uri'."), |
38 isSynthesized = true; | 36 isSynthesized = true; |
39 | 37 |
40 String get text => (file == null) ? null : file.slowText(); | 38 String get text => (file == null) ? null : file.slowText(); |
41 String get name => (file == null) ? null : file.filename; | 39 String get name => (file == null) ? null : file.filename; |
42 | 40 |
43 /// Creates a new [Script] with the same URIs, but new content ([file]). | 41 /// Creates a new [Script] with the same URIs, but new content ([file]). |
44 Script copyWithFile(SourceFile file) { | 42 Script copyWithFile(SourceFile file) { |
45 return new Script(readableUri, resourceUri, file); | 43 return new Script(readableUri, resourceUri, file); |
46 } | 44 } |
47 } | 45 } |
OLD | NEW |