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

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

Issue 11092003: Implement part-of directive. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update co19 status for dart2dart 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
Index: dart/lib/compiler/implementation/elements/elements.dart
diff --git a/dart/lib/compiler/implementation/elements/elements.dart b/dart/lib/compiler/implementation/elements/elements.dart
index 3dfee4956fba2b2051c86d758a4487239b3ca02a..71a7d0007dc859acdfd21e5800441658cf7d6755 100644
--- a/dart/lib/compiler/implementation/elements/elements.dart
+++ b/dart/lib/compiler/implementation/elements/elements.dart
@@ -6,6 +6,8 @@
#import('dart:uri');
+// TODO(ahe): Rename prefix to 'api' when VM bug is fixed.
+#import('../../compiler.dart', prefix: 'api_e');
#import('../tree/tree.dart');
#import('../scanner/scannerlib.dart');
#import('../leg.dart'); // TODO(karlklose): we only need type.
@@ -493,6 +495,7 @@ class ScopeContainerElement extends ContainerElement {
class CompilationUnitElement extends ContainerElement {
final Script script;
+ PartOf partTag;
CompilationUnitElement(Script script, LibraryElement library)
: this.script = script,
@@ -512,6 +515,43 @@ class CompilationUnitElement extends ContainerElement {
getLibrary().addMember(element, listener);
}
}
+
+ void setPartOf(PartOf tag, DiagnosticListener listener) {
+ LibraryElement library = enclosingElement;
+ if (library.entryCompilationUnit == this) {
+ listener.reportMessage(
+ listener.spanFromNode(tag),
+ MessageKind.ILLEGAL_DIRECTIVE.error(),
+ api_e.Diagnostic.WARNING);
+ return;
+ }
+ if (!localMembers.isEmpty()) {
+ listener.reportMessage(
+ listener.spanFromNode(tag),
+ MessageKind.BEFORE_TOP_LEVEL.error(),
+ api_e.Diagnostic.ERROR);
+ return;
+ }
+ if (partTag != null) {
+ listener.reportMessage(
+ listener.spanFromNode(tag),
+ MessageKind.DUPLICATED_PART_OF.error(),
+ api_e.Diagnostic.WARNING);
+ return;
+ }
+ partTag = tag;
+ LibraryName libraryTag = getLibrary().libraryTag;
+ if (libraryTag != null) {
Johnni Winther 2012/10/09 07:43:36 Isn't it also an error if the library does not hav
ahe 2012/10/09 07:48:09 A script may have parts, but no library name: scr
+ String expectedName = tag.name.toString();
+ String actualName = libraryTag.name.toString();
+ if (expectedName != actualName) {
+ listener.reportMessage(
+ listener.spanFromNode(tag.name),
+ MessageKind.LIBRARY_NAME_MISMATCH.error([expectedName]),
+ api_e.Diagnostic.WARNING);
+ }
+ }
+ }
}
class LibraryElement extends ScopeContainerElement {

Powered by Google App Engine
This is Rietveld 408576698