Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 part of dart2js.semantics_visitor; | 5 part of dart2js.semantics_visitor; |
| 6 | 6 |
| 7 enum SendStructureKind { | 7 enum SendStructureKind { |
| 8 GET, | 8 GET, |
| 9 SET, | 9 SET, |
| 10 INVOKE, | 10 INVOKE, |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 } | 262 } |
| 263 } else if (!node.isPropertyAccess) { | 263 } else if (!node.isPropertyAccess) { |
| 264 kind = SendStructureKind.INVOKE; | 264 kind = SendStructureKind.INVOKE; |
| 265 } else { | 265 } else { |
| 266 kind = SendStructureKind.GET; | 266 kind = SendStructureKind.GET; |
| 267 } | 267 } |
| 268 | 268 |
| 269 if (node.isOperator) { | 269 if (node.isOperator) { |
| 270 String operatorText = node.selector.asOperator().source; | 270 String operatorText = node.selector.asOperator().source; |
| 271 if (node.arguments.isEmpty) { | 271 if (node.arguments.isEmpty) { |
| 272 unaryOperator = UnaryOperator.parse(operatorText); | 272 return internalError(node, "Unexpected unary $operatorText."); |
| 273 if (unaryOperator != null) { | |
| 274 switch (unaryOperator.kind) { | |
| 275 case UnaryOperatorKind.NOT: | |
| 276 kind = SendStructureKind.NOT; | |
| 277 break; | |
| 278 default: | |
| 279 kind = SendStructureKind.UNARY; | |
| 280 break; | |
| 281 } | |
| 282 } else { | |
| 283 return const InvalidUnaryStructure(); | |
| 284 } | |
| 285 } else { | 273 } else { |
| 286 binaryOperator = BinaryOperator.parse(operatorText); | 274 binaryOperator = BinaryOperator.parse(operatorText); |
| 287 if (binaryOperator != null) { | 275 if (binaryOperator != null) { |
| 288 switch (binaryOperator.kind) { | 276 switch (binaryOperator.kind) { |
| 289 case BinaryOperatorKind.EQ: | 277 case BinaryOperatorKind.EQ: |
| 290 kind = SendStructureKind.EQ; | 278 kind = SendStructureKind.EQ; |
| 291 break; | 279 return internalError(node, "Unexpected binary $kind."); |
|
karlklose
2015/05/29 11:12:14
Move 'return internalError' after the switch?
Johnni Winther
2015/05/29 12:47:54
We still need to index in compounds.
| |
| 292 case BinaryOperatorKind.NOT_EQ: | 280 case BinaryOperatorKind.NOT_EQ: |
| 293 if (node.isSuperCall) { | |
| 294 // `super != foo` is a compile-time error. | |
| 295 return const InvalidBinaryStructure(); | |
| 296 } | |
| 297 kind = SendStructureKind.NOT_EQ; | 281 kind = SendStructureKind.NOT_EQ; |
| 298 break; | 282 return internalError(node, "Unexpected binary $kind."); |
| 299 case BinaryOperatorKind.INDEX: | 283 case BinaryOperatorKind.INDEX: |
| 300 if (node.isPrefix) { | 284 if (node.isPrefix) { |
| 301 kind = SendStructureKind.INDEX_PREFIX; | 285 kind = SendStructureKind.INDEX_PREFIX; |
| 302 } else if (node.isPostfix) { | 286 } else if (node.isPostfix) { |
| 303 kind = SendStructureKind.INDEX_POSTFIX; | 287 kind = SendStructureKind.INDEX_POSTFIX; |
| 304 } else if (node.arguments.tail.isEmpty) { | 288 } else if (node.arguments.tail.isEmpty) { |
| 305 // a[b] | 289 // a[b] |
| 306 kind = SendStructureKind.INDEX; | 290 kind = SendStructureKind.INDEX; |
| 291 return internalError(node, "Unexpected binary $kind."); | |
| 307 } else { | 292 } else { |
| 308 if (kind == SendStructureKind.COMPOUND) { | 293 if (kind == SendStructureKind.COMPOUND) { |
| 309 // a[b] += c | 294 // a[b] += c |
| 310 kind = SendStructureKind.COMPOUND_INDEX_SET; | 295 kind = SendStructureKind.COMPOUND_INDEX_SET; |
| 311 } else { | 296 } else { |
| 312 // a[b] = c | 297 // a[b] = c |
| 313 kind = SendStructureKind.INDEX_SET; | 298 kind = SendStructureKind.INDEX_SET; |
| 314 } | 299 } |
| 315 } | 300 } |
| 316 break; | 301 break; |
| 317 default: | 302 default: |
| 318 kind = SendStructureKind.BINARY; | 303 kind = SendStructureKind.BINARY; |
| 319 break; | 304 return internalError(node, "Unexpected binary $kind."); |
| 320 } | 305 } |
| 321 } else { | 306 } else { |
| 322 return const InvalidBinaryStructure(); | 307 return internalError( |
| 308 node, "Unexpected invalid binary $operatorText."); | |
| 323 } | 309 } |
| 324 } | 310 } |
| 325 } | 311 } |
| 326 AccessSemantics semantics = computeAccessSemantics( | 312 AccessSemantics semantics = computeAccessSemantics( |
| 327 node, | 313 node, |
| 328 isSet: kind == SendStructureKind.SET, | 314 isSet: kind == SendStructureKind.SET, |
| 329 isInvoke: kind == SendStructureKind.INVOKE, | 315 isInvoke: kind == SendStructureKind.INVOKE, |
| 330 isCompound: kind == SendStructureKind.COMPOUND || | 316 isCompound: kind == SendStructureKind.COMPOUND || |
| 331 kind == SendStructureKind.COMPOUND_INDEX_SET || | 317 kind == SendStructureKind.COMPOUND_INDEX_SET || |
| 332 kind == SendStructureKind.PREFIX || | 318 kind == SendStructureKind.PREFIX || |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 return internalError(node, "Unexpected variable $element."); | 924 return internalError(node, "Unexpected variable $element."); |
| 939 } | 925 } |
| 940 if (element.isConst) { | 926 if (element.isConst) { |
| 941 ConstantExpression constant = elements.getConstant(element.initializer); | 927 ConstantExpression constant = elements.getConstant(element.initializer); |
| 942 return new ConstantVariableStructure(kind, node, element, constant); | 928 return new ConstantVariableStructure(kind, node, element, constant); |
| 943 } else { | 929 } else { |
| 944 return new NonConstantVariableStructure(kind, node, element); | 930 return new NonConstantVariableStructure(kind, node, element); |
| 945 } | 931 } |
| 946 } | 932 } |
| 947 } | 933 } |
| OLD | NEW |