OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class ScannerTask extends CompilerTask { | 5 class ScannerTask extends CompilerTask { |
6 ScannerTask(Compiler compiler) : super(compiler); | 6 ScannerTask(Compiler compiler) : super(compiler); |
7 String get name() => 'Scanner'; | 7 String get name() => 'Scanner'; |
8 | 8 |
9 void scan(CompilationUnitElement compilationUnit) { | 9 void scan(CompilationUnitElement compilationUnit) { |
10 measure(() { | 10 measure(() { |
(...skipping 17 matching lines...) Expand all Loading... |
28 */ | 28 */ |
29 int checkTag(int value, ScriptTag tag) { | 29 int checkTag(int value, ScriptTag tag) { |
30 if (tagState > value) { | 30 if (tagState > value) { |
31 compiler.reportError(tag, 'out of order'); | 31 compiler.reportError(tag, 'out of order'); |
32 return tagState; | 32 return tagState; |
33 } | 33 } |
34 return TagState.NEXT[value]; | 34 return TagState.NEXT[value]; |
35 } | 35 } |
36 | 36 |
37 LinkBuilder<ScriptTag> imports = new LinkBuilder<ScriptTag>(); | 37 LinkBuilder<ScriptTag> imports = new LinkBuilder<ScriptTag>(); |
38 Uri cwd = new Uri(scheme: 'file', path: compiler.currentDirectory); | 38 Uri base = library.script.uri; |
39 Uri base = cwd.resolve(library.script.name.toString()); | |
40 for (ScriptTag tag in library.tags.reverse()) { | 39 for (ScriptTag tag in library.tags.reverse()) { |
41 StringNode argument = tag.argument; | 40 StringNode argument = tag.argument; |
42 // TODO(lrn): Support interpolations here. We need access to the | 41 // TODO(lrn): Support interpolations here. We need access to the |
43 // special constants that can be inserted into script tag strings. | 42 // special constants that can be inserted into script tag strings. |
44 Uri resolved = base.resolve(argument.dartString.slowToString()); | 43 Uri resolved = base.resolve(argument.dartString.slowToString()); |
45 if (tag.isImport()) { | 44 if (tag.isImport()) { |
46 tagState = checkTag(TagState.IMPORT, tag); | 45 tagState = checkTag(TagState.IMPORT, tag); |
47 // It is not safe to import other libraries at this point as | 46 // It is not safe to import other libraries at this point as |
48 // another library could then observe the current library | 47 // another library could then observe the current library |
49 // before it fully declares all the members that are sourced | 48 // before it fully declares all the members that are sourced |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 static final int RESOURCE = 4; | 194 static final int RESOURCE = 4; |
196 | 195 |
197 /** Next state. */ | 196 /** Next state. */ |
198 static final List<int> NEXT = | 197 static final List<int> NEXT = |
199 const <int>[NO_TAG_SEEN, | 198 const <int>[NO_TAG_SEEN, |
200 IMPORT, // Only one library tag is allowed. | 199 IMPORT, // Only one library tag is allowed. |
201 IMPORT, | 200 IMPORT, |
202 SOURCE, | 201 SOURCE, |
203 RESOURCE]; | 202 RESOURCE]; |
204 } | 203 } |
OLD | NEW |