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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/verifier.dart

Issue 2721623002: Let parser handle factory modifiers. (Closed)
Patch Set: Handle factory modifiers correctly in dart2js. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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' show 7 import 'package:kernel/ast.dart' show
8 Class,
8 ExpressionStatement, 9 ExpressionStatement,
9 Program; 10 Field,
11 Library,
12 Procedure,
13 Program,
14 TreeNode;
10 15
11 import 'package:kernel/verifier.dart' show 16 import 'package:kernel/verifier.dart' show
17 VerificationError,
12 VerifyingVisitor; 18 VerifyingVisitor;
13 19
20 import '../errors.dart' show
21 printUnexpected;
22
14 import 'redirecting_factory_body.dart' show 23 import 'redirecting_factory_body.dart' show
15 RedirectingFactoryBody; 24 RedirectingFactoryBody;
16 25
17 void verifyProgram(Program program, {bool isOutline: false}) { 26 void verifyProgram(Program program, {bool isOutline: false}) {
18 program.accept(new FastaVerifyingVisitor(isOutline)); 27 FastaVerifyingVisitor verifier = new FastaVerifyingVisitor(isOutline);
28 program.accept(verifier);
29 if (verifier.errors.isNotEmpty) {
30 throw verifier.errors.first;
31 }
19 } 32 }
20 33
21 class FastaVerifyingVisitor extends VerifyingVisitor { 34 class FastaVerifyingVisitor extends VerifyingVisitor {
35 final List<VerificationError> errors = <VerificationError>[];
36
37 String fileUri;
38
22 FastaVerifyingVisitor(bool isOutline) { 39 FastaVerifyingVisitor(bool isOutline) {
23 this.isOutline = isOutline; 40 this.isOutline = isOutline;
24 } 41 }
25 42
26 @override 43 @override
44 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
45 VerificationError error = new VerificationError(context, node, details);
46 printUnexpected(Uri.parse(fileUri), node.fileOffset, "$error");
47 errors.add(error);
48 }
49
50 @override
27 visitExpressionStatement(ExpressionStatement node) { 51 visitExpressionStatement(ExpressionStatement node) {
28 // Bypass verification of the [StaticGet] in [RedirectingFactoryBody] as 52 // Bypass verification of the [StaticGet] in [RedirectingFactoryBody] as
29 // this is a static get without a getter. 53 // this is a static get without a getter.
30 if (node is! RedirectingFactoryBody) { 54 if (node is! RedirectingFactoryBody) {
31 super.visitExpressionStatement(node); 55 super.visitExpressionStatement(node);
32 } 56 }
33 } 57 }
58
59 visitLibrary(Library node) {
60 fileUri = node.fileUri;
61 super.visitLibrary(node);
62 }
63
64 visitClass(Class node) {
65 fileUri = node.fileUri;
66 super.visitClass(node);
67 }
68
69 visitField(Field node) {
70 fileUri = node.fileUri;
71 super.visitField(node);
72 }
73
74 visitProcedure(Procedure node) {
75 fileUri = node.fileUri;
76 super.visitProcedure(node);
77 }
34 } 78 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart ('k') | pkg/front_end/lib/src/fasta/parser/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698