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 #import('../tree/tree.dart'); | 7 #import('../tree/tree.dart'); |
8 #import('../scanner/scannerlib.dart'); | 8 #import('../scanner/scannerlib.dart'); |
9 #import('../leg.dart'); // TODO(karlklose): we only need type. | 9 #import('../leg.dart'); // TODO(karlklose): we only need type. |
10 #import('../util/util.dart'); | 10 #import('../util/util.dart'); |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 && !element.isInstanceMember() | 637 && !element.isInstanceMember() |
638 && (element.kind === ElementKind.FUNCTION); | 638 && (element.kind === ElementKind.FUNCTION); |
639 } | 639 } |
640 | 640 |
641 static bool isInstanceMethod(Element element) { | 641 static bool isInstanceMethod(Element element) { |
642 return (element != null) | 642 return (element != null) |
643 && element.isInstanceMember() | 643 && element.isInstanceMember() |
644 && (element.kind === ElementKind.FUNCTION); | 644 && (element.kind === ElementKind.FUNCTION); |
645 } | 645 } |
646 | 646 |
| 647 static bool isInstanceSend(Send send, TreeElements elements) { |
| 648 Element element = elements[send]; |
| 649 if (element === null) return !isClosureSend(send, elements); |
| 650 return isInstanceMethod(element) || isInstanceField(element); |
| 651 } |
| 652 |
647 static bool isClosureSend(Send send, TreeElements elements) { | 653 static bool isClosureSend(Send send, TreeElements elements) { |
648 if (send.isPropertyAccess) return false; | 654 if (send.isPropertyAccess) return false; |
649 if (send.receiver !== null) return false; | 655 if (send.receiver !== null) return false; |
650 Element element = elements[send]; | 656 Element element = elements[send]; |
651 // (o)() or foo()(). | 657 // (o)() or foo()(). |
652 if (element === null && send.selector.asIdentifier() === null) return true; | 658 if (element === null && send.selector.asIdentifier() === null) return true; |
653 if (element === null) return false; | 659 if (element === null) return false; |
654 // foo() with foo a local or a parameter. | 660 // foo() with foo a local or a parameter. |
655 return element.isVariable() || element.isParameter(); | 661 return element.isVariable() || element.isParameter(); |
656 } | 662 } |
(...skipping 24 matching lines...) Expand all Loading... |
681 else if (str === '>=') str = 'ge'; | 687 else if (str === '>=') str = 'ge'; |
682 else if (str === '>') str = 'gt'; | 688 else if (str === '>') str = 'gt'; |
683 else if (str === '<=') str = 'le'; | 689 else if (str === '<=') str = 'le'; |
684 else if (str === '<') str = 'lt'; | 690 else if (str === '<') str = 'lt'; |
685 else if (str === '&' || str === '&=') str = 'and'; | 691 else if (str === '&' || str === '&=') str = 'and'; |
686 else if (str === '^' || str === '^=') str = 'xor'; | 692 else if (str === '^' || str === '^=') str = 'xor'; |
687 else if (str === '|' || str === '|=') str = 'or'; | 693 else if (str === '|' || str === '|=') str = 'or'; |
688 return new SourceString('$receiver\$$str'); | 694 return new SourceString('$receiver\$$str'); |
689 } | 695 } |
690 } | 696 } |
OLD | NEW |