| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library fasta.verifier; | 5 library fasta.verifier; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
| 8 show | 8 show |
| 9 InvalidExpression, | 9 InvalidExpression, |
| 10 InvalidStatement, | 10 InvalidStatement, |
| 11 InvalidInitializer, | 11 InvalidInitializer, |
| 12 Class, | 12 Class, |
| 13 ExpressionStatement, | 13 ExpressionStatement, |
| 14 Field, | 14 Field, |
| 15 Library, | 15 Library, |
| 16 Procedure, | 16 Procedure, |
| 17 Program, | 17 Program, |
| 18 TreeNode; | 18 TreeNode; |
| 19 | 19 |
| 20 import 'package:kernel/verifier.dart' show VerificationError, VerifyingVisitor; | 20 import 'package:kernel/verifier.dart' show VerificationError, VerifyingVisitor; |
| 21 | 21 |
| 22 import '../errors.dart' show printUnexpected; | 22 import '../errors.dart' show printUnexpected; |
| 23 | 23 |
| 24 import 'redirecting_factory_body.dart' show RedirectingFactoryBody; | 24 import 'redirecting_factory_body.dart' show RedirectingFactoryBody; |
| 25 | 25 |
| 26 void verifyProgram(Program program, {bool isOutline: false}) { | 26 List<VerificationError> verifyProgram(Program program, |
| 27 {bool isOutline: false}) { |
| 27 FastaVerifyingVisitor verifier = new FastaVerifyingVisitor(isOutline); | 28 FastaVerifyingVisitor verifier = new FastaVerifyingVisitor(isOutline); |
| 28 program.accept(verifier); | 29 program.accept(verifier); |
| 29 if (verifier.errors.isNotEmpty) { | 30 return verifier.errors; |
| 30 throw verifier.errors.first; | |
| 31 } | |
| 32 } | 31 } |
| 33 | 32 |
| 34 class FastaVerifyingVisitor extends VerifyingVisitor { | 33 class FastaVerifyingVisitor extends VerifyingVisitor { |
| 35 final List<VerificationError> errors = <VerificationError>[]; | 34 final List<VerificationError> errors = <VerificationError>[]; |
| 36 | 35 |
| 37 String fileUri; | 36 String fileUri; |
| 38 | 37 |
| 39 FastaVerifyingVisitor(bool isOutline) { | 38 FastaVerifyingVisitor(bool isOutline) { |
| 40 this.isOutline = isOutline; | 39 this.isOutline = isOutline; |
| 41 } | 40 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 @override | 87 @override |
| 89 visitInvalidStatement(InvalidStatement node) { | 88 visitInvalidStatement(InvalidStatement node) { |
| 90 problem(node, "Invalid statement."); | 89 problem(node, "Invalid statement."); |
| 91 } | 90 } |
| 92 | 91 |
| 93 @override | 92 @override |
| 94 visitInvalidInitializer(InvalidInitializer node) { | 93 visitInvalidInitializer(InvalidInitializer node) { |
| 95 problem(node, "Invalid initializer."); | 94 problem(node, "Invalid initializer."); |
| 96 } | 95 } |
| 97 } | 96 } |
| OLD | NEW |