| 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 DartType getType(TypeAnnotation annotation); | 8 DartType getType(TypeAnnotation annotation); |
| 9 bool isParameterChecked(Element element); | 9 bool isParameterChecked(Element element); |
| 10 } | 10 } |
| (...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 if (node.catchBlocks.isEmpty() && node.finallyBlock == null) { | 1900 if (node.catchBlocks.isEmpty() && node.finallyBlock == null) { |
| 1901 // TODO(ngeoffray): The precise location is | 1901 // TODO(ngeoffray): The precise location is |
| 1902 // node.getEndtoken.next. Adjust when issue #1581 is fixed. | 1902 // node.getEndtoken.next. Adjust when issue #1581 is fixed. |
| 1903 error(node, MessageKind.NO_CATCH_NOR_FINALLY); | 1903 error(node, MessageKind.NO_CATCH_NOR_FINALLY); |
| 1904 } | 1904 } |
| 1905 visit(node.catchBlocks); | 1905 visit(node.catchBlocks); |
| 1906 visit(node.finallyBlock); | 1906 visit(node.finallyBlock); |
| 1907 } | 1907 } |
| 1908 | 1908 |
| 1909 visitCatchBlock(CatchBlock node) { | 1909 visitCatchBlock(CatchBlock node) { |
| 1910 // Check that the catch has one or two formal parameters. | 1910 // Check that if catch part is present, then |
| 1911 if (node.formals.isEmpty()) { | 1911 // it has one or two formal parameters. |
| 1912 error(node, MessageKind.EMPTY_CATCH_DECLARATION); | 1912 if (node.formals !== null) { |
| 1913 } else if (!node.formals.nodes.tail.isEmpty() | 1913 if (node.formals.isEmpty()) { |
| 1914 && !node.formals.nodes.tail.tail.isEmpty()) { | 1914 error(node, MessageKind.EMPTY_CATCH_DECLARATION); |
| 1915 for (Node extra in node.formals.nodes.tail.tail) { | |
| 1916 error(extra, MessageKind.EXTRA_CATCH_DECLARATION); | |
| 1917 } | 1915 } |
| 1918 } | 1916 if (!node.formals.nodes.tail.isEmpty() && |
| 1917 !node.formals.nodes.tail.tail.isEmpty()) { |
| 1918 for (Node extra in node.formals.nodes.tail.tail) { |
| 1919 error(extra, MessageKind.EXTRA_CATCH_DECLARATION); |
| 1920 } |
| 1921 } |
| 1919 | 1922 |
| 1920 // Check that the formals aren't optional and that they have no | 1923 // Check that the formals aren't optional and that they have no |
| 1921 // modifiers or type. | 1924 // modifiers or type. |
| 1922 for (Link<Node> link = node.formals.nodes; | 1925 for (Link<Node> link = node.formals.nodes; |
| 1923 !link.isEmpty(); | 1926 !link.isEmpty(); |
| 1924 link = link.tail) { | 1927 link = link.tail) { |
| 1925 // If the formal parameter is a node list, it means that it is a | 1928 // If the formal parameter is a node list, it means that it is a |
| 1926 // sequence of optional parameters. | 1929 // sequence of optional parameters. |
| 1927 NodeList nodeList = link.head.asNodeList(); | 1930 NodeList nodeList = link.head.asNodeList(); |
| 1928 if (nodeList !== null) { | 1931 if (nodeList !== null) { |
| 1929 error(nodeList, MessageKind.OPTIONAL_PARAMETER_IN_CATCH); | 1932 error(nodeList, MessageKind.OPTIONAL_PARAMETER_IN_CATCH); |
| 1930 } else { | 1933 } else { |
| 1931 VariableDefinitions declaration = link.head; | 1934 VariableDefinitions declaration = link.head; |
| 1932 for (Node modifier in declaration.modifiers.nodes) { | 1935 for (Node modifier in declaration.modifiers.nodes) { |
| 1933 error(modifier, MessageKind.PARAMETER_WITH_MODIFIER_IN_CATCH); | 1936 error(modifier, MessageKind.PARAMETER_WITH_MODIFIER_IN_CATCH); |
| 1934 } | 1937 } |
| 1935 TypeAnnotation type = declaration.type; | 1938 TypeAnnotation type = declaration.type; |
| 1936 if (type !== null) { | 1939 if (type !== null) { |
| 1937 error(type, MessageKind.PARAMETER_WITH_TYPE_IN_CATCH); | 1940 error(type, MessageKind.PARAMETER_WITH_TYPE_IN_CATCH); |
| 1941 } |
| 1938 } | 1942 } |
| 1939 } | 1943 } |
| 1940 } | 1944 } |
| 1941 | 1945 |
| 1942 Scope blockScope = new BlockScope(scope); | 1946 Scope blockScope = new BlockScope(scope); |
| 1943 var wasTypeRequired = typeRequired; | 1947 var wasTypeRequired = typeRequired; |
| 1944 typeRequired = true; | 1948 typeRequired = true; |
| 1945 doInCheckContext(() => visitIn(node.type, blockScope)); | 1949 doInCheckContext(() => visitIn(node.type, blockScope)); |
| 1946 typeRequired = wasTypeRequired; | 1950 typeRequired = wasTypeRequired; |
| 1947 visitIn(node.formals, blockScope); | 1951 visitIn(node.formals, blockScope); |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 | 2760 |
| 2757 Element localLookup(SourceString name) => library.find(name); | 2761 Element localLookup(SourceString name) => library.find(name); |
| 2758 Element lookup(SourceString name) => localLookup(name); | 2762 Element lookup(SourceString name) => localLookup(name); |
| 2759 Element lexicalLookup(SourceString name) => localLookup(name); | 2763 Element lexicalLookup(SourceString name) => localLookup(name); |
| 2760 | 2764 |
| 2761 Element add(Element newElement) { | 2765 Element add(Element newElement) { |
| 2762 throw "Cannot add an element in the top scope"; | 2766 throw "Cannot add an element in the top scope"; |
| 2763 } | 2767 } |
| 2764 String toString() => '$element'; | 2768 String toString() => '$element'; |
| 2765 } | 2769 } |
| OLD | NEW |