| 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 interface TreeElements { | 5 interface TreeElements { |
| 6 Element operator[](Node node); | 6 Element operator[](Node node); |
| 7 Selector getSelector(Send send); | 7 Selector getSelector(Send send); |
| 8 } | 8 } |
| 9 | 9 |
| 10 class TreeElementMapping implements TreeElements { | 10 class TreeElementMapping implements TreeElements { |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 visit(node.thenPart); | 747 visit(node.thenPart); |
| 748 visit(node.elsePart); | 748 visit(node.elsePart); |
| 749 } | 749 } |
| 750 | 750 |
| 751 static bool isLogicalOperator(Identifier op) { | 751 static bool isLogicalOperator(Identifier op) { |
| 752 String str = op.source.stringValue; | 752 String str = op.source.stringValue; |
| 753 return (str === '&&' || str == '||' || str == '!'); | 753 return (str === '&&' || str == '||' || str == '!'); |
| 754 } | 754 } |
| 755 | 755 |
| 756 Element resolveSend(Send node) { | 756 Element resolveSend(Send node) { |
| 757 if (node.receiver === null || (node.selector.asIdentifier() !== null && | 757 if (node.receiver === null) { |
| 758 node.selector.asIdentifier().isThis())) { | |
| 759 return node.selector.accept(this); | 758 return node.selector.accept(this); |
| 760 } | 759 } |
| 761 var oldCategory = allowedCategory; | 760 var oldCategory = allowedCategory; |
| 762 allowedCategory |= | 761 allowedCategory |= |
| 763 ElementCategory.CLASS | ElementCategory.PREFIX | ElementCategory.SUPER; | 762 ElementCategory.CLASS | ElementCategory.PREFIX | ElementCategory.SUPER; |
| 764 Element resolvedReceiver = visit(node.receiver); | 763 Element resolvedReceiver = visit(node.receiver); |
| 765 allowedCategory = oldCategory; | 764 allowedCategory = oldCategory; |
| 766 | 765 |
| 767 Element target; | 766 Element target; |
| 768 SourceString name = node.selector.asIdentifier().source; | 767 SourceString name = node.selector.asIdentifier().source; |
| 769 if (node.isSuperCall) { | 768 if (name.stringValue === 'this') { |
| 769 error(node.selector, MessageKind.GENERIC, ["expected an identifier"]); |
| 770 } else if (node.isSuperCall) { |
| 770 if (isUserDefinableOperator(name.stringValue)) { | 771 if (isUserDefinableOperator(name.stringValue)) { |
| 771 name = Elements.constructOperatorName(const SourceString('operator'), | 772 name = Elements.constructOperatorName(const SourceString('operator'), |
| 772 name); | 773 name); |
| 773 } | 774 } |
| 774 if (!inInstanceContext) { | 775 if (!inInstanceContext) { |
| 775 error(node.receiver, MessageKind.NO_INSTANCE_AVAILABLE, [name]); | 776 error(node.receiver, MessageKind.NO_INSTANCE_AVAILABLE, [name]); |
| 776 return null; | 777 return null; |
| 777 } | 778 } |
| 778 if (currentClass.supertype === null) { | 779 if (currentClass.supertype === null) { |
| 779 // This is just to guard against internal errors, so no need | 780 // This is just to guard against internal errors, so no need |
| 780 // for a real error message. | 781 // for a real error message. |
| 781 error(node.receiver, MessageKind.GENERIC, "Object has no superclass"); | 782 error(node.receiver, MessageKind.GENERIC, ["Object has no superclass"]); |
| 782 } | 783 } |
| 783 target = currentClass.lookupSuperMember(name); | 784 target = currentClass.lookupSuperMember(name); |
| 784 // [target] may be null which means invoking noSuchMethod on | 785 // [target] may be null which means invoking noSuchMethod on |
| 785 // super. | 786 // super. |
| 786 } else if (resolvedReceiver === null) { | 787 } else if (resolvedReceiver === null) { |
| 787 return null; | 788 return null; |
| 788 } else if (resolvedReceiver.kind === ElementKind.CLASS) { | 789 } else if (resolvedReceiver.kind === ElementKind.CLASS) { |
| 789 ClassElement receiverClass = resolvedReceiver; | 790 ClassElement receiverClass = resolvedReceiver; |
| 790 target = receiverClass.ensureResolved(compiler).lookupLocalMember(name); | 791 target = receiverClass.ensureResolved(compiler).lookupLocalMember(name); |
| 791 if (target === null) { | 792 if (target === null) { |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1749 | 1750 |
| 1750 TopScope(LibraryElement library) : super(null, library); | 1751 TopScope(LibraryElement library) : super(null, library); |
| 1751 Element lookup(SourceString name) { | 1752 Element lookup(SourceString name) { |
| 1752 return library.find(name); | 1753 return library.find(name); |
| 1753 } | 1754 } |
| 1754 | 1755 |
| 1755 Element add(Element element) { | 1756 Element add(Element element) { |
| 1756 throw "Cannot add an element in the top scope"; | 1757 throw "Cannot add an element in the top scope"; |
| 1757 } | 1758 } |
| 1758 } | 1759 } |
| OLD | NEW |