| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 class TreeValidatorTask extends CompilerTask { | 7 class TreeValidatorTask extends CompilerTask { |
| 8 TreeValidatorTask(Compiler compiler) : super(compiler); | 8 TreeValidatorTask(Compiler compiler) : super(compiler); |
| 9 | 9 |
| 10 void validate(Node tree) { | 10 void validate(Node tree) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 expect(node.arguments.tail.head, node.arguments.tail.isEmpty); | 51 expect(node.arguments.tail.head, node.arguments.tail.isEmpty); |
| 52 } else { | 52 } else { |
| 53 expect(node.arguments.head, node.arguments.isEmpty); | 53 expect(node.arguments.head, node.arguments.isEmpty); |
| 54 } | 54 } |
| 55 } else { | 55 } else { |
| 56 expect(node, !node.arguments.isEmpty); | 56 expect(node, !node.arguments.isEmpty); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 visitReturn(Return node) { | 60 visitReturn(Return node) { |
| 61 if (!node.isRedirectingFactoryBody && node.hasExpression) { | 61 if (node.hasExpression) { |
| 62 // We allow non-expression expressions in Return nodes, but only when | 62 // We allow non-expression expressions in Return nodes, but only when |
| 63 // using them to hold redirecting factory constructors. | 63 // using them to hold redirecting factory constructors. |
| 64 expect(node, node.expression.asExpression() != null); | 64 expect(node, node.expression.asExpression() != null); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 class InvalidNodeError { | 69 class InvalidNodeError { |
| 70 final Node node; | 70 final Node node; |
| 71 final String message; | 71 final String message; |
| 72 InvalidNodeError(this.node, [this.message]); | 72 InvalidNodeError(this.node, [this.message]); |
| 73 | 73 |
| 74 toString() { | 74 toString() { |
| 75 String nodeString = node.toDebugString(); | 75 String nodeString = node.toDebugString(); |
| 76 String result = 'invalid node: $nodeString'; | 76 String result = 'invalid node: $nodeString'; |
| 77 if (message != null) result = '$result ($message)'; | 77 if (message != null) result = '$result ($message)'; |
| 78 return result; | 78 return result; |
| 79 } | 79 } |
| 80 } | 80 } |
| OLD | NEW |