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

Side by Side Diff: lib/compiler/implementation/unparse_validator.dart

Issue 10454049: Validate that all instructions dominate their inputs. And fix a bug where that did not happen. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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 class ValidatorListener implements DiagnosticListener { 5 class ValidatorListener implements DiagnosticListener {
6 final SourceFile sourceFile; 6 final SourceFile sourceFile;
7 7
8 ValidatorListener(this.sourceFile); 8 ValidatorListener(this.sourceFile);
9 9
10 void cancel([String reason, node, token, instruction, element]) { 10 void cancel([String reason, node, token, instruction, element]) {
11 assert(token !== null); 11 assert(token !== null);
12 SourceSpan.withOffsets(token, token, (beginOffset, endOffset) { 12 SourceSpan.withOffsets(token, token, (beginOffset, endOffset) {
13 String errorMessage = 13 String errorMessage =
14 sourceFile.getLocationMessage(reason, beginOffset, endOffset, true); 14 sourceFile.getLocationMessage(reason, beginOffset, endOffset, true);
15 print(errorMessage); 15 print(errorMessage);
16 }); 16 });
17 throw new CompilerCancelledException(reason); 17 throw new CompilerCancelledException(reason);
18 } 18 }
19 19
20 void log(message) {} 20 void log(message) {}
21 } 21 }
22 22
23 /** 23 /**
24 * Checks result's of [Node] unparse. 24 * Checks result's of [Node] unparse.
25 */ 25 */
26 class UnparseValidator extends CompilerTask { 26 class UnparseValidator extends CompilerTask {
27 final bool validateUnparse; 27 final bool validateUnparse;
28 28
29 String get name() => "Unparse validator";
30
29 UnparseValidator(Compiler compiler, this.validateUnparse) : super(compiler); 31 UnparseValidator(Compiler compiler, this.validateUnparse) : super(compiler);
30 32
31 void check(Element element) { 33 void check(Element element) {
32 if (!validateUnparse) return; 34 if (!validateUnparse) return;
33 35
34 // TODO(antonm): consider supporting other kinds of elements. 36 // TODO(antonm): consider supporting other kinds of elements.
35 if (element is! PartialFunctionElement) return; 37 if (element is! PartialFunctionElement) return;
36 38
37 PartialFunctionElement originalFunction = element; 39 PartialFunctionElement originalFunction = element;
38 FunctionExpression originalNode = originalFunction.parseNode(compiler); 40 FunctionExpression originalNode = originalFunction.parseNode(compiler);
(...skipping 18 matching lines...) Expand all
57 new Script(originalScript.uri, synthesizedSourceFile); 59 new Script(originalScript.uri, synthesizedSourceFile);
58 LibraryElement lib = new LibraryElement(synthesizedScript); 60 LibraryElement lib = new LibraryElement(synthesizedScript);
59 NodeListener listener = 61 NodeListener listener =
60 new NodeListener(new ValidatorListener(synthesizedSourceFile), lib); 62 new NodeListener(new ValidatorListener(synthesizedSourceFile), lib);
61 parser = new Parser(listener); 63 parser = new Parser(listener);
62 parser.parseFunction(newTokens, getOrSet); 64 parser.parseFunction(newTokens, getOrSet);
63 FunctionExpression newNode = listener.popNode(); 65 FunctionExpression newNode = listener.popNode();
64 // TODO(antonm): add Node comparison. 66 // TODO(antonm): add Node comparison.
65 } 67 }
66 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698