| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 if (implicitlyImportCoreLibrary) { | 85 if (implicitlyImportCoreLibrary) { |
| 86 importLibrary(library, compiler.coreLibrary, null); | 86 importLibrary(library, compiler.coreLibrary, null); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 void scanElements(CompilationUnitElement compilationUnit) { | 90 void scanElements(CompilationUnitElement compilationUnit) { |
| 91 Script script = compilationUnit.script; | 91 Script script = compilationUnit.script; |
| 92 Token tokens; | 92 Token tokens; |
| 93 try { | 93 try { |
| 94 tokens = new StringScanner(script.text).tokenize(); | 94 try { |
| 95 } catch (MalformedInputException ex) { | 95 tokens = new StringScanner(script.text).tokenize(); |
| 96 Token token; | 96 } catch (MalformedInputException ex) { |
| 97 var message; | 97 Token token; |
| 98 if (ex.position is num) { | 98 var message; |
| 99 // TODO(ahe): Always use tokens in MalformedInputException. | 99 if (ex.position is num) { |
| 100 token = new Token(EOF_INFO, ex.position); | 100 // TODO(ahe): Always use tokens in MalformedInputException. |
| 101 } else { | 101 token = new Token(EOF_INFO, ex.position); |
| 102 token = ex.position; | 102 } else { |
| 103 token = ex.position; |
| 104 } |
| 105 compiler.cancel(ex.message, token: token); |
| 103 } | 106 } |
| 104 compiler.cancel(ex.message, token: token); | 107 compiler.dietParser.dietParse(compilationUnit, tokens); |
| 108 } catch (CompilerCancelledException ex) { |
| 109 throw; |
| 110 } catch (var ex) { |
| 111 compiler.unhandledExceptionOnElement(compilationUnit); |
| 112 throw; |
| 105 } | 113 } |
| 106 compiler.dietParser.dietParse(compilationUnit, tokens); | |
| 107 } | 114 } |
| 108 | 115 |
| 109 LibraryElement loadLibrary(Uri uri, ScriptTag node) { | 116 LibraryElement loadLibrary(Uri uri, ScriptTag node) { |
| 110 bool newLibrary = false; | 117 bool newLibrary = false; |
| 111 LibraryElement library = | 118 LibraryElement library = |
| 112 compiler.universe.libraries.putIfAbsent(uri.toString(), () { | 119 compiler.universe.libraries.putIfAbsent(uri.toString(), () { |
| 113 newLibrary = true; | 120 newLibrary = true; |
| 114 Script script = compiler.readScript(uri, node); | 121 Script script = compiler.readScript(uri, node); |
| 115 LibraryElement element = new LibraryElement(script); | 122 LibraryElement element = new LibraryElement(script); |
| 116 native.maybeEnableNative(compiler, element, uri); | 123 native.maybeEnableNative(compiler, element, uri); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 static final int RESOURCE = 4; | 205 static final int RESOURCE = 4; |
| 199 | 206 |
| 200 /** Next state. */ | 207 /** Next state. */ |
| 201 static final List<int> NEXT = | 208 static final List<int> NEXT = |
| 202 const <int>[NO_TAG_SEEN, | 209 const <int>[NO_TAG_SEEN, |
| 203 IMPORT, // Only one library tag is allowed. | 210 IMPORT, // Only one library tag is allowed. |
| 204 IMPORT, | 211 IMPORT, |
| 205 SOURCE, | 212 SOURCE, |
| 206 RESOURCE]; | 213 RESOURCE]; |
| 207 } | 214 } |
| OLD | NEW |