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

Unified Diff: lib/compiler/implementation/elements/elements.dart

Issue 10990060: Added support for exports and re-exports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase (again) Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/leg.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/elements/elements.dart
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart
index 71a7d0007dc859acdfd21e5800441658cf7d6755..60ac9bdf2753484cd40025f86cb1afcd6181a533 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 ERROR =
+ const ElementKind('error', ElementCategory.NONE);
+
toString() => id;
}
@@ -358,7 +361,8 @@ class ErroneousElement extends Element {
ErroneousElement(this.messageKind, this.messageArguments,
this.targetName, Element enclosing)
- : super(const SourceString('erroneous element'), null, enclosing);
ahe 2012/10/09 13:07:50 Good catch!
+ : super(const SourceString('erroneous element'),
+ ElementKind.ERROR, enclosing);
isErroneous() => true;
@@ -367,7 +371,6 @@ class ErroneousElement extends Element {
}
SourceString get name => unsupported();
- ElementKind get kind => unsupported();
Link<MetadataAnnotation> get metadata => unsupported();
getLibrary() => enclosingElement.getLibrary();
@@ -617,8 +620,9 @@ class LibraryElement extends ScopeContainerElement {
* detection of ambiguous uses of imported names.
*/
void addImport(Element element, DiagnosticListener listener) {
- Element existing = importScope.putIfAbsent(element.name, () => element);
- if (existing !== element && existing !== null) {
+ Element existing = importScope[element.name];
+ importScope.putIfAbsent(element.name, () => element);
ahe 2012/10/09 13:07:50 This should be: Element existing = importScope.pu
Johnni Winther 2012/10/09 13:50:07 Changed to not use [putIfAbsent].
+ if (existing !== null) {
if (!existing.isErroneous()) {
// TODO(johnniwinther): Provide access to both the new and existing
// elements.
@@ -629,6 +633,33 @@ class LibraryElement extends ScopeContainerElement {
}
}
+ bool get exportsHandled => _exports !== null;
ahe 2012/10/09 13:07:50 What is the purpose of this method?
Johnni Winther 2012/10/09 13:50:07 To test whether the export scope has been computed
+
+ /**
+ * Link for elements exported either through export declarations or through
+ * declaration.
+ *
+ * [ImportExportHandler] sets this map when the library is loaded.
+ */
+ Link<Element> _exports;
ahe 2012/10/09 13:07:50 Why is this private, and why is it not with all th
Johnni Winther 2012/10/09 13:50:07 It is private so that setExports can ensure that i
ahe 2012/10/09 14:41:33 How does privacy ensure that it can only be set on
Johnni Winther 2012/10/10 09:20:59 It doesn't. Renamed to [slotForExports] and commen
+
+ Link<Element> get exports {
+ assert(invariant(this, exportsHandled,
+ message: 'Exports not handled on $this'));
+ return _exports;
+ }
+
+ void setExports(Iterable<Element> iterable) {
ahe 2012/10/09 13:07:50 Why is this not a setter?
Johnni Winther 2012/10/09 13:50:07 Because it is not symmetric to the getter. It has
Bob Nystrom 2012/10/09 16:20:37 I agree with Johnni, I wouldn't make this a setter
+ assert(invariant(this, !exportsHandled,
+ message: 'Exports already set to $_exports on $this'));
+ assert(invariant(this, iterable !== null));
+ var builder = new LinkBuilder<Element>();
+ for (Element export in iterable) {
+ builder.addLast(export);
+ }
+ _exports = builder.toLink();
+ }
+
LibraryElement getLibrary() => isPatch ? origin : this;
/**
@@ -656,14 +687,7 @@ class LibraryElement extends ScopeContainerElement {
}
void forEachExport(f(Element element)) {
- localScope.forEach((_, Element e) {
- if (this === e.getLibrary()
- && e.kind !== ElementKind.PREFIX
- && e.kind !== ElementKind.FOREIGN
- && !e.name.isPrivate()) {
- f(e);
- }
- });
+ exports.forEach((Element e) => f(e));
}
void forEachLocalMember(f(Element element)) {
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/leg.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698