| 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:front_end/src/fasta/type_inference/type_schema.dart' | 7 import 'package:front_end/src/fasta/type_inference/type_schema.dart' | 
| 8     show TypeSchemaVisitor, UnknownType; | 8     show TypeSchemaVisitor, UnknownType; | 
| 9 | 9 | 
| 10 import 'package:kernel/ast.dart' | 10 import 'package:kernel/ast.dart' | 
| 11     show | 11     show | 
| 12         InvalidExpression, | 12         InvalidExpression, | 
| 13         InvalidStatement, | 13         InvalidStatement, | 
| 14         InvalidInitializer, | 14         InvalidInitializer, | 
| 15         Class, | 15         Class, | 
| 16         ExpressionStatement, | 16         ExpressionStatement, | 
| 17         Field, | 17         Field, | 
| 18         Library, | 18         Library, | 
| 19         Procedure, | 19         Procedure, | 
| 20         Program, | 20         Program, | 
| 21         TreeNode; | 21         TreeNode; | 
| 22 | 22 | 
| 23 import 'package:kernel/verifier.dart' show VerificationError, VerifyingVisitor; | 23 import 'package:kernel/verifier.dart' show VerificationError, VerifyingVisitor; | 
| 24 | 24 | 
| 25 import '../errors.dart' show printUnexpected; | 25 import '../deprecated_problems.dart' show deprecated_printUnexpected; | 
| 26 | 26 | 
| 27 import 'redirecting_factory_body.dart' show RedirectingFactoryBody; | 27 import 'redirecting_factory_body.dart' show RedirectingFactoryBody; | 
| 28 | 28 | 
| 29 List<VerificationError> verifyProgram(Program program, | 29 List<VerificationError> verifyProgram(Program program, | 
| 30     {bool isOutline: false}) { | 30     {bool isOutline: false}) { | 
| 31   FastaVerifyingVisitor verifier = new FastaVerifyingVisitor(isOutline); | 31   FastaVerifyingVisitor verifier = new FastaVerifyingVisitor(isOutline); | 
| 32   program.accept(verifier); | 32   program.accept(verifier); | 
| 33   return verifier.errors; | 33   return verifier.errors; | 
| 34 } | 34 } | 
| 35 | 35 | 
| 36 class FastaVerifyingVisitor extends VerifyingVisitor | 36 class FastaVerifyingVisitor extends VerifyingVisitor | 
| 37     implements TypeSchemaVisitor { | 37     implements TypeSchemaVisitor { | 
| 38   final List<VerificationError> errors = <VerificationError>[]; | 38   final List<VerificationError> errors = <VerificationError>[]; | 
| 39 | 39 | 
| 40   String fileUri; | 40   String fileUri; | 
| 41 | 41 | 
| 42   FastaVerifyingVisitor(bool isOutline) { | 42   FastaVerifyingVisitor(bool isOutline) { | 
| 43     this.isOutline = isOutline; | 43     this.isOutline = isOutline; | 
| 44   } | 44   } | 
| 45 | 45 | 
| 46   @override | 46   @override | 
| 47   problem(TreeNode node, String details, {TreeNode context}) { | 47   problem(TreeNode node, String details, {TreeNode context}) { | 
| 48     context ??= this.context; | 48     context ??= this.context; | 
| 49     VerificationError error = new VerificationError(context, node, details); | 49     VerificationError error = new VerificationError(context, node, details); | 
| 50     printUnexpected(Uri.parse(fileUri), node?.fileOffset ?? -1, "$error"); | 50     deprecated_printUnexpected( | 
|  | 51         Uri.parse(fileUri), node?.fileOffset ?? -1, "$error"); | 
| 51     errors.add(error); | 52     errors.add(error); | 
| 52   } | 53   } | 
| 53 | 54 | 
| 54   @override | 55   @override | 
| 55   visitExpressionStatement(ExpressionStatement node) { | 56   visitExpressionStatement(ExpressionStatement node) { | 
| 56     // Bypass verification of the [StaticGet] in [RedirectingFactoryBody] as | 57     // Bypass verification of the [StaticGet] in [RedirectingFactoryBody] as | 
| 57     // this is a static get without a getter. | 58     // this is a static get without a getter. | 
| 58     if (node is! RedirectingFactoryBody) { | 59     if (node is! RedirectingFactoryBody) { | 
| 59       super.visitExpressionStatement(node); | 60       super.visitExpressionStatement(node); | 
| 60     } | 61     } | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 98   visitInvalidInitializer(InvalidInitializer node) { | 99   visitInvalidInitializer(InvalidInitializer node) { | 
| 99     problem(node, "Invalid initializer."); | 100     problem(node, "Invalid initializer."); | 
| 100   } | 101   } | 
| 101 | 102 | 
| 102   @override | 103   @override | 
| 103   visitUnknownType(UnknownType node) { | 104   visitUnknownType(UnknownType node) { | 
| 104     // Note: we can't pass [node] to [problem] because it's not a [TreeNode]. | 105     // Note: we can't pass [node] to [problem] because it's not a [TreeNode]. | 
| 105     problem(null, "Unexpected appearance of the unknown type."); | 106     problem(null, "Unexpected appearance of the unknown type."); | 
| 106   } | 107   } | 
| 107 } | 108 } | 
| OLD | NEW | 
|---|