| OLD | NEW |
| 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 package com.google.dart.compiler; | 5 package com.google.dart.compiler; |
| 6 | 6 |
| 7 import com.google.common.collect.Lists; | 7 import com.google.common.collect.Lists; |
| 8 import com.google.common.collect.Maps; | 8 import com.google.common.collect.Maps; |
| 9 import com.google.common.collect.Sets; | 9 import com.google.common.collect.Sets; |
| 10 import com.google.common.collect.Sets.SetView; | 10 import com.google.common.collect.Sets.SetView; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 for (LibrarySource embedded : embeddedLibraries) { | 381 for (LibrarySource embedded : embeddedLibraries) { |
| 382 updateLibraries(embedded); | 382 updateLibraries(embedded); |
| 383 } | 383 } |
| 384 | 384 |
| 385 for (LibraryUnit lib : getLibrariesToProcess()) { | 385 for (LibraryUnit lib : getLibrariesToProcess()) { |
| 386 for (LibrarySource embedded : embeddedLibraries) { | 386 for (LibrarySource embedded : embeddedLibraries) { |
| 387 LibraryUnit imp = libraries.get(embedded.getUri()); | 387 LibraryUnit imp = libraries.get(embedded.getUri()); |
| 388 // Check that the current library is not the embedded library, and | 388 // Check that the current library is not the embedded library, and |
| 389 // that the current library does not already import the embedded | 389 // that the current library does not already import the embedded |
| 390 // library. | 390 // library. |
| 391 if (lib != imp && !lib.hasImport(imp)) { | 391 if (lib != imp && !lib.hasImport(null, imp)) { |
| 392 lib.addImport(imp, null); | 392 lib.addImport(imp, null); |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 } | 395 } |
| 396 } finally { | 396 } finally { |
| 397 Tracer.end(importEvent); | 397 Tracer.end(importEvent); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 /** | 401 /** |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 // Validate import prefixes. | 641 // Validate import prefixes. |
| 642 for (LibraryNode importNode : lib.getImportPaths()) { | 642 for (LibraryNode importNode : lib.getImportPaths()) { |
| 643 String prefix = importNode.getPrefix(); | 643 String prefix = importNode.getPrefix(); |
| 644 if (DartParser.PSEUDO_KEYWORDS_SET.contains(prefix)) { | 644 if (DartParser.PSEUDO_KEYWORDS_SET.contains(prefix)) { |
| 645 context.onError(new DartCompilationError(importNode.getSourceInfo(), | 645 context.onError(new DartCompilationError(importNode.getSourceInfo(), |
| 646 ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_IMPORT_PREFIX, prefix))
; | 646 ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_IMPORT_PREFIX, prefix))
; |
| 647 } | 647 } |
| 648 } | 648 } |
| 649 | 649 |
| 650 // check that each imported library has a library directive | 650 // check that each imported library has a library directive |
| 651 for (LibraryUnit importedLib : lib.getImports()) { | 651 for (LibraryUnit importedLib : lib.getImportedLibraries()) { |
| 652 | 652 |
| 653 if (SystemLibraryManager.isDartUri(importedLib.getSource().getUri()))
{ | 653 if (SystemLibraryManager.isDartUri(importedLib.getSource().getUri()))
{ |
| 654 // system libraries are always valid | 654 // system libraries are always valid |
| 655 continue; | 655 continue; |
| 656 } | 656 } |
| 657 | 657 |
| 658 // get the dart unit corresponding to this library | 658 // get the dart unit corresponding to this library |
| 659 DartUnit unit = importedLib.getSelfDartUnit(); | 659 DartUnit unit = importedLib.getSelfDartUnit(); |
| 660 if (unit.isDiet()) { | 660 if (unit.isDiet()) { |
| 661 // don't need to check a unit that hasn't changed | 661 // don't need to check a unit that hasn't changed |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 DartArtifactProvider provider, | 1132 DartArtifactProvider provider, |
| 1133 DartCompilerListener listener) throws IOExcept
ion { | 1133 DartCompilerListener listener) throws IOExcept
ion { |
| 1134 DartCompilerMainContext context = new DartCompilerMainContext(lib, provider,
listener, | 1134 DartCompilerMainContext context = new DartCompilerMainContext(lib, provider,
listener, |
| 1135 config); | 1135 config); |
| 1136 if (config.getCompilerOptions().shouldExposeCoreImpl()) { | 1136 if (config.getCompilerOptions().shouldExposeCoreImpl()) { |
| 1137 if (embeddedLibraries == null) { | 1137 if (embeddedLibraries == null) { |
| 1138 embeddedLibraries = Lists.newArrayList(); | 1138 embeddedLibraries = Lists.newArrayList(); |
| 1139 } | 1139 } |
| 1140 // use a place-holder LibrarySource instance, to be replaced when embedded | 1140 // use a place-holder LibrarySource instance, to be replaced when embedded |
| 1141 // in the compiler, where the dart uri can be resolved. | 1141 // in the compiler, where the dart uri can be resolved. |
| 1142 embeddedLibraries.add(new NamedPlaceHolderLibrarySource("dart:coreimpl")); | 1142 embeddedLibraries.add(new NamedPlaceHolderLibrarySource("dart:core")); |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 new Compiler(lib, embeddedLibraries, config, context).compile(); | 1145 new Compiler(lib, embeddedLibraries, config, context).compile(); |
| 1146 int errorCount = context.getErrorCount(); | 1146 int errorCount = context.getErrorCount(); |
| 1147 if (config.typeErrorsAreFatal()) { | 1147 if (config.typeErrorsAreFatal()) { |
| 1148 errorCount += context.getTypeErrorCount(); | 1148 errorCount += context.getTypeErrorCount(); |
| 1149 } | 1149 } |
| 1150 if (config.warningsAreFatal()) { | 1150 if (config.warningsAreFatal()) { |
| 1151 errorCount += context.getWarningCount(); | 1151 errorCount += context.getWarningCount(); |
| 1152 } | 1152 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 } | 1302 } |
| 1303 seen.add(libraryUnit.getElement()); | 1303 seen.add(libraryUnit.getElement()); |
| 1304 if (uri.equals(libraryUnit.getName())) { | 1304 if (uri.equals(libraryUnit.getName())) { |
| 1305 return libraryUnit; | 1305 return libraryUnit; |
| 1306 } | 1306 } |
| 1307 for (LibraryNode src : libraryUnit.getSourcePaths()) { | 1307 for (LibraryNode src : libraryUnit.getSourcePaths()) { |
| 1308 if (src.getText().equals(uri)) { | 1308 if (src.getText().equals(uri)) { |
| 1309 return libraryUnit; | 1309 return libraryUnit; |
| 1310 } | 1310 } |
| 1311 } | 1311 } |
| 1312 for (LibraryUnit importedLibrary : libraryUnit.getImports()) { | 1312 for (LibraryUnit importedLibrary : libraryUnit.getImportedLibraries()) { |
| 1313 LibraryUnit unit = findLibrary(importedLibrary, uri, seen); | 1313 LibraryUnit unit = findLibrary(importedLibrary, uri, seen); |
| 1314 if (unit != null) { | 1314 if (unit != null) { |
| 1315 return unit; | 1315 return unit; |
| 1316 } | 1316 } |
| 1317 } | 1317 } |
| 1318 return null; | 1318 return null; |
| 1319 } | 1319 } |
| 1320 | 1320 |
| 1321 public static LibraryUnit getCoreLib(LibraryUnit libraryUnit) { | 1321 public static LibraryUnit getCoreLib(LibraryUnit libraryUnit) { |
| 1322 return findLibrary(libraryUnit, "dart:core", new HashSet<LibraryElement>()); | 1322 return findLibrary(libraryUnit, "dart:core", new HashSet<LibraryElement>()); |
| 1323 } | 1323 } |
| 1324 } | 1324 } |
| OLD | NEW |