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

Side by Side Diff: pkg/kernel/lib/verifier.dart

Issue 2746923002: Implement nested switches and missing switch continue targets. (Closed)
Patch Set: Long line. 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
« no previous file with comments | « pkg/front_end/lib/src/fasta/testing/kernel_chain.dart ('k') | tests/co19/co19-kernel.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library kernel.checks; 4 library kernel.checks;
5 5
6 import 'ast.dart'; 6 import 'ast.dart';
7 import 'transformations/flags.dart'; 7 import 'transformations/flags.dart';
8 8
9 void verifyProgram(Program program) { 9 void verifyProgram(Program program) {
10 VerifyingVisitor.check(program); 10 VerifyingVisitor.check(program);
(...skipping 13 matching lines...) Expand all
24 try { 24 try {
25 location = node?.location ?? context?.location; 25 location = node?.location ?? context?.location;
26 } catch (_) { 26 } catch (_) {
27 // TODO(ahe): Fix the compiler instead. 27 // TODO(ahe): Fix the compiler instead.
28 } 28 }
29 if (location != null) { 29 if (location != null) {
30 String file = location.file ?? ""; 30 String file = location.file ?? "";
31 return "$file:${location.line}:${location.column}: Verification error:" 31 return "$file:${location.line}:${location.column}: Verification error:"
32 " $details"; 32 " $details";
33 } else { 33 } else {
34 return "Verification error: $details\nContext: '$context'.\nNode: '$node'. "; 34 return "Verification error: $details\n"
35 "Context: '$context'.\n"
36 "Node: '$node'.";
35 } 37 }
36 } 38 }
37 } 39 }
38 40
39 /// Checks that a kernel program is well-formed. 41 /// Checks that a kernel program is well-formed.
40 /// 42 ///
41 /// This does not include any kind of type checking. 43 /// This does not include any kind of type checking.
42 class VerifyingVisitor extends RecursiveVisitor { 44 class VerifyingVisitor extends RecursiveVisitor {
43 final Set<Class> classes = new Set<Class>(); 45 final Set<Class> classes = new Set<Class>();
44 final Set<TypeParameter> typeParameters = new Set<TypeParameter>(); 46 final Set<TypeParameter> typeParameters = new Set<TypeParameter>();
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 String name = argument.name; 425 String name = argument.name;
424 for (int j = 0; j < function.namedParameters.length; ++j) { 426 for (int j = 0; j < function.namedParameters.length; ++j) {
425 if (function.namedParameters[j].name == name) continue namedLoop; 427 if (function.namedParameters[j].name == name) continue namedLoop;
426 } 428 }
427 return false; 429 return false;
428 } 430 }
429 return true; 431 return true;
430 } 432 }
431 433
432 @override 434 @override
435 visitContinueSwitchStatement(ContinueSwitchStatement node) {
436 if (node.target == null) {
437 problem(node, "No target.");
438 } else if (node.target.parent == null) {
439 problem(node, "Target has no parent.");
440 } else {
441 SwitchStatement statement = node.target.parent;
442 for (SwitchCase switchCase in statement.cases) {
443 if (switchCase == node.target) return;
444 }
445 problem(node, "Switch case isn't child of parent.");
446 }
447 }
448
449 @override
433 defaultMemberReference(Member node) { 450 defaultMemberReference(Member node) {
434 if (node.transformerFlags & TransformerFlag.seenByVerifier == 0) { 451 if (node.transformerFlags & TransformerFlag.seenByVerifier == 0) {
435 problem( 452 problem(
436 node, "Dangling reference to '$node', parent is: '${node.parent}'."); 453 node, "Dangling reference to '$node', parent is: '${node.parent}'.");
437 } 454 }
438 } 455 }
439 456
440 @override 457 @override
441 visitClassReference(Class node) { 458 visitClassReference(Class node) {
442 if (!classes.contains(node)) { 459 if (!classes.contains(node)) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 var oldParent = parent; 513 var oldParent = parent;
497 parent = node; 514 parent = node;
498 node.visitChildren(this); 515 node.visitChildren(this);
499 parent = oldParent; 516 parent = oldParent;
500 } 517 }
501 } 518 }
502 519
503 void checkInitializers(Constructor constructor) { 520 void checkInitializers(Constructor constructor) {
504 // TODO(ahe): I'll add more here in other CLs. 521 // TODO(ahe): I'll add more here in other CLs.
505 } 522 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/testing/kernel_chain.dart ('k') | tests/co19/co19-kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698