Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: lib/compiler/implementation/scanner/scanner_task.dart

Issue 10831262: Revert "Revert "Allow patch files to add top-level declarations to the patched library."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed bugs Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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, [CompilationUnitElement patch]) { 133 ScriptTag tag, [CompilationUnitElement override]) {
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(), patch); 145 Element enclosing = library;
146 if (override !== null) {
147 enclosing = new CompilationUnitOverrideElement(override, library);
148 }
149 e = new PrefixElement(prefix, enclosing, tag.getBeginToken());
146 library.define(e, compiler); 150 library.define(e, compiler);
147 } 151 }
148 if (e.kind !== ElementKind.PREFIX) { 152 if (e.kind !== ElementKind.PREFIX) {
149 compiler.withCurrentElement(e, () { 153 compiler.withCurrentElement(e, () {
150 compiler.reportWarning(new Identifier(e.position()), 154 compiler.reportWarning(new Identifier(e.position()),
151 'duplicated definition'); 155 'duplicated definition');
152 }); 156 });
153 compiler.reportError(tag.prefix, 'duplicate defintion'); 157 compiler.reportError(tag.prefix, 'duplicate defintion');
154 } 158 }
155 PrefixElement prefixElement = e; 159 PrefixElement prefixElement = e;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 static final int RESOURCE = 4; 208 static final int RESOURCE = 4;
205 209
206 /** Next state. */ 210 /** Next state. */
207 static final List<int> NEXT = 211 static final List<int> NEXT =
208 const <int>[NO_TAG_SEEN, 212 const <int>[NO_TAG_SEEN,
209 IMPORT, // Only one library tag is allowed. 213 IMPORT, // Only one library tag is allowed.
210 IMPORT, 214 IMPORT,
211 SOURCE, 215 SOURCE,
212 RESOURCE]; 216 RESOURCE];
213 } 217 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/scanner/listener.dart ('k') | lib/compiler/implementation/unparse_validator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698