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

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

Issue 10332196: Start working on unparse validation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Start working on unparse validation. Created 8 years, 7 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/leg.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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Checks result's of [Node] unparse.
7 */
8 class UnparseValidator extends CompilerTask {
9 final bool validateUnparse;
10
11 UnparseValidator(Compiler compiler, this.validateUnparse) : super(compiler);
12
13 void check(Element element) {
14 if (!validateUnparse) return;
15
16 // TODO(antonm): consider supporting other kinds of elements.
17 if (element is! PartialFunctionElement) return;
18
19 PartialFunctionElement originalFunction = element;
20 FunctionExpression originalNode = originalFunction.parseNode(compiler);
21 String unparsed = originalNode.unparse(false);
22
23 Token newTokens = new StringScanner(unparsed).tokenize();
24
25 // Find the getOrSet token.
26 // TODO(ahe): This is to frigging complicated. Simplify it.
27 Parser parser = new Parser(new Listener());
28 Token getOrSet =
29 parser.findGetOrSet(parser.parseModifiers(newTokens));
30
31 // TODO(ahe): This is also too frigging complicated.
32 Script originalScript = element.getCompilationUnit().script;
33 SourceFile synthesizedSourceFile =
34 new SourceFile(originalScript.name, unparsed);
35 Script synthesizedScript =
36 new Script(originalScript.uri, synthesizedSourceFile);
37 LibraryElement lib = new LibraryElement(synthesizedScript);
38 NodeListener listener = new NodeListener(compiler, lib);
39 parser = new Parser(listener);
40 // TODO(antonm): better error reporting.
41 compiler.withCurrentElement(lib, () {
42 parser.parseFunction(newTokens, getOrSet);
43 });
44 FunctionExpression newNode = listener.popNode();
45 // TODO(antonm): add Node comparison.
46 }
47 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/leg.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698