| 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 Type getType(TypeAnnotation annotation); | 8 Type getType(TypeAnnotation annotation); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 Type useType(TypeAnnotation annotation, Type type) { | 928 Type useType(TypeAnnotation annotation, Type type) { |
| 929 if (type !== null) { | 929 if (type !== null) { |
| 930 mapping.setType(annotation, type); | 930 mapping.setType(annotation, type); |
| 931 useElement(annotation, type.element); | 931 useElement(annotation, type.element); |
| 932 } | 932 } |
| 933 return type; | 933 return type; |
| 934 } | 934 } |
| 935 | 935 |
| 936 void setupFunction(FunctionExpression node, FunctionElement function) { | 936 void setupFunction(FunctionExpression node, FunctionElement function) { |
| 937 context = new MethodScope(context, function); | 937 context = new MethodScope(context, function); |
| 938 if (node.returnType !== null) resolveTypeAnnotation(node.returnType); |
| 938 // Put the parameters in scope. | 939 // Put the parameters in scope. |
| 939 FunctionSignature functionParameters = | 940 FunctionSignature functionParameters = |
| 940 function.computeSignature(compiler); | 941 function.computeSignature(compiler); |
| 941 Link<Node> parameterNodes = node.parameters.nodes; | 942 Link<Node> parameterNodes = node.parameters.nodes; |
| 942 functionParameters.forEachParameter((Element element) { | 943 functionParameters.forEachParameter((Element element) { |
| 943 if (element == functionParameters.optionalParameters.head) { | 944 if (element == functionParameters.optionalParameters.head) { |
| 944 NodeList nodes = parameterNodes.head; | 945 NodeList nodes = parameterNodes.head; |
| 945 parameterNodes = nodes.nodes; | 946 parameterNodes = nodes.nodes; |
| 946 } | 947 } |
| 947 VariableDefinitions variableDefinitions = parameterNodes.head; | 948 VariableDefinitions variableDefinitions = parameterNodes.head; |
| 948 Node parameterNode = variableDefinitions.definitions.nodes.head; | 949 Node parameterNode = variableDefinitions.definitions.nodes.head; |
| 950 if (variableDefinitions.type !== null) { |
| 951 resolveTypeAnnotation(variableDefinitions.type); |
| 952 } |
| 949 initializerDo(parameterNode, (n) => n.accept(this)); | 953 initializerDo(parameterNode, (n) => n.accept(this)); |
| 950 // Field parameters (this.x) are not visible inside the constructor. The | 954 // Field parameters (this.x) are not visible inside the constructor. The |
| 951 // fields they reference are visible, but must be resolved independently. | 955 // fields they reference are visible, but must be resolved independently. |
| 952 if (element.kind == ElementKind.FIELD_PARAMETER) { | 956 if (element.kind == ElementKind.FIELD_PARAMETER) { |
| 953 useElement(parameterNode, element); | 957 useElement(parameterNode, element); |
| 954 } else { | 958 } else { |
| 955 defineElement(variableDefinitions.definitions.nodes.head, element); | 959 defineElement(variableDefinitions.definitions.nodes.head, element); |
| 956 } | 960 } |
| 957 parameterNodes = parameterNodes.tail; | 961 parameterNodes = parameterNodes.tail; |
| 958 }); | 962 }); |
| (...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 | 2209 |
| 2206 TopScope(LibraryElement library) : super(null, library); | 2210 TopScope(LibraryElement library) : super(null, library); |
| 2207 Element lookup(SourceString name) { | 2211 Element lookup(SourceString name) { |
| 2208 return library.find(name); | 2212 return library.find(name); |
| 2209 } | 2213 } |
| 2210 | 2214 |
| 2211 Element add(Element newElement) { | 2215 Element add(Element newElement) { |
| 2212 throw "Cannot add an element in the top scope"; | 2216 throw "Cannot add an element in the top scope"; |
| 2213 } | 2217 } |
| 2214 } | 2218 } |
| OLD | NEW |