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

Side by Side Diff: frog/leg/elements/elements.dart

Issue 9662035: When importing a library without a prefix, add the elements from the element map instead of the lis… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | frog/leg/scanner/scanner_task.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #library('elements'); 5 #library('elements');
6 6
7 #import('../tree/tree.dart'); 7 #import('../tree/tree.dart');
8 #import('../scanner/scannerlib.dart'); 8 #import('../scanner/scannerlib.dart');
9 #import('../leg.dart'); // TODO(karlklose): we only need type. 9 #import('../leg.dart'); // TODO(karlklose): we only need type.
10 #import('../util/util.dart'); 10 #import('../util/util.dart');
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 define(element, listener); 253 define(element, listener);
254 } 254 }
255 255
256 void define(Element element, DiagnosticListener listener) { 256 void define(Element element, DiagnosticListener listener) {
257 if (element.kind == ElementKind.GETTER 257 if (element.kind == ElementKind.GETTER
258 || element.kind == ElementKind.SETTER) { 258 || element.kind == ElementKind.SETTER) {
259 addGetterOrSetter(element, elements[element.name], listener); 259 addGetterOrSetter(element, elements[element.name], listener);
260 } else { 260 } else {
261 Element existing = elements.putIfAbsent(element.name, () => element); 261 Element existing = elements.putIfAbsent(element.name, () => element);
262 if (existing !== element) { 262 if (existing !== element) {
263 print(existing);
ahe 2012/03/10 21:26:36 debug code?
ngeoffray 2012/03/10 21:30:50 Done.
264 print(element);
ahe 2012/03/10 21:26:36 ditto
ngeoffray 2012/03/10 21:30:50 Done.
263 listener.cancel('duplicate definition', token: element.position()); 265 listener.cancel('duplicate definition', token: element.position());
264 listener.cancel('existing definition', token: existing.position()); 266 listener.cancel('existing definition', token: existing.position());
265 } 267 }
266 } 268 }
267 } 269 }
268 270
269 Element find(SourceString name) { 271 Element find(SourceString name) {
270 return elements[name]; 272 return elements[name];
271 } 273 }
272 274
273 Element lookupLocalMember(SourceString name) { 275 Element lookupLocalMember(SourceString name) {
274 Element element = find(name); 276 Element element = find(name);
275 if (element === null) return null; 277 if (element === null) return null;
276 return (this === element.getLibrary()) ? element : null; 278 return (this === element.getLibrary()) ? element : null;
277 } 279 }
280
281 void forEachExport(f(Element element)) {
282 elements.forEach((SourceString _, Element e) {
283 if (this === e.getLibrary()
284 && e.kind !== ElementKind.PREFIX
ahe 2012/03/10 21:26:36 See the code above in lookupLocalMember. Shouldn't
ngeoffray 2012/03/10 21:30:50 Are you referring to the one line 278? I don't thi
ahe 2012/04/13 13:48:10 I was referring to the method above. However, that
285 && e.kind !== ElementKind.FOREIGN) {
286 f(e);
287 }
288 });
289 }
278 } 290 }
279 291
280 class PrefixElement extends Element { 292 class PrefixElement extends Element {
281 final LiteralString prefix; 293 final LiteralString prefix;
282 final LibraryElement library; 294 final LibraryElement library;
283 295
284 PrefixElement(LiteralString prefix, 296 PrefixElement(LiteralString prefix,
285 LibraryElement this.library, 297 LibraryElement this.library,
286 Element enclosing) 298 Element enclosing)
287 : this.prefix = prefix, 299 : this.prefix = prefix,
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 852
841 LabelElement addLabel(Identifier label, String labelName) { 853 LabelElement addLabel(Identifier label, String labelName) {
842 LabelElement result = new LabelElement(label, labelName, this, 854 LabelElement result = new LabelElement(label, labelName, this,
843 enclosingElement); 855 enclosingElement);
844 labels = labels.prepend(result); 856 labels = labels.prepend(result);
845 return result; 857 return result;
846 } 858 }
847 859
848 Node parseNode(DiagnosticListener l) => statement; 860 Node parseNode(DiagnosticListener l) => statement;
849 } 861 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/scanner/scanner_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698