Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library analyzer2dart.semantic_visitor; | 5 library analyzer2dart.semantic_visitor; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
| 9 | 9 |
| 10 import 'util.dart'; | 10 import 'util.dart'; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 @override | 74 @override |
| 75 R visitMethodInvocation(MethodInvocation node) { | 75 R visitMethodInvocation(MethodInvocation node) { |
| 76 if (node.target != null) { | 76 if (node.target != null) { |
| 77 node.target.accept(this); | 77 node.target.accept(this); |
| 78 } | 78 } |
| 79 node.argumentList.accept(this); | 79 node.argumentList.accept(this); |
| 80 return handleMethodInvocation(node); | 80 return handleMethodInvocation(node); |
| 81 } | 81 } |
| 82 | 82 |
| 83 R handleMethodInvocation(MethodInvocation node) { | 83 R handleMethodInvocation(MethodInvocation node) { |
| 84 AccessSemantics semantics = classifyMethodInvocation(node); | 84 AccessSemantics semantics = node.accept(ACCESS_SEMANTICS_VISITOR); |
| 85 switch (semantics.kind) { | 85 switch (semantics.kind) { |
| 86 case AccessKind.DYNAMIC: | 86 case AccessKind.DYNAMIC: |
| 87 return visitDynamicInvocation(node, semantics); | 87 return visitDynamicInvocation(node, semantics); |
| 88 case AccessKind.LOCAL_FUNCTION: | 88 case AccessKind.LOCAL_FUNCTION: |
| 89 return visitLocalFunctionInvocation(node, semantics); | 89 return visitLocalFunctionInvocation(node, semantics); |
| 90 case AccessKind.LOCAL_VARIABLE: | 90 case AccessKind.LOCAL_VARIABLE: |
| 91 return visitLocalVariableInvocation(node, semantics); | 91 return visitLocalVariableInvocation(node, semantics); |
| 92 case AccessKind.PARAMETER: | 92 case AccessKind.PARAMETER: |
| 93 return visitParameterInvocation(node, semantics); | 93 return visitParameterInvocation(node, semantics); |
| 94 case AccessKind.STATIC_FIELD: | 94 case AccessKind.STATIC_FIELD: |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 106 | 106 |
| 107 @override | 107 @override |
| 108 R visitPropertyAccess(PropertyAccess node) { | 108 R visitPropertyAccess(PropertyAccess node) { |
| 109 if (node.target != null) { | 109 if (node.target != null) { |
| 110 node.target.accept(this); | 110 node.target.accept(this); |
| 111 } | 111 } |
| 112 return handlePropertyAccess(node); | 112 return handlePropertyAccess(node); |
| 113 } | 113 } |
| 114 | 114 |
| 115 R handlePropertyAccess(PropertyAccess node) { | 115 R handlePropertyAccess(PropertyAccess node) { |
| 116 return _handlePropertyAccess(node, classifyPropertyAccess(node)); | 116 return _handlePropertyAccess(node, node.accept(ACCESS_SEMANTICS_VISITOR)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 @override | 119 @override |
| 120 R visitPrefixedIdentifier(PrefixedIdentifier node) { | 120 R visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 121 node.prefix.accept(this); | 121 node.prefix.accept(this); |
| 122 return handlePrefixedIdentifier(node); | 122 return handlePrefixedIdentifier(node); |
| 123 } | 123 } |
| 124 | 124 |
| 125 R handlePrefixedIdentifier(PrefixedIdentifier node) { | 125 R handlePrefixedIdentifier(PrefixedIdentifier node) { |
| 126 return _handlePropertyAccess(node, classifyPrefixedIdentifier(node)); | 126 return _handlePropertyAccess(node, node.accept(ACCESS_SEMANTICS_VISITOR)); |
| 127 } | 127 } |
| 128 | 128 |
| 129 @override | 129 @override |
| 130 R visitSimpleIdentifier(SimpleIdentifier node) { | 130 R visitSimpleIdentifier(SimpleIdentifier node) { |
| 131 AccessSemantics semantics = classifySimpleIdentifier(node); | 131 AccessSemantics semantics = node.accept(ACCESS_SEMANTICS_VISITOR); |
| 132 if (semantics != null) { | 132 if (semantics != null) { |
| 133 return _handlePropertyAccess(node, semantics); | 133 return _handlePropertyAccess(node, semantics); |
| 134 } else { | 134 } else { |
| 135 return null; | 135 return null; |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 R visitDynamicAccess(AstNode node, AccessSemantics semantics) { | 139 R visitDynamicAccess(AstNode node, AccessSemantics semantics) { |
| 140 return giveUp(node, 'visitDynamicAccess of $semantics'); | 140 return giveUp(node, 'visitDynamicAccess of $semantics'); |
| 141 } | 141 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 case AccessKind.STATIC_METHOD: | 179 case AccessKind.STATIC_METHOD: |
| 180 return visitStaticMethodAccess(node, semantics); | 180 return visitStaticMethodAccess(node, semantics); |
| 181 case AccessKind.STATIC_PROPERTY: | 181 case AccessKind.STATIC_PROPERTY: |
| 182 return visitStaticPropertyAccess(node, semantics); | 182 return visitStaticPropertyAccess(node, semantics); |
| 183 default: | 183 default: |
| 184 // Unexpected access kind. | 184 // Unexpected access kind. |
| 185 return giveUp(node, | 185 return giveUp(node, |
| 186 'Unexpected ${semantics} in _handlePropertyAccess.'); | 186 'Unexpected ${semantics} in _handlePropertyAccess.'); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | |
| 190 // TODO(johnniwinther,paulberry): Is this a real thing? | |
|
Paul Berry
2014/10/27 14:15:56
This will only happen if the call
node.leftHand
Johnni Winther
2014/10/27 14:26:18
Ahh. We need an AccessSemantics for index operatio
| |
| 191 R visitDynamicAssignment(AssignmentExpression node) { | |
| 192 return giveUp(node, 'visitDynamicAssignment'); | |
| 193 } | |
| 194 | |
| 195 R visitDynamicPropertyAssignment(AssignmentExpression node, | |
| 196 AccessSemantics semantics) { | |
| 197 return giveUp(node, 'visitDynamicPropertyAssignment of $semantics'); | |
| 198 } | |
| 199 | |
| 200 R visitLocalFunctionAssignment(AssignmentExpression node, | |
| 201 AccessSemantics semantics) { | |
| 202 return giveUp(node, 'visitLocalFunctionAssignment of $semantics'); | |
| 203 } | |
| 204 | |
| 205 R visitLocalVariableAssignment(AssignmentExpression node, | |
| 206 AccessSemantics semantics) { | |
| 207 return giveUp(node, 'visitLocalVariableAssignment of $semantics'); | |
| 208 } | |
| 209 | |
| 210 R visitParameterAssignment(AssignmentExpression node, | |
| 211 AccessSemantics semantics) { | |
| 212 return giveUp(node, 'visitParameterAssignment of $semantics'); | |
| 213 } | |
| 214 | |
| 215 R visitStaticFieldAssignment(AssignmentExpression node, | |
| 216 AccessSemantics semantics) { | |
| 217 return giveUp(node, 'visitStaticFieldAssignment of $semantics'); | |
| 218 } | |
| 219 | |
| 220 R visitStaticMethodAssignment(AssignmentExpression node, | |
| 221 AccessSemantics semantics) { | |
| 222 return giveUp(node, 'visitStaticMethodAssignment of $semantics'); | |
| 223 } | |
| 224 | |
| 225 R visitStaticPropertyAssignment(AssignmentExpression node, | |
| 226 AccessSemantics semantics) { | |
| 227 return giveUp(node, 'visitStaticPropertyAssignment of $semantics'); | |
| 228 } | |
| 229 | |
| 230 @override | |
| 231 R visitAssignmentExpression(AssignmentExpression node) { | |
| 232 super.visitAssignmentExpression(node); | |
| 233 return handleAssignmentExpression(node); | |
| 234 } | |
| 235 | |
| 236 R handleAssignmentExpression(AssignmentExpression node) { | |
| 237 AccessSemantics semantics = | |
| 238 node.leftHandSide.accept(ACCESS_SEMANTICS_VISITOR); | |
| 239 if (semantics == null) { | |
| 240 return visitDynamicAssignment(node); | |
| 241 } else { | |
| 242 switch (semantics.kind) { | |
| 243 case AccessKind.DYNAMIC: | |
| 244 return visitDynamicPropertyAssignment(node, semantics); | |
| 245 case AccessKind.LOCAL_FUNCTION: | |
| 246 return visitLocalFunctionAssignment(node, semantics); | |
| 247 case AccessKind.LOCAL_VARIABLE: | |
| 248 return visitLocalVariableAssignment(node, semantics); | |
| 249 case AccessKind.PARAMETER: | |
| 250 return visitParameterAssignment(node, semantics); | |
| 251 case AccessKind.STATIC_FIELD: | |
| 252 return visitStaticFieldAssignment(node, semantics); | |
| 253 case AccessKind.STATIC_METHOD: | |
| 254 return visitStaticMethodAssignment(node, semantics); | |
| 255 case AccessKind.STATIC_PROPERTY: | |
| 256 return visitStaticPropertyAssignment(node, semantics); | |
| 257 default: | |
| 258 // Unexpected access kind. | |
| 259 return giveUp(node, | |
| 260 'Unexpected ${semantics} in _handlePropertyAccess.'); | |
| 261 } | |
| 262 } | |
| 263 } | |
| 189 } | 264 } |
| OLD | NEW |