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

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

Issue 10456080: Remove printDebugInfo from Unparser (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: toDebugString() in tree validator 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
« no previous file with comments | « lib/compiler/implementation/tree_validator.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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]) {
(...skipping 20 matching lines...) Expand all
31 UnparseValidator(Compiler compiler, this.validateUnparse) : super(compiler); 31 UnparseValidator(Compiler compiler, this.validateUnparse) : super(compiler);
32 32
33 void check(Element element) { 33 void check(Element element) {
34 if (!validateUnparse) return; 34 if (!validateUnparse) return;
35 35
36 // TODO(antonm): consider supporting other kinds of elements. 36 // TODO(antonm): consider supporting other kinds of elements.
37 if (element is! PartialFunctionElement) return; 37 if (element is! PartialFunctionElement) return;
38 38
39 PartialFunctionElement originalFunction = element; 39 PartialFunctionElement originalFunction = element;
40 FunctionExpression originalNode = originalFunction.parseNode(compiler); 40 FunctionExpression originalNode = originalFunction.parseNode(compiler);
41 String unparsed = originalNode.unparse(false); 41 String unparsed = originalNode.unparse();
42 42
43 Token newTokens = new StringScanner(unparsed).tokenize(); 43 Token newTokens = new StringScanner(unparsed).tokenize();
44 44
45 // Find the getOrSet token. 45 // Find the getOrSet token.
46 // TODO(ahe): This is to frigging complicated. Simplify it. 46 // TODO(ahe): This is to frigging complicated. Simplify it.
47 Parser parser = new Parser(new Listener()); 47 Parser parser = new Parser(new Listener());
48 Token getOrSet = 48 Token getOrSet =
49 parser.findGetOrSet(parser.parseModifiers(newTokens)); 49 parser.findGetOrSet(parser.parseModifiers(newTokens));
50 50
51 // TODO(ahe): This is also too frigging complicated. 51 // TODO(ahe): This is also too frigging complicated.
52 Script originalScript = element.getCompilationUnit().script; 52 Script originalScript = element.getCompilationUnit().script;
53 String name = SourceSpan.withOffsets( 53 String name = SourceSpan.withOffsets(
54 originalFunction.beginToken, originalFunction.endToken, 54 originalFunction.beginToken, originalFunction.endToken,
55 (beginOffset, endOffset) => 55 (beginOffset, endOffset) =>
56 'synthesized:${originalScript.name}#$beginOffset:$endOffset'); 56 'synthesized:${originalScript.name}#$beginOffset:$endOffset');
57 SourceFile synthesizedSourceFile = new SourceFile(name, unparsed); 57 SourceFile synthesizedSourceFile = new SourceFile(name, unparsed);
58 Script synthesizedScript = 58 Script synthesizedScript =
59 new Script(originalScript.uri, synthesizedSourceFile); 59 new Script(originalScript.uri, synthesizedSourceFile);
60 LibraryElement lib = new LibraryElement(synthesizedScript); 60 LibraryElement lib = new LibraryElement(synthesizedScript);
61 NodeListener listener = 61 NodeListener listener =
62 new NodeListener(new ValidatorListener(synthesizedSourceFile), lib); 62 new NodeListener(new ValidatorListener(synthesizedSourceFile), lib);
63 parser = new Parser(listener); 63 parser = new Parser(listener);
64 parser.parseFunction(newTokens, getOrSet); 64 parser.parseFunction(newTokens, getOrSet);
65 FunctionExpression newNode = listener.popNode(); 65 FunctionExpression newNode = listener.popNode();
66 // TODO(antonm): add Node comparison. 66 // TODO(antonm): add Node comparison.
67 } 67 }
68 } 68 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/tree_validator.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698