| 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 library elements; | 5 library elements; |
| 6 | 6 |
| 7 | 7 |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../tree/tree.dart'; | 9 import '../tree/tree.dart'; |
| 10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 static bool isNativeOrExtendsNative(ClassElement element) { | 525 static bool isNativeOrExtendsNative(ClassElement element) { |
| 526 if (element == null) return false; | 526 if (element == null) return false; |
| 527 if (element.isNative) return true; | 527 if (element.isNative) return true; |
| 528 assert(element.resolutionState == STATE_DONE); | 528 assert(element.resolutionState == STATE_DONE); |
| 529 return isNativeOrExtendsNative(element.superclass); | 529 return isNativeOrExtendsNative(element.superclass); |
| 530 } | 530 } |
| 531 | 531 |
| 532 static bool isInstanceSend(Send send, TreeElements elements) { | 532 static bool isInstanceSend(Send send, TreeElements elements) { |
| 533 Element element = elements[send]; | 533 Element element = elements[send]; |
| 534 if (element == null) return !isClosureSend(send, element); | 534 if (element == null) return !isClosureSend(send, element); |
| 535 return isInstanceMethod(element) || isInstanceField(element); | 535 return isInstanceMethod(element) || |
| 536 isInstanceField(element) || |
| 537 send.isConditional; |
| 536 } | 538 } |
| 537 | 539 |
| 538 static bool isClosureSend(Send send, Element element) { | 540 static bool isClosureSend(Send send, Element element) { |
| 539 if (send.isPropertyAccess) return false; | 541 if (send.isPropertyAccess) return false; |
| 540 if (send.receiver != null) return false; | 542 if (send.receiver != null) return false; |
| 541 Node selector = send.selector; | 543 Node selector = send.selector; |
| 542 // this(). | 544 // this(). |
| 543 if (selector.isThis()) return true; | 545 if (selector.isThis()) return true; |
| 544 // (o)() or foo()(). | 546 // (o)() or foo()(). |
| 545 if (element == null && selector.asIdentifier() == null) return true; | 547 if (element == null && selector.asIdentifier() == null) return true; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 } else if (identical(name, 'unary-')) { | 635 } else if (identical(name, 'unary-')) { |
| 634 return r'operator$negate'; | 636 return r'operator$negate'; |
| 635 } else { | 637 } else { |
| 636 return name; | 638 return name; |
| 637 } | 639 } |
| 638 } | 640 } |
| 639 | 641 |
| 640 static String constructOperatorNameOrNull(String op, bool isUnary) { | 642 static String constructOperatorNameOrNull(String op, bool isUnary) { |
| 641 if (isMinusOperator(op)) { | 643 if (isMinusOperator(op)) { |
| 642 return isUnary ? 'unary-' : op; | 644 return isUnary ? 'unary-' : op; |
| 643 } else if (isUserDefinableOperator(op)) { | 645 } else if (isUserDefinableOperator(op) || op == '??') { |
| 644 return op; | 646 return op; |
| 645 } else { | 647 } else { |
| 646 return null; | 648 return null; |
| 647 } | 649 } |
| 648 } | 650 } |
| 649 | 651 |
| 650 static String constructOperatorName(String op, bool isUnary) { | 652 static String constructOperatorName(String op, bool isUnary) { |
| 651 String operatorName = constructOperatorNameOrNull(op, isUnary); | 653 String operatorName = constructOperatorNameOrNull(op, isUnary); |
| 652 if (operatorName == null) throw 'Unhandled operator: $op'; | 654 if (operatorName == null) throw 'Unhandled operator: $op'; |
| 653 else return operatorName; | 655 else return operatorName; |
| 654 } | 656 } |
| 655 | 657 |
| 656 static String mapToUserOperatorOrNull(String op) { | 658 static String mapToUserOperatorOrNull(String op) { |
| 657 if (identical(op, '!=')) return '=='; | 659 if (identical(op, '!=')) return '=='; |
| 658 if (identical(op, '*=')) return '*'; | 660 if (identical(op, '*=')) return '*'; |
| 659 if (identical(op, '/=')) return '/'; | 661 if (identical(op, '/=')) return '/'; |
| 660 if (identical(op, '%=')) return '%'; | 662 if (identical(op, '%=')) return '%'; |
| 661 if (identical(op, '~/=')) return '~/'; | 663 if (identical(op, '~/=')) return '~/'; |
| 662 if (identical(op, '+=')) return '+'; | 664 if (identical(op, '+=')) return '+'; |
| 663 if (identical(op, '-=')) return '-'; | 665 if (identical(op, '-=')) return '-'; |
| 664 if (identical(op, '<<=')) return '<<'; | 666 if (identical(op, '<<=')) return '<<'; |
| 665 if (identical(op, '>>=')) return '>>'; | 667 if (identical(op, '>>=')) return '>>'; |
| 666 if (identical(op, '&=')) return '&'; | 668 if (identical(op, '&=')) return '&'; |
| 667 if (identical(op, '^=')) return '^'; | 669 if (identical(op, '^=')) return '^'; |
| 668 if (identical(op, '|=')) return '|'; | 670 if (identical(op, '|=')) return '|'; |
| 671 if (identical(op, '??=')) return '??'; |
| 669 | 672 |
| 670 return null; | 673 return null; |
| 671 } | 674 } |
| 672 | 675 |
| 673 static String mapToUserOperator(String op) { | 676 static String mapToUserOperator(String op) { |
| 674 String userOperator = mapToUserOperatorOrNull(op); | 677 String userOperator = mapToUserOperatorOrNull(op); |
| 675 if (userOperator == null) throw 'Unhandled operator: $op'; | 678 if (userOperator == null) throw 'Unhandled operator: $op'; |
| 676 else return userOperator; | 679 else return userOperator; |
| 677 } | 680 } |
| 678 | 681 |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 bool get isDeclaredByField; | 1649 bool get isDeclaredByField; |
| 1647 | 1650 |
| 1648 /// Returns `true` if this member is abstract. | 1651 /// Returns `true` if this member is abstract. |
| 1649 bool get isAbstract; | 1652 bool get isAbstract; |
| 1650 | 1653 |
| 1651 /// If abstract, [implementation] points to the overridden concrete member, | 1654 /// If abstract, [implementation] points to the overridden concrete member, |
| 1652 /// if any. Otherwise [implementation] points to the member itself. | 1655 /// if any. Otherwise [implementation] points to the member itself. |
| 1653 Member get implementation; | 1656 Member get implementation; |
| 1654 } | 1657 } |
| 1655 | 1658 |
| OLD | NEW |