| 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 abstract class TreeElements { | 5 abstract class TreeElements { |
| 6 Element operator[](Node node); | 6 Element operator[](Node node); |
| 7 Selector getSelector(Send send); | 7 Selector getSelector(Send send); |
| 8 DartType getType(TypeAnnotation annotation); | 8 DartType getType(TypeAnnotation annotation); |
| 9 bool isParameterChecked(Element element); | 9 bool isParameterChecked(Element element); |
| 10 } | 10 } |
| (...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 // unqualified. | 1493 // unqualified. |
| 1494 useElement(node, target); | 1494 useElement(node, target); |
| 1495 registerSend(selector, target); | 1495 registerSend(selector, target); |
| 1496 return node.isPropertyAccess ? target : null; | 1496 return node.isPropertyAccess ? target : null; |
| 1497 } | 1497 } |
| 1498 | 1498 |
| 1499 visitSendSet(SendSet node) { | 1499 visitSendSet(SendSet node) { |
| 1500 Element target = resolveSend(node); | 1500 Element target = resolveSend(node); |
| 1501 Element setter = target; | 1501 Element setter = target; |
| 1502 Element getter = target; | 1502 Element getter = target; |
| 1503 String source = node.assignmentOperator.source.stringValue; | 1503 SourceString operatorName = node.assignmentOperator.source; |
| 1504 String source = operatorName.stringValue; |
| 1504 bool isComplex = source !== '='; | 1505 bool isComplex = source !== '='; |
| 1505 if (!Elements.isUnresolved(target) | 1506 if (!Elements.isUnresolved(target) |
| 1506 && target.kind == ElementKind.ABSTRACT_FIELD) { | 1507 && target.kind == ElementKind.ABSTRACT_FIELD) { |
| 1507 AbstractFieldElement field = target; | 1508 AbstractFieldElement field = target; |
| 1508 setter = field.setter; | 1509 setter = field.setter; |
| 1509 getter = field.getter; | 1510 getter = field.getter; |
| 1510 if (setter == null && !inInstanceContext) { | 1511 if (setter == null && !inInstanceContext) { |
| 1511 setter = | 1512 setter = |
| 1512 warnAndCreateErroneousElement(node.selector, field.name, | 1513 warnAndCreateErroneousElement(node.selector, field.name, |
| 1513 MessageKind.CANNOT_RESOLVE_SETTER, | 1514 MessageKind.CANNOT_RESOLVE_SETTER, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1542 // TODO(kasperl): If [getter] is resolved, it will actually | 1543 // TODO(kasperl): If [getter] is resolved, it will actually |
| 1543 // refer to the []= operator which isn't the one we want to | 1544 // refer to the []= operator which isn't the one we want to |
| 1544 // register here. We should consider using some notion of | 1545 // register here. We should consider using some notion of |
| 1545 // abstract indexable element that we can resolve to so we can | 1546 // abstract indexable element that we can resolve to so we can |
| 1546 // distinguish the two. | 1547 // distinguish the two. |
| 1547 assert(selector.isIndexSet()); | 1548 assert(selector.isIndexSet()); |
| 1548 registerSend(new Selector.index(), null); | 1549 registerSend(new Selector.index(), null); |
| 1549 } | 1550 } |
| 1550 | 1551 |
| 1551 // Make sure we include the + and - operators if we are using | 1552 // Make sure we include the + and - operators if we are using |
| 1552 // the ++ and -- ones. | 1553 // the ++ and -- ones. Also, if op= form is used, include op itself. |
| 1553 void registerBinaryOperator(SourceString name) { | 1554 void registerBinaryOperator(SourceString name) { |
| 1554 Selector binop = new Selector.binaryOperator(name); | 1555 Selector binop = new Selector.binaryOperator(name); |
| 1555 world.registerDynamicInvocation(binop.name, binop); | 1556 world.registerDynamicInvocation(binop.name, binop); |
| 1556 } | 1557 } |
| 1557 if (source === '++') registerBinaryOperator(const SourceString('+')); | 1558 if (source === '++') registerBinaryOperator(const SourceString('+')); |
| 1558 if (source === '--') registerBinaryOperator(const SourceString('-')); | 1559 if (source === '--') registerBinaryOperator(const SourceString('-')); |
| 1560 if (source.endsWith('=')) { |
| 1561 registerBinaryOperator(Elements.mapToUserOperator(operatorName)); |
| 1562 } |
| 1559 } | 1563 } |
| 1560 | 1564 |
| 1561 registerSend(selector, setter); | 1565 registerSend(selector, setter); |
| 1562 return useElement(node, setter); | 1566 return useElement(node, setter); |
| 1563 } | 1567 } |
| 1564 | 1568 |
| 1565 void registerSend(Selector selector, Element target) { | 1569 void registerSend(Selector selector, Element target) { |
| 1566 if (target === null || target.isInstanceMember()) { | 1570 if (target === null || target.isInstanceMember()) { |
| 1567 if (selector.isGetter()) { | 1571 if (selector.isGetter()) { |
| 1568 world.registerDynamicGetter(selector.name, selector); | 1572 world.registerDynamicGetter(selector.name, selector); |
| (...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2871 | 2875 |
| 2872 Element localLookup(SourceString name) => library.find(name); | 2876 Element localLookup(SourceString name) => library.find(name); |
| 2873 Element lookup(SourceString name) => localLookup(name); | 2877 Element lookup(SourceString name) => localLookup(name); |
| 2874 Element lexicalLookup(SourceString name) => localLookup(name); | 2878 Element lexicalLookup(SourceString name) => localLookup(name); |
| 2875 | 2879 |
| 2876 Element add(Element newElement) { | 2880 Element add(Element newElement) { |
| 2877 throw "Cannot add an element in the top scope"; | 2881 throw "Cannot add an element in the top scope"; |
| 2878 } | 2882 } |
| 2879 String toString() => '$element'; | 2883 String toString() => '$element'; |
| 2880 } | 2884 } |
| OLD | NEW |