| 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 scanLibrary(LibraryElement library) { | 9 void scanLibrary(LibraryElement library) { |
| 10 var compilationUnit = library.entryCompilationUnit; | 10 var compilationUnit = library.entryCompilationUnit; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 111 } |
| 112 | 112 |
| 113 void scanElements(CompilationUnitElement compilationUnit) { | 113 void scanElements(CompilationUnitElement compilationUnit) { |
| 114 Script script = compilationUnit.script; | 114 Script script = compilationUnit.script; |
| 115 Token tokens = new StringScanner(script.text).tokenize(); | 115 Token tokens = new StringScanner(script.text).tokenize(); |
| 116 compiler.dietParser.dietParse(compilationUnit, tokens); | 116 compiler.dietParser.dietParse(compilationUnit, tokens); |
| 117 } | 117 } |
| 118 | 118 |
| 119 LibraryElement loadLibrary(Uri uri, Node node, Uri canonicalUri) { | 119 LibraryElement loadLibrary(Uri uri, Node node, Uri canonicalUri) { |
| 120 bool newLibrary = false; | 120 bool newLibrary = false; |
| 121 LibraryElement library = | 121 LibraryElement createLibrary() { |
| 122 compiler.libraries.putIfAbsent(uri.toString(), () { | 122 newLibrary = true; |
| 123 newLibrary = true; | 123 Script script = compiler.readScript(uri, node); |
| 124 Script script = compiler.readScript(uri, node); | 124 LibraryElement element = new LibraryElement(script, canonicalUri); |
| 125 LibraryElement element = new LibraryElement(script, canonicalUri); | 125 native.maybeEnableNative(compiler, element, uri); |
| 126 native.maybeEnableNative(compiler, element, uri); | 126 return element; |
| 127 return element; | 127 } |
| 128 }); | 128 LibraryElement library; |
| 129 if (canonicalUri === null) { |
| 130 library = createLibrary(); |
| 131 } else { |
| 132 library = compiler.libraries.putIfAbsent(canonicalUri.toString(), |
| 133 createLibrary); |
| 134 } |
| 129 if (newLibrary) { | 135 if (newLibrary) { |
| 130 compiler.withCurrentElement(library, () { | 136 compiler.withCurrentElement(library, () { |
| 131 scanLibrary(library); | 137 scanLibrary(library); |
| 132 compiler.onLibraryLoaded(library, uri); | 138 compiler.onLibraryLoaded(library, uri); |
| 133 }); | 139 }); |
| 134 } | 140 } |
| 135 return library; | 141 return library; |
| 136 } | 142 } |
| 137 | 143 |
| 138 void importLibrary(LibraryElement library, LibraryElement imported, | 144 void importLibrary(LibraryElement library, LibraryElement imported, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 static const int RESOURCE = 4; | 218 static const int RESOURCE = 4; |
| 213 | 219 |
| 214 /** Next state. */ | 220 /** Next state. */ |
| 215 static const List<int> NEXT = | 221 static const List<int> NEXT = |
| 216 const <int>[NO_TAG_SEEN, | 222 const <int>[NO_TAG_SEEN, |
| 217 IMPORT, // Only one library tag is allowed. | 223 IMPORT, // Only one library tag is allowed. |
| 218 IMPORT, | 224 IMPORT, |
| 219 SOURCE, | 225 SOURCE, |
| 220 RESOURCE]; | 226 RESOURCE]; |
| 221 } | 227 } |
| OLD | NEW |