Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: pkg/compiler/lib/src/patch_parser.dart

Issue 1312613006: Add command-line parameter enabling assert messages. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /** 5 /**
6 * This library contains the infrastructure to parse and integrate patch files. 6 * This library contains the infrastructure to parse and integrate patch files.
7 * 7 *
8 * Three types of elements can be patched: [LibraryElement], [ClassElement], 8 * Three types of elements can be patched: [LibraryElement], [ClassElement],
9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded 9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded
10 * together with the corresponding origin library. Which libraries that are 10 * together with the corresponding origin library. Which libraries that are
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void scanLibraryElements(CompilationUnitElement compilationUnit) { 170 void scanLibraryElements(CompilationUnitElement compilationUnit) {
171 measure(() { 171 measure(() {
172 // TODO(johnniwinther): Test that parts and exports are handled correctly. 172 // TODO(johnniwinther): Test that parts and exports are handled correctly.
173 Script script = compilationUnit.script; 173 Script script = compilationUnit.script;
174 Token tokens = new Scanner(script.file).tokenize(); 174 Token tokens = new Scanner(script.file).tokenize();
175 Function idGenerator = compiler.getNextFreeClassId; 175 Function idGenerator = compiler.getNextFreeClassId;
176 Listener patchListener = new PatchElementListener(compiler, 176 Listener patchListener = new PatchElementListener(compiler,
177 compilationUnit, 177 compilationUnit,
178 idGenerator); 178 idGenerator);
179 try { 179 try {
180 new PartialParser(patchListener).parseUnit(tokens); 180 new PartialParser(patchListener,
181 allowAssertMessage: compiler.allowAssertMessage)
182 .parseUnit(tokens);
181 } on ParserError catch (e) { 183 } on ParserError catch (e) {
182 // No need to recover from a parser error in platform libraries, user 184 // No need to recover from a parser error in platform libraries, user
183 // will never see this if the libraries are tested correctly. 185 // will never see this if the libraries are tested correctly.
184 compiler.internalError( 186 compiler.internalError(
185 compilationUnit, "Parser error in patch file: $e"); 187 compilationUnit, "Parser error in patch file: $e");
186 } 188 }
187 }); 189 });
188 } 190 }
189 191
190 void parsePatchClassNode(PartialClassElement cls) { 192 void parsePatchClassNode(PartialClassElement cls) {
191 // Parse [PartialClassElement] using a "patch"-aware parser instead 193 // Parse [PartialClassElement] using a "patch"-aware parser instead
192 // of calling its [parseNode] method. 194 // of calling its [parseNode] method.
193 if (cls.cachedNode != null) return; 195 if (cls.cachedNode != null) return;
194 196
195 measure(() => compiler.withCurrentElement(cls, () { 197 measure(() => compiler.withCurrentElement(cls, () {
196 MemberListener listener = new PatchMemberListener(compiler, cls); 198 MemberListener listener = new PatchMemberListener(compiler, cls);
197 Parser parser = new PatchClassElementParser(listener); 199 Parser parser = new PatchClassElementParser(listener,
200 allowAssertMessage: compiler.allowAssertMessage);
198 try { 201 try {
199 Token token = parser.parseTopLevelDeclaration(cls.beginToken); 202 Token token = parser.parseTopLevelDeclaration(cls.beginToken);
200 assert(identical(token, cls.endToken.next)); 203 assert(identical(token, cls.endToken.next));
201 } on ParserError catch (e) { 204 } on ParserError catch (e) {
202 // No need to recover from a parser error in platform libraries, user 205 // No need to recover from a parser error in platform libraries, user
203 // will never see this if the libraries are tested correctly. 206 // will never see this if the libraries are tested correctly.
204 compiler.internalError( 207 compiler.internalError(
205 cls, "Parser error in patch file: $e"); 208 cls, "Parser error in patch file: $e");
206 } 209 }
207 cls.cachedNode = listener.popNode(); 210 cls.cachedNode = listener.popNode();
(...skipping 26 matching lines...) Expand all
234 enclosingClass.addMember(patch, listener); 237 enclosingClass.addMember(patch, listener);
235 } 238 }
236 } 239 }
237 } 240 }
238 241
239 /** 242 /**
240 * Partial parser for patch files that also handles the members of class 243 * Partial parser for patch files that also handles the members of class
241 * declarations. 244 * declarations.
242 */ 245 */
243 class PatchClassElementParser extends PartialParser { 246 class PatchClassElementParser extends PartialParser {
244 PatchClassElementParser(Listener listener) : super(listener); 247 PatchClassElementParser(Listener listener,
248 {bool allowAssertMessage: false})
249 : super(listener, allowAssertMessage: allowAssertMessage);
245 250
246 Token parseClassBody(Token token) => fullParseClassBody(token); 251 Token parseClassBody(Token token) => fullParseClassBody(token);
247 } 252 }
248 253
249 /** 254 /**
250 * Extension of [ElementListener] for parsing patch files. 255 * Extension of [ElementListener] for parsing patch files.
251 */ 256 */
252 class PatchElementListener extends ElementListener implements Listener { 257 class PatchElementListener extends ElementListener implements Listener {
253 final Compiler compiler; 258 final Compiler compiler;
254 259
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 579
575 class PatchVersion { 580 class PatchVersion {
576 final String tag; 581 final String tag;
577 582
578 const PatchVersion(this.tag); 583 const PatchVersion(this.tag);
579 584
580 bool isActive(String patchTag) => tag == null || tag == patchTag; 585 bool isActive(String patchTag) => tag == null || tag == patchTag;
581 586
582 String toString() => 'PatchVersion($tag)'; 587 String toString() => 'PatchVersion($tag)';
583 } 588 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart2js.dart ('k') | pkg/compiler/lib/src/scanner/class_element_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698