| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 tagState = checkTag(TagState.LIBRARY, tag); | 52 tagState = checkTag(TagState.LIBRARY, tag); |
| 53 if (library.libraryTag !== null) { | 53 if (library.libraryTag !== null) { |
| 54 compiler.cancel("duplicated library declaration", node: tag); | 54 compiler.cancel("duplicated library declaration", node: tag); |
| 55 } else { | 55 } else { |
| 56 library.libraryTag = tag; | 56 library.libraryTag = tag; |
| 57 } | 57 } |
| 58 } else if (tag.isSource()) { | 58 } else if (tag.isSource()) { |
| 59 tagState = checkTag(TagState.SOURCE, tag); | 59 tagState = checkTag(TagState.SOURCE, tag); |
| 60 Script script = compiler.readScript(resolved, tag); | 60 Script script = compiler.readScript(resolved, tag); |
| 61 CompilationUnitElement unit = | 61 CompilationUnitElement unit = |
| 62 new CompilationUnitElement(script, library); | 62 new CompilationUnitElement(script, library); |
| 63 compiler.withCurrentElement(unit, () => scan(unit)); | 63 compiler.withCurrentElement(unit, () => scan(unit)); |
| 64 } else if (tag.isResource()) { | 64 } else if (tag.isResource()) { |
| 65 tagState = checkTag(TagState.RESOURCE, tag); | 65 tagState = checkTag(TagState.RESOURCE, tag); |
| 66 compiler.reportWarning(tag, 'ignoring resource tag'); | 66 compiler.reportWarning(tag, 'ignoring resource tag'); |
| 67 } else { | 67 } else { |
| 68 compiler.cancel("illegal script tag: ${tag.tag}", node: tag); | 68 compiler.cancel("illegal script tag: ${tag.tag}", node: tag); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 // TODO(ahe): During Compiler.scanBuiltinLibraries, | 71 // TODO(ahe): During Compiler.scanBuiltinLibraries, |
| 72 // compiler.coreLibrary is null. Clean this up when there is a | 72 // compiler.coreLibrary is null. Clean this up when there is a |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 class DietParserTask extends CompilerTask { | 174 class DietParserTask extends CompilerTask { |
| 175 DietParserTask(Compiler compiler) : super(compiler); | 175 DietParserTask(Compiler compiler) : super(compiler); |
| 176 final String name = 'Diet Parser'; | 176 final String name = 'Diet Parser'; |
| 177 | 177 |
| 178 dietParse(CompilationUnitElement compilationUnit, Token tokens) { | 178 dietParse(CompilationUnitElement compilationUnit, Token tokens) { |
| 179 measure(() { | 179 measure(() { |
| 180 ElementListener listener = new ElementListener(compiler, compilationUnit); | 180 Function idGenerator = compiler.universe.getNextFreeClassId; |
| 181 ElementListener listener = |
| 182 new ElementListener(compiler, compilationUnit, idGenerator); |
| 181 PartialParser parser = new PartialParser(listener); | 183 PartialParser parser = new PartialParser(listener); |
| 182 parser.parseUnit(tokens); | 184 parser.parseUnit(tokens); |
| 183 }); | 185 }); |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| 187 /** | 189 /** |
| 188 * The fields of this class models a state machine for checking script | 190 * The fields of this class models a state machine for checking script |
| 189 * tags come in the correct order. | 191 * tags come in the correct order. |
| 190 */ | 192 */ |
| 191 class TagState { | 193 class TagState { |
| 192 static final int NO_TAG_SEEN = 0; | 194 static final int NO_TAG_SEEN = 0; |
| 193 static final int LIBRARY = 1; | 195 static final int LIBRARY = 1; |
| 194 static final int IMPORT = 2; | 196 static final int IMPORT = 2; |
| 195 static final int SOURCE = 3; | 197 static final int SOURCE = 3; |
| 196 static final int RESOURCE = 4; | 198 static final int RESOURCE = 4; |
| 197 | 199 |
| 198 /** Next state. */ | 200 /** Next state. */ |
| 199 static final List<int> NEXT = | 201 static final List<int> NEXT = |
| 200 const <int>[NO_TAG_SEEN, | 202 const <int>[NO_TAG_SEEN, |
| 201 IMPORT, // Only one library tag is allowed. | 203 IMPORT, // Only one library tag is allowed. |
| 202 IMPORT, | 204 IMPORT, |
| 203 SOURCE, | 205 SOURCE, |
| 204 RESOURCE]; | 206 RESOURCE]; |
| 205 } | 207 } |
| OLD | NEW |