Chromium Code Reviews| 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) || isInstanceField(element) |
| 536 || send.isConditional; | |
|
Siggi Cherem (dart-lang)
2015/05/22 03:50:49
this is because `A?.foo` is equivalent to `(A).foo
Johnni Winther
2015/05/22 12:39:48
Ack. Format like this:
return isInstanceMethod(el
Siggi Cherem (dart-lang)
2015/05/22 19:49:54
Done.
| |
| 536 } | 537 } |
| 537 | 538 |
| 538 static bool isClosureSend(Send send, Element element) { | 539 static bool isClosureSend(Send send, Element element) { |
| 539 if (send.isPropertyAccess) return false; | 540 if (send.isPropertyAccess) return false; |
| 540 if (send.receiver != null) return false; | 541 if (send.receiver != null) return false; |
| 541 Node selector = send.selector; | 542 Node selector = send.selector; |
| 542 // this(). | 543 // this(). |
| 543 if (selector.isThis()) return true; | 544 if (selector.isThis()) return true; |
| 544 // (o)() or foo()(). | 545 // (o)() or foo()(). |
| 545 if (element == null && selector.asIdentifier() == null) return true; | 546 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-')) { | 634 } else if (identical(name, 'unary-')) { |
| 634 return r'operator$negate'; | 635 return r'operator$negate'; |
| 635 } else { | 636 } else { |
| 636 return name; | 637 return name; |
| 637 } | 638 } |
| 638 } | 639 } |
| 639 | 640 |
| 640 static String constructOperatorNameOrNull(String op, bool isUnary) { | 641 static String constructOperatorNameOrNull(String op, bool isUnary) { |
| 641 if (isMinusOperator(op)) { | 642 if (isMinusOperator(op)) { |
| 642 return isUnary ? 'unary-' : op; | 643 return isUnary ? 'unary-' : op; |
| 643 } else if (isUserDefinableOperator(op)) { | 644 } else if (isUserDefinableOperator(op) || op == '??') { |
| 644 return op; | 645 return op; |
| 645 } else { | 646 } else { |
| 646 return null; | 647 return null; |
| 647 } | 648 } |
| 648 } | 649 } |
| 649 | 650 |
| 650 static String constructOperatorName(String op, bool isUnary) { | 651 static String constructOperatorName(String op, bool isUnary) { |
| 651 String operatorName = constructOperatorNameOrNull(op, isUnary); | 652 String operatorName = constructOperatorNameOrNull(op, isUnary); |
| 652 if (operatorName == null) throw 'Unhandled operator: $op'; | 653 if (operatorName == null) throw 'Unhandled operator: $op'; |
| 653 else return operatorName; | 654 else return operatorName; |
| 654 } | 655 } |
| 655 | 656 |
| 656 static String mapToUserOperatorOrNull(String op) { | 657 static String mapToUserOperatorOrNull(String op) { |
| 657 if (identical(op, '!=')) return '=='; | 658 if (identical(op, '!=')) return '=='; |
| 658 if (identical(op, '*=')) return '*'; | 659 if (identical(op, '*=')) return '*'; |
| 659 if (identical(op, '/=')) return '/'; | 660 if (identical(op, '/=')) return '/'; |
| 660 if (identical(op, '%=')) return '%'; | 661 if (identical(op, '%=')) return '%'; |
| 661 if (identical(op, '~/=')) return '~/'; | 662 if (identical(op, '~/=')) return '~/'; |
| 662 if (identical(op, '+=')) return '+'; | 663 if (identical(op, '+=')) return '+'; |
| 663 if (identical(op, '-=')) return '-'; | 664 if (identical(op, '-=')) return '-'; |
| 664 if (identical(op, '<<=')) return '<<'; | 665 if (identical(op, '<<=')) return '<<'; |
| 665 if (identical(op, '>>=')) return '>>'; | 666 if (identical(op, '>>=')) return '>>'; |
| 666 if (identical(op, '&=')) return '&'; | 667 if (identical(op, '&=')) return '&'; |
| 667 if (identical(op, '^=')) return '^'; | 668 if (identical(op, '^=')) return '^'; |
| 668 if (identical(op, '|=')) return '|'; | 669 if (identical(op, '|=')) return '|'; |
| 670 if (identical(op, '??=')) return '??'; | |
| 669 | 671 |
| 670 return null; | 672 return null; |
| 671 } | 673 } |
| 672 | 674 |
| 673 static String mapToUserOperator(String op) { | 675 static String mapToUserOperator(String op) { |
| 674 String userOperator = mapToUserOperatorOrNull(op); | 676 String userOperator = mapToUserOperatorOrNull(op); |
| 675 if (userOperator == null) throw 'Unhandled operator: $op'; | 677 if (userOperator == null) throw 'Unhandled operator: $op'; |
| 676 else return userOperator; | 678 else return userOperator; |
| 677 } | 679 } |
| 678 | 680 |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1646 bool get isDeclaredByField; | 1648 bool get isDeclaredByField; |
| 1647 | 1649 |
| 1648 /// Returns `true` if this member is abstract. | 1650 /// Returns `true` if this member is abstract. |
| 1649 bool get isAbstract; | 1651 bool get isAbstract; |
| 1650 | 1652 |
| 1651 /// If abstract, [implementation] points to the overridden concrete member, | 1653 /// If abstract, [implementation] points to the overridden concrete member, |
| 1652 /// if any. Otherwise [implementation] points to the member itself. | 1654 /// if any. Otherwise [implementation] points to the member itself. |
| 1653 Member get implementation; | 1655 Member get implementation; |
| 1654 } | 1656 } |
| 1655 | 1657 |
| OLD | NEW |