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

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: Merge. 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 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 if (node.catchBlocks.isEmpty() && node.finallyBlock == null) { 1839 if (node.catchBlocks.isEmpty() && node.finallyBlock == null) {
1840 // TODO(ngeoffray): The precise location is 1840 // TODO(ngeoffray): The precise location is
1841 // node.getEndtoken.next. Adjust when issue #1581 is fixed. 1841 // node.getEndtoken.next. Adjust when issue #1581 is fixed.
1842 error(node, MessageKind.NO_CATCH_NOR_FINALLY); 1842 error(node, MessageKind.NO_CATCH_NOR_FINALLY);
1843 } 1843 }
1844 visit(node.catchBlocks); 1844 visit(node.catchBlocks);
1845 visit(node.finallyBlock); 1845 visit(node.finallyBlock);
1846 } 1846 }
1847 1847
1848 visitCatchBlock(CatchBlock node) { 1848 visitCatchBlock(CatchBlock node) {
1849 Scope blockScope = new BlockScope(scope); 1849 // Check that the catch has one or two formal parameters.
1850 if (node.formals.isEmpty()) { 1850 if (node.formals.isEmpty()) {
1851 error(node, MessageKind.EMPTY_CATCH_DECLARATION); 1851 error(node, MessageKind.EMPTY_CATCH_DECLARATION);
1852 } else if (!node.formals.nodes.tail.isEmpty() 1852 } else if (!node.formals.nodes.tail.isEmpty()
1853 && !node.formals.nodes.tail.tail.isEmpty()) { 1853 && !node.formals.nodes.tail.tail.isEmpty()) {
1854 for (Node extra in node.formals.nodes.tail.tail) { 1854 for (Node extra in node.formals.nodes.tail.tail) {
1855 error(extra, MessageKind.EXTRA_CATCH_DECLARATION); 1855 error(extra, MessageKind.EXTRA_CATCH_DECLARATION);
1856 } 1856 }
1857 } 1857 }
1858
1859 // Check that the formals aren't optional and that they have no
1860 // modifiers or type.
1861 for (Link<Node> link = node.formals.nodes;
1862 !link.isEmpty();
1863 link = link.tail) {
1864 // If the formal parameter is a node list, it means that it is a
1865 // sequence of optional parameters.
1866 NodeList nodeList = link.head.asNodeList();
1867 if (nodeList !== null) {
1868 error(nodeList, MessageKind.OPTIONAL_PARAMETER_IN_CATCH);
1869 } else {
1870 VariableDefinitions declaration = link.head;
1871 for (Node modifier in declaration.modifiers.nodes) {
1872 error(modifier, MessageKind.PARAMETER_WITH_MODIFIER_IN_CATCH);
1873 }
1874 TypeAnnotation type = declaration.type;
1875 if (type !== null) {
1876 error(type, MessageKind.PARAMETER_WITH_TYPE_IN_CATCH);
1877 }
1878 }
1879 }
1880
1881 Scope blockScope = new BlockScope(scope);
1858 visitIn(node.type, blockScope); 1882 visitIn(node.type, blockScope);
1859 visitIn(node.formals, blockScope); 1883 visitIn(node.formals, blockScope);
1860 visitIn(node.block, blockScope); 1884 visitIn(node.block, blockScope);
1861 } 1885 }
1862 1886
1863 visitTypedef(Typedef node) { 1887 visitTypedef(Typedef node) {
1864 unimplemented(node, 'typedef'); 1888 unimplemented(node, 'typedef');
1865 } 1889 }
1866 } 1890 }
1867 1891
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 TopScope(LibraryElement library) : super(null, library); 2660 TopScope(LibraryElement library) : super(null, library);
2637 Element lookup(SourceString name) { 2661 Element lookup(SourceString name) {
2638 return library.find(name); 2662 return library.find(name);
2639 } 2663 }
2640 2664
2641 Element add(Element newElement) { 2665 Element add(Element newElement) {
2642 throw "Cannot add an element in the top scope"; 2666 throw "Cannot add an element in the top scope";
2643 } 2667 }
2644 String toString() => '$element'; 2668 String toString() => '$element';
2645 } 2669 }
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