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

Unified Diff: lib/compiler/implementation/compiler.dart

Issue 10332196: Start working on unparse validation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/apiimpl.dart ('k') | lib/compiler/implementation/dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
+}
« no previous file with comments | « lib/compiler/implementation/apiimpl.dart ('k') | lib/compiler/implementation/dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698