Index: pkg/front_end/lib/src/fasta/kernel/verifier.dart |
diff --git a/pkg/front_end/lib/src/fasta/kernel/verifier.dart b/pkg/front_end/lib/src/fasta/kernel/verifier.dart |
index 7a0c16c0c2d5e8b26a66616bdfc8f90423f91386..c943f9e1ff438473553f8247dbafd46a5ca1d3da 100644 |
--- a/pkg/front_end/lib/src/fasta/kernel/verifier.dart |
+++ b/pkg/front_end/lib/src/fasta/kernel/verifier.dart |
@@ -5,25 +5,49 @@ |
library fasta.verifier; |
import 'package:kernel/ast.dart' show |
+ Class, |
ExpressionStatement, |
- Program; |
+ Field, |
+ Library, |
+ Procedure, |
+ Program, |
+ TreeNode; |
import 'package:kernel/verifier.dart' show |
+ VerificationError, |
VerifyingVisitor; |
+import '../errors.dart' show |
+ printUnexpected; |
+ |
import 'redirecting_factory_body.dart' show |
RedirectingFactoryBody; |
void verifyProgram(Program program, {bool isOutline: false}) { |
- program.accept(new FastaVerifyingVisitor(isOutline)); |
+ FastaVerifyingVisitor verifier = new FastaVerifyingVisitor(isOutline); |
+ program.accept(verifier); |
+ if (verifier.errors.isNotEmpty) { |
+ throw verifier.errors.first; |
+ } |
} |
class FastaVerifyingVisitor extends VerifyingVisitor { |
+ final List<VerificationError> errors = <VerificationError>[]; |
+ |
+ String fileUri; |
+ |
FastaVerifyingVisitor(bool isOutline) { |
this.isOutline = isOutline; |
} |
@override |
+ problem(TreeNode node, String details) { |
Johnni Winther
2017/02/28 13:36:39
No use of this yet?
ahe
2017/02/28 13:46:25
It's used a lot in the superclass. Too much, I thi
|
+ VerificationError error = new VerificationError(context, node, details); |
+ printUnexpected(Uri.parse(fileUri), node.fileOffset, "$error"); |
+ errors.add(error); |
+ } |
+ |
+ @override |
visitExpressionStatement(ExpressionStatement node) { |
// Bypass verification of the [StaticGet] in [RedirectingFactoryBody] as |
// this is a static get without a getter. |
@@ -31,4 +55,24 @@ class FastaVerifyingVisitor extends VerifyingVisitor { |
super.visitExpressionStatement(node); |
} |
} |
+ |
+ visitLibrary(Library node) { |
+ fileUri = node.fileUri; |
+ super.visitLibrary(node); |
+ } |
+ |
+ visitClass(Class node) { |
+ fileUri = node.fileUri; |
+ super.visitClass(node); |
+ } |
+ |
+ visitField(Field node) { |
+ fileUri = node.fileUri; |
+ super.visitField(node); |
+ } |
+ |
+ visitProcedure(Procedure node) { |
+ fileUri = node.fileUri; |
+ super.visitProcedure(node); |
+ } |
} |