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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 if (newLibrary) { | 123 if (newLibrary) { |
124 compiler.withCurrentElement(library, () { | 124 compiler.withCurrentElement(library, () { |
125 scan(library); | 125 scan(library); |
126 compiler.onLibraryLoaded(library, uri); | 126 compiler.onLibraryLoaded(library, uri); |
127 }); | 127 }); |
128 } | 128 } |
129 return library; | 129 return library; |
130 } | 130 } |
131 | 131 |
132 void importLibrary(LibraryElement library, LibraryElement imported, | 132 void importLibrary(LibraryElement library, LibraryElement imported, |
133 ScriptTag tag, [Script override]) { | 133 ScriptTag tag, [CompilationUnitElement patch]) { |
134 if (!imported.hasLibraryName()) { | 134 if (!imported.hasLibraryName()) { |
135 compiler.withCurrentElement(library, () { | 135 compiler.withCurrentElement(library, () { |
136 compiler.reportError(tag === null ? null : tag.argument, | 136 compiler.reportError(tag === null ? null : tag.argument, |
137 'no #library tag found in ${imported.script.uri}'); | 137 'no #library tag found in ${imported.script.uri}'); |
138 }); | 138 }); |
139 } | 139 } |
140 if (tag !== null && tag.prefix !== null) { | 140 if (tag !== null && tag.prefix !== null) { |
141 SourceString prefix = | 141 SourceString prefix = |
142 new SourceString(tag.prefix.dartString.slowToString()); | 142 new SourceString(tag.prefix.dartString.slowToString()); |
143 Element e = library.find(prefix); | 143 Element e = library.find(prefix); |
144 if (e === null) { | 144 if (e === null) { |
145 e = new PrefixElement(prefix, library, tag.getBeginToken()); | 145 e = new PrefixElement(prefix, library, tag.getBeginToken(), patch); |
146 e.scriptOverride = override; | |
147 library.define(e, compiler); | 146 library.define(e, compiler); |
148 } | 147 } |
149 if (e.kind !== ElementKind.PREFIX) { | 148 if (e.kind !== ElementKind.PREFIX) { |
150 compiler.withCurrentElement(e, () { | 149 compiler.withCurrentElement(e, () { |
151 compiler.reportWarning(new Identifier(e.position()), | 150 compiler.reportWarning(new Identifier(e.position()), |
152 'duplicated definition'); | 151 'duplicated definition'); |
153 }); | 152 }); |
154 compiler.reportError(tag.prefix, 'duplicate defintion'); | 153 compiler.reportError(tag.prefix, 'duplicate defintion'); |
155 } | 154 } |
156 PrefixElement prefixElement = e; | 155 PrefixElement prefixElement = e; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 static final int RESOURCE = 4; | 204 static final int RESOURCE = 4; |
206 | 205 |
207 /** Next state. */ | 206 /** Next state. */ |
208 static final List<int> NEXT = | 207 static final List<int> NEXT = |
209 const <int>[NO_TAG_SEEN, | 208 const <int>[NO_TAG_SEEN, |
210 IMPORT, // Only one library tag is allowed. | 209 IMPORT, // Only one library tag is allowed. |
211 IMPORT, | 210 IMPORT, |
212 SOURCE, | 211 SOURCE, |
213 RESOURCE]; | 212 RESOURCE]; |
214 } | 213 } |
OLD | NEW |