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 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 330 |
331 visitVariableDeclaration(VariableDeclaration node) { | 331 visitVariableDeclaration(VariableDeclaration node) { |
332 var parent = node.parent; | 332 var parent = node.parent; |
333 if (parent is! Block && | 333 if (parent is! Block && |
334 !(parent is Catch && parent.body != node) && | 334 !(parent is Catch && parent.body != node) && |
335 !(parent is FunctionNode && parent.body != node) && | 335 !(parent is FunctionNode && parent.body != node) && |
336 parent is! FunctionDeclaration && | 336 parent is! FunctionDeclaration && |
337 !(parent is ForStatement && parent.body != node) && | 337 !(parent is ForStatement && parent.body != node) && |
338 !(parent is ForInStatement && parent.body != node) && | 338 !(parent is ForInStatement && parent.body != node) && |
339 parent is! Let && | 339 parent is! Let && |
340 parent is! LocalInitializer) { | 340 parent is! LocalInitializer && |
| 341 parent is! Typedef) { |
341 problem( | 342 problem( |
342 node, | 343 node, |
343 "VariableDeclaration must be a direct child of a Block, " | 344 "VariableDeclaration must be a direct child of a Block, " |
344 "not ${parent.runtimeType}."); | 345 "not ${parent.runtimeType}."); |
345 } | 346 } |
346 visitChildren(node); | 347 visitChildren(node); |
347 declareVariable(node); | 348 declareVariable(node); |
348 } | 349 } |
349 | 350 |
350 visitVariableGet(VariableGet node) { | 351 visitVariableGet(VariableGet node) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 var oldParent = parent; | 602 var oldParent = parent; |
602 parent = node; | 603 parent = node; |
603 node.visitChildren(this); | 604 node.visitChildren(this); |
604 parent = oldParent; | 605 parent = oldParent; |
605 } | 606 } |
606 } | 607 } |
607 | 608 |
608 void checkInitializers(Constructor constructor) { | 609 void checkInitializers(Constructor constructor) { |
609 // TODO(ahe): I'll add more here in other CLs. | 610 // TODO(ahe): I'll add more here in other CLs. |
610 } | 611 } |
OLD | NEW |