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

Unified Diff: dart/frog/leg/scanner/scanner_task.dart

Issue 9663047: Repeated prefixes and parser fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased and status file 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/frog/leg/scanner/partial_parser.dart ('k') | dart/tests/language/language-leg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/scanner/scanner_task.dart
diff --git a/dart/frog/leg/scanner/scanner_task.dart b/dart/frog/leg/scanner/scanner_task.dart
index b052d85ea3ee2044de641789f96d473ed9bc92d7..407084d8d71b806bd781a0f479408f619ee9e4ee 100644
--- a/dart/frog/leg/scanner/scanner_task.dart
+++ b/dart/frog/leg/scanner/scanner_task.dart
@@ -58,7 +58,7 @@ class ScannerTask extends CompilerTask {
if (resolved.toString() == "dart:core") {
implicitlyImportCoreLibrary = false;
}
- importLibrary(library, loadLibrary(resolved, tag), tag.prefix);
+ importLibrary(library, loadLibrary(resolved, tag), tag);
}
if (implicitlyImportCoreLibrary) {
importLibrary(library, compiler.coreLibrary, null);
@@ -101,9 +101,34 @@ class ScannerTask extends CompilerTask {
}
void importLibrary(LibraryElement library, LibraryElement imported,
- LiteralString prefix) {
- if (prefix !== null) {
- library.define(new PrefixElement(prefix, imported, library), compiler);
+ ScriptTag tag) {
+ if (tag !== null && tag.prefix !== null) {
+ SourceString prefix = tag.prefix.dartString.source;
+ Element e = library.find(prefix);
+ if (e === null) {
+ e = new PrefixElement(prefix, library);
+ library.define(e, compiler);
+ }
+ if (e.kind !== ElementKind.PREFIX) {
+ compiler.withCurrentElement(e, () {
+ compiler.reportWarning(new Identifier(e.position()),
+ 'duplicated definition');
+ });
+ compiler.reportError(tag.prefix, 'duplicate defintion');
+ }
+ imported.forEachExport((Element element) {
+ Element existing = e.imported.putIfAbsent(element.name, () => element);
+ if (existing !== element) {
+ compiler.withCurrentElement(existing, () {
+ compiler.reportWarning(new Identifier(existing.position()),
+ 'duplicated import');
+ });
+ compiler.withCurrentElement(element, () {
+ compiler.reportError(new Identifier(element.position()),
+ 'duplicated import');
+ });
+ }
+ });
} else {
imported.forEachExport((Element element) {
compiler.withCurrentElement(element, () {
« no previous file with comments | « dart/frog/leg/scanner/partial_parser.dart ('k') | dart/tests/language/language-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698