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

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

Issue 10632019: Place more guards for the cases which should be covered. (Closed) Base URL: https://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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/unparse_validator.dart
diff --git a/lib/compiler/implementation/unparse_validator.dart b/lib/compiler/implementation/unparse_validator.dart
index 146811bbf849be66fefc843a1842230b370fa7c6..f43024678c2ea99bf3a394cc725cb78277168909 100644
--- a/lib/compiler/implementation/unparse_validator.dart
+++ b/lib/compiler/implementation/unparse_validator.dart
@@ -31,13 +31,7 @@ class UnparseValidator extends CompilerTask {
UnparseValidator(Compiler compiler, this.validateUnparse) : super(compiler);
- void check(Element element) {
- if (!validateUnparse) return;
-
- // TODO(antonm): consider supporting other kinds of elements.
- if (element is! PartialFunctionElement) return;
-
- PartialFunctionElement originalFunction = element;
+ void checkFunction(PartialFunctionElement originalFunction) {
FunctionExpression originalNode = originalFunction.parseNode(compiler);
String unparsed = originalNode.unparse();
@@ -50,7 +44,7 @@ class UnparseValidator extends CompilerTask {
parser.findGetOrSet(parser.parseModifiers(newTokens));
// TODO(ahe): This is also too frigging complicated.
- Script originalScript = element.getCompilationUnit().script;
+ Script originalScript = originalFunction.getCompilationUnit().script;
String name = SourceSpan.withOffsets(
originalFunction.beginToken, originalFunction.endToken,
(beginOffset, endOffset) =>
@@ -59,7 +53,7 @@ class UnparseValidator extends CompilerTask {
Script synthesizedScript =
new Script(originalScript.uri, synthesizedSourceFile);
LibraryElement lib = new LibraryElement(synthesizedScript);
- lib.canUseNative = element.getLibrary().canUseNative;
+ lib.canUseNative = originalFunction.getLibrary().canUseNative;
NodeListener listener =
new NodeListener(new ValidatorListener(synthesizedSourceFile), lib);
parser = new Parser(listener);
@@ -67,4 +61,22 @@ class UnparseValidator extends CompilerTask {
FunctionExpression newNode = listener.popNode();
// TODO(antonm): add Node comparison.
}
+
+ void check(Element element) {
+ if (!validateUnparse) return;
+
+ if (element is PartialFunctionElement) {
+ checkFunction(element);
+ } else if (element.isGenerativeConstructor()) {
+ assert(element is FunctionElement);
+ // Generative constructors parse to very special function expressions.
+ // Handle them when classes are properly handled.
+ } else if (element.isField()) {
+ assert(element is VariableElement);
+ // Fields are just names with possible initialization expressions.
+ // Nothing to care about for now.
+ } else {
+ compiler.cancel('Cannot handle $element', element: element);
+ }
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698