OLD | NEW |
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 } | 8 } |
9 | 9 |
10 class TreeElementMapping implements TreeElements { | 10 class TreeElementMapping implements TreeElements { |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 | 849 |
850 visitNamedArgument(NamedArgument node) { | 850 visitNamedArgument(NamedArgument node) { |
851 visit(node.expression); | 851 visit(node.expression); |
852 } | 852 } |
853 | 853 |
854 visitSwitchStatement(SwitchStatement node) { | 854 visitSwitchStatement(SwitchStatement node) { |
855 unimplemented(node, 'switch'); | 855 unimplemented(node, 'switch'); |
856 } | 856 } |
857 | 857 |
858 visitTryStatement(TryStatement node) { | 858 visitTryStatement(TryStatement node) { |
859 unimplemented(node, 'try'); | 859 visit(node.tryBlock); |
| 860 if (node.catchBlocks.isEmpty() && node.finallyBlock == null) { |
| 861 // TODO(ngeoffray): The precise location is |
| 862 // node.getEndtoken.next. Adjust when issue #1581 is fixed. |
| 863 error(node, MessageKind.NO_CATCH_NOR_FINALLY); |
| 864 } |
| 865 visit(node.catchBlocks); |
| 866 visit(node.finallyBlock); |
860 } | 867 } |
861 | 868 |
862 visitCatchBlock(CatchBlock node) { | 869 visitCatchBlock(CatchBlock node) { |
863 unimplemented(node, 'catch'); | 870 Scope scope = new BlockScope(context); |
| 871 if (node.formals.isEmpty()) { |
| 872 error(node, MessageKind.EMPTY_CATCH_DECLARATION); |
| 873 } else if (!node.formals.nodes.tail.isEmpty() |
| 874 && !node.formals.nodes.tail.tail.isEmpty()) { |
| 875 for (Node extra in node.formals.nodes.tail.tail) { |
| 876 error(extra, MessageKind.EXTRA_CATCH_DECLARATION); |
| 877 } |
| 878 } |
| 879 visitIn(node.formals, scope); |
| 880 visitIn(node.block, scope); |
864 } | 881 } |
865 | 882 |
866 visitTypedef(Typedef node) { | 883 visitTypedef(Typedef node) { |
867 unimplemented(node, 'typedef'); | 884 unimplemented(node, 'typedef'); |
868 } | 885 } |
869 } | 886 } |
870 | 887 |
871 class ClassResolverVisitor extends CommonResolverVisitor<Type> { | 888 class ClassResolverVisitor extends CommonResolverVisitor<Type> { |
872 Scope context; | 889 Scope context; |
873 | 890 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 class TopScope extends Scope { | 1164 class TopScope extends Scope { |
1148 LibraryElement get library() => element; | 1165 LibraryElement get library() => element; |
1149 | 1166 |
1150 TopScope(LibraryElement library) : super(null, library); | 1167 TopScope(LibraryElement library) : super(null, library); |
1151 Element lookup(SourceString name) => library.find(name); | 1168 Element lookup(SourceString name) => library.find(name); |
1152 | 1169 |
1153 Element add(Element element) { | 1170 Element add(Element element) { |
1154 throw "Cannot add an element in the top scope"; | 1171 throw "Cannot add an element in the top scope"; |
1155 } | 1172 } |
1156 } | 1173 } |
OLD | NEW |