Chromium Code Reviews| Index: lib/compiler/implementation/compiler.dart |
| diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart |
| index 1e2f66efdf3cadda6b47d3d4ca428f815c284e60..037cb278386c7d213b67b50d16f487e2e0ce9381 100644 |
| --- a/lib/compiler/implementation/compiler.dart |
| +++ b/lib/compiler/implementation/compiler.dart |
| @@ -81,6 +81,7 @@ class Compiler implements DiagnosticListener { |
| Namer namer; |
| Types types; |
| bool enableTypeAssertions = false; |
| + bool unparseValidation = false; |
| final Tracer tracer; |
| @@ -364,6 +365,9 @@ Please report this problem at http://dartbug.com/new.'''); |
| assert(parser !== null); |
| Node tree = parser.parse(element); |
| validator.validate(tree); |
| + if (unparseValidation) { |
| + checkUnparse(element, this); |
|
Anton Muhin
2012/05/16 16:00:58
I considered several other options, but found this
|
| + } |
| TreeElements elements = resolver.resolve(element); |
| checker.check(tree, elements); |
| return elements; |
| @@ -594,3 +598,31 @@ class SourceSpan { |
| const SourceSpan(this.uri, this.begin, this.end); |
| } |
| + |
| +void checkUnparse(Element element, Compiler compiler) { |
|
ahe
2012/05/21 16:53:29
I don't like having this method here :-)
A task a
Anton Muhin
2012/05/21 19:14:38
Done.
|
| + if (element is! PartialFunctionElement) { |
| + // TODO(antonm): consider supporting other kinds of elements. |
| + return; |
| + } |
| + |
| + PartialFunctionElement originalFunction = element; |
| + String unparsed = compiler.parser.parse(originalFunction).unparse(false); |
|
ahe
2012/05/21 16:53:29
I think this should be originalFunction.parseNode(
Anton Muhin
2012/05/21 19:14:38
Done.
|
| + Token newTokens = new StringScanner(unparsed).tokenize(); |
| + Token lastToken = newTokens; |
| + while (lastToken.info !== EOF_INFO) { |
| + lastToken = lastToken.next; |
| + } |
| + |
| + PartialFunctionElement newFunction = new PartialFunctionElement( |
| + originalFunction.name, |
| + newTokens, |
| + originalFunction.getOrSet, |
|
ahe
2012/05/21 16:53:29
Unfortunately, this will not work.
Everything aft
Anton Muhin
2012/05/21 19:14:38
Done.
|
| + lastToken, |
| + originalFunction.kind, |
| + originalFunction.modifiers, |
| + originalFunction.enclosingElement); |
| + |
| + Node originalNode = originalFunction.parseNode(compiler); |
| + Node newNode = newFunction.parseNode(compiler); |
|
Anton Muhin
2012/05/16 16:00:58
as of now in some cases we cannot even parse unpar
|
| + // TODO(antonm): add Node comparison. |
| +} |