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

Side by Side Diff: lib/compiler/implementation/resolver.dart

Issue 10917070: Disallow legacy try-catch syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve testing. Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/compiler/implementation/warnings.dart » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 interface TreeElements { 5 interface TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 DartType getType(TypeAnnotation annotation); 8 DartType getType(TypeAnnotation annotation);
9 } 9 }
10 10
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 if (node.catchBlocks.isEmpty() && node.finallyBlock == null) { 1827 if (node.catchBlocks.isEmpty() && node.finallyBlock == null) {
1828 // TODO(ngeoffray): The precise location is 1828 // TODO(ngeoffray): The precise location is
1829 // node.getEndtoken.next. Adjust when issue #1581 is fixed. 1829 // node.getEndtoken.next. Adjust when issue #1581 is fixed.
1830 error(node, MessageKind.NO_CATCH_NOR_FINALLY); 1830 error(node, MessageKind.NO_CATCH_NOR_FINALLY);
1831 } 1831 }
1832 visit(node.catchBlocks); 1832 visit(node.catchBlocks);
1833 visit(node.finallyBlock); 1833 visit(node.finallyBlock);
1834 } 1834 }
1835 1835
1836 visitCatchBlock(CatchBlock node) { 1836 visitCatchBlock(CatchBlock node) {
1837 Scope blockScope = new BlockScope(scope); 1837 // Check that the catch have one or two formal parameters.
karlklose 2012/09/04 10:27:02 'have' -> 'has'.
1838 if (node.formals.isEmpty()) { 1838 if (node.formals.isEmpty()) {
1839 error(node, MessageKind.EMPTY_CATCH_DECLARATION); 1839 error(node, MessageKind.EMPTY_CATCH_DECLARATION);
1840 } else if (!node.formals.nodes.tail.isEmpty() 1840 } else if (!node.formals.nodes.tail.isEmpty()
1841 && !node.formals.nodes.tail.tail.isEmpty()) { 1841 && !node.formals.nodes.tail.tail.isEmpty()) {
1842 for (Node extra in node.formals.nodes.tail.tail) { 1842 for (Node extra in node.formals.nodes.tail.tail) {
1843 error(extra, MessageKind.EXTRA_CATCH_DECLARATION); 1843 error(extra, MessageKind.EXTRA_CATCH_DECLARATION);
1844 } 1844 }
1845 } 1845 }
1846
1847 // Check that the formals aren't optional and that they have no
1848 // modifiers or type.
1849 for (Link<Node> link = node.formals.nodes;
1850 !link.isEmpty();
1851 link = link.tail) {
1852 // If the formal parameter is a node list, it means that it is a
1853 // sequence of optional parameters.
1854 NodeList nodeList = link.head.asNodeList();
1855 if (nodeList !== null) {
1856 error(nodeList, MessageKind.OPTIONAL_PARAMETER_IN_CATCH);
1857 } else {
1858 VariableDefinitions declaration = link.head;
1859 for (Node modifier in declaration.modifiers.nodes) {
1860 error(modifier, MessageKind.PARAMETER_WITH_MODIFIER_IN_CATCH);
1861 }
1862 TypeAnnotation type = declaration.type;
1863 if (type !== null) {
1864 error(type, MessageKind.PARAMETER_WITH_TYPE_IN_CATCH);
1865 }
1866 }
1867 }
1868
1869 Scope blockScope = new BlockScope(scope);
1846 visitIn(node.type, blockScope); 1870 visitIn(node.type, blockScope);
1847 visitIn(node.formals, blockScope); 1871 visitIn(node.formals, blockScope);
1848 visitIn(node.block, blockScope); 1872 visitIn(node.block, blockScope);
1849 } 1873 }
1850 1874
1851 visitTypedef(Typedef node) { 1875 visitTypedef(Typedef node) {
1852 unimplemented(node, 'typedef'); 1876 unimplemented(node, 'typedef');
1853 } 1877 }
1854 } 1878 }
1855 1879
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 TopScope(LibraryElement library) : super(null, library); 2648 TopScope(LibraryElement library) : super(null, library);
2625 Element lookup(SourceString name) { 2649 Element lookup(SourceString name) {
2626 return library.find(name); 2650 return library.find(name);
2627 } 2651 }
2628 2652
2629 Element add(Element newElement) { 2653 Element add(Element newElement) {
2630 throw "Cannot add an element in the top scope"; 2654 throw "Cannot add an element in the top scope";
2631 } 2655 }
2632 String toString() => '$element'; 2656 String toString() => '$element';
2633 } 2657 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698