Chromium Code Reviews| Index: lib/compiler/implementation/elements/elements.dart |
| diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart |
| index 3775bc740d446d42d288da93064db6a366e48a8f..9a077b51df57da52da3e61ea10077e097d4d7b13 100644 |
| --- a/lib/compiler/implementation/elements/elements.dart |
| +++ b/lib/compiler/implementation/elements/elements.dart |
| @@ -104,6 +104,9 @@ class ElementKind { |
| static const ElementKind VOID = |
| const ElementKind('void', ElementCategory.NONE); |
| + static const ElementKind ERRONEOUS = |
|
Lasse Reichstein Nielsen
2012/09/28 07:45:36
It should be called ERROR - a noun - and not ERRON
Johnni Winther
2012/10/09 09:47:10
Done.
|
| + const ElementKind('erroneous', ElementCategory.NONE); |
| + |
| toString() => id; |
| } |
| @@ -371,7 +374,8 @@ class ErroneousElement extends Element { |
| ErroneousElement(this.messageKind, this.messageArguments, |
| this.targetName, Element enclosing) |
| - : super(const SourceString('erroneous element'), null, enclosing); |
| + : super(const SourceString('erroneous element'), |
| + ElementKind.ERRONEOUS, enclosing); |
| isErroneous() => true; |
| @@ -380,7 +384,6 @@ class ErroneousElement extends Element { |
| } |
| SourceString get name => unsupported(); |
| - ElementKind get kind => unsupported(); |
| Link<MetadataAnnotation> get metadata => unsupported(); |
| getLibrary() => enclosingElement.getLibrary(); |
| @@ -550,6 +553,25 @@ class LibraryElement extends ScopeContainerElement { |
| */ |
| final Map<SourceString, Element> importScope; |
| + /** |
| + * Map for elements exported either through export declarations or through |
| + * declaration. |
| + * |
| + * [ImportExportHandler] sets this map when the library is loaded. |
| + */ |
| + Map<SourceString, Element> _exportScope; |
| + |
| + Map<SourceString, Element> get exportScope { |
|
Lasse Reichstein Nielsen
2012/09/28 07:45:36
Please don't export the map. Someone will just do
Bob Nystrom
2012/09/28 16:41:27
Drive-by comment: I see stuff like this frequently
Johnni Winther
2012/10/09 09:47:10
Changed to used a linked list.
|
| + assert(invariant(this, _exportScope !== null)); |
| + return _exportScope; |
| + } |
| + |
| + void set exportScope(Map<SourceString, Element> map) { |
| + assert(invariant(this, _exportScope === null)); |
| + assert(invariant(this, map !== null)); |
| + _exportScope = map; |
| + } |
| + |
| LibraryElement(Script script, [Uri uri]) |
| : this.uri = ((uri === null) ? script.uri : uri), |
| importScope = new Map<SourceString, Element>(), |
| @@ -557,7 +579,6 @@ class LibraryElement extends ScopeContainerElement { |
| entryCompilationUnit = new CompilationUnitElement(script, this); |
| } |
| - |
| bool get isPatched => patch !== null; |
| void addCompilationUnit(CompilationUnitElement element) { |
| @@ -576,19 +597,19 @@ class LibraryElement extends ScopeContainerElement { |
| * detection of ambiguous uses of imported names. |
| */ |
| void addImport(Element element, DiagnosticListener listener) { |
| - Element existing = importScope.putIfAbsent(element.name, () => element); |
| + SourceString name = element.name; |
| + Element existing = importScope.putIfAbsent(name, () => element); |
| if (existing !== element && existing !== null) { |
|
Lasse Reichstein Nielsen
2012/09/28 07:45:36
Add a comment that you are not following the curre
Johnni Winther
2012/10/09 09:47:10
Implementation changed to follow spec.
|
| if (!existing.isErroneous()) { |
| // TODO(johnniwinther): Provide access to both the new and existing |
| // elements. |
| - importScope[element.name] = new ErroneousElement( |
| + importScope[name] = new ErroneousElement( |
| MessageKind.DUPLICATE_IMPORT, |
| - [element.name], element.name, this); |
| + [name], name, this); |
| } |
| } |
| } |
| - |
| /** |
| * Look up a top-level element in this library. The element could |
| * potentially have been imported from another library. Returns |
| @@ -620,6 +641,7 @@ class LibraryElement extends ScopeContainerElement { |
| f(e); |
| } |
| }); |
| + exportScope.forEach((_, Element e) => f(e)); |
| } |
| bool hasLibraryName() => libraryTag !== null; |