Chromium Code Reviews| 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 class ScannerTask extends CompilerTask { | 5 class ScannerTask extends CompilerTask { |
| 6 ScannerTask(Compiler compiler) : super(compiler); | 6 ScannerTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'Scanner'; | 7 String get name() => 'Scanner'; |
| 8 | 8 |
| 9 void scan(CompilationUnitElement compilationUnit) { | 9 void scan(CompilationUnitElement compilationUnit) { |
| 10 measure(() { | 10 measure(() { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 } | 36 } |
| 37 } else if (tag.isSource()) { | 37 } else if (tag.isSource()) { |
| 38 Script script = compiler.readScript(resolved, tag); | 38 Script script = compiler.readScript(resolved, tag); |
| 39 CompilationUnitElement unit = | 39 CompilationUnitElement unit = |
| 40 new CompilationUnitElement(script, library); | 40 new CompilationUnitElement(script, library); |
| 41 compiler.withCurrentElement(unit, () => scan(unit)); | 41 compiler.withCurrentElement(unit, () => scan(unit)); |
| 42 } else { | 42 } else { |
| 43 compiler.cancel("illegal script tag: ${tag.tag}", node: tag); | 43 compiler.cancel("illegal script tag: ${tag.tag}", node: tag); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 bool implicitlyImportCoreLibrary = compiler.coreLibrary !== null; | |
|
ngeoffray
2012/02/16 10:50:50
Is that a check that for making sure core library
ahe
2012/02/16 11:23:18
I plan to fix this as we add more libraries. I thi
| |
| 46 for (ScriptTag tag in imports.toLink()) { | 47 for (ScriptTag tag in imports.toLink()) { |
| 47 // Now that we have processed all the source tags, it is safe to | 48 // Now that we have processed all the source tags, it is safe to |
| 48 // start loading other libraries. | 49 // start loading other libraries. |
| 49 SourceString argument = tag.argument.value.copyWithoutQuotes(1, 1); | 50 SourceString argument = tag.argument.value.copyWithoutQuotes(1, 1); |
| 50 Uri resolved = base.resolve(argument.toString()); | 51 Uri resolved = base.resolve(argument.toString()); |
| 52 if (resolved.toString() == "dart:core") { | |
| 53 implicitlyImportCoreLibrary = false; | |
| 54 } | |
| 51 importLibrary(library, loadLibrary(resolved, tag), tag.prefix); | 55 importLibrary(library, loadLibrary(resolved, tag), tag.prefix); |
| 52 } | 56 } |
| 53 if (compiler.coreLibrary !== null) { | 57 if (implicitlyImportCoreLibrary) { |
| 54 importLibrary(library, compiler.coreLibrary, null); | 58 importLibrary(library, compiler.coreLibrary, null); |
| 55 } | 59 } |
| 56 } | 60 } |
| 57 | 61 |
| 58 void scanElements(CompilationUnitElement compilationUnit) { | 62 void scanElements(CompilationUnitElement compilationUnit) { |
| 59 compiler.log("scanning $compilationUnit"); | 63 compiler.log("scanning $compilationUnit"); |
| 60 Script script = compilationUnit.script; | 64 Script script = compilationUnit.script; |
| 61 Token tokens; | 65 Token tokens; |
| 62 try { | 66 try { |
| 63 tokens = new StringScanner(script.text).tokenize(); | 67 tokens = new StringScanner(script.text).tokenize(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 } else { | 102 } else { |
| 99 for (Link<Element> link = imported.topLevelElements; !link.isEmpty(); | 103 for (Link<Element> link = imported.topLevelElements; !link.isEmpty(); |
| 100 link = link.tail) { | 104 link = link.tail) { |
| 101 compiler.withCurrentElement(link.head, () { | 105 compiler.withCurrentElement(link.head, () { |
| 102 library.define(link.head, compiler); | 106 library.define(link.head, compiler); |
| 103 }); | 107 }); |
| 104 } | 108 } |
| 105 } | 109 } |
| 106 } | 110 } |
| 107 } | 111 } |
| OLD | NEW |