Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Side by Side Diff: lib/compiler/implementation/resolver.dart

Issue 10942029: Resolve op when op= syntax is used. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 // TODO(kasperl): If [getter] is resolved, it will actually 1542 // TODO(kasperl): If [getter] is resolved, it will actually
1543 // refer to the []= operator which isn't the one we want to 1543 // refer to the []= operator which isn't the one we want to
1544 // register here. We should consider using some notion of 1544 // register here. We should consider using some notion of
1545 // abstract indexable element that we can resolve to so we can 1545 // abstract indexable element that we can resolve to so we can
1546 // distinguish the two. 1546 // distinguish the two.
1547 assert(selector.isIndexSet()); 1547 assert(selector.isIndexSet());
1548 registerSend(new Selector.index(), null); 1548 registerSend(new Selector.index(), null);
1549 } 1549 }
1550 1550
1551 // Make sure we include the + and - operators if we are using 1551 // Make sure we include the + and - operators if we are using
1552 // the ++ and -- ones. 1552 // the ++ and -- ones. Also, if op= form is used, include op itself.
1553 void registerBinaryOperator(SourceString name) { 1553 void registerBinaryOperator(SourceString name) {
1554 Selector binop = new Selector.binaryOperator(name); 1554 Selector binop = new Selector.binaryOperator(name);
1555 world.registerDynamicInvocation(binop.name, binop); 1555 world.registerDynamicInvocation(binop.name, binop);
1556 } 1556 }
1557 if (source === '++') registerBinaryOperator(const SourceString('+')); 1557 if (source === '++') registerBinaryOperator(const SourceString('+'));
1558 if (source === '--') registerBinaryOperator(const SourceString('-')); 1558 if (source === '--') registerBinaryOperator(const SourceString('-'));
1559 if (source.endsWith('=')) {
1560 registerBinaryOperator(new SourceString(source));
ahe 2012/09/24 09:19:31 This will register '+=' as a binary operator. But
Anton Muhin 2012/09/24 09:22:30 That's somewhat surprising, but it actually works
ahe 2012/09/24 11:14:55 I agree this is surprising, and I don't think this
Anton Muhin 2012/09/24 13:13:07 Peter, you should know this stuff better. Anyway,
ahe 2012/09/24 13:22:24 dart2dart is not a short-term priority, so we can
Anton Muhin 2012/09/24 13:23:31 What would be your advice then On 2012/09/24 13:2
ahe 2012/09/24 13:50:30 Create a method that maps a compound operator to i
ahe 2012/09/24 16:07:55 Or even better: take Elements.mapToUserOperator fr
Anton Muhin 2012/09/24 16:09:18 Thanks a lot, Peter, let me give it a try. On 201
Anton Muhin 2012/09/25 10:05:51 Done, ptal On 2012/09/24 16:09:18, Anton Muhin wr
1561 }
1559 } 1562 }
1560 1563
1561 registerSend(selector, setter); 1564 registerSend(selector, setter);
1562 return useElement(node, setter); 1565 return useElement(node, setter);
1563 } 1566 }
1564 1567
1565 void registerSend(Selector selector, Element target) { 1568 void registerSend(Selector selector, Element target) {
1566 if (target === null || target.isInstanceMember()) { 1569 if (target === null || target.isInstanceMember()) {
1567 if (selector.isGetter()) { 1570 if (selector.isGetter()) {
1568 world.registerDynamicGetter(selector.name, selector); 1571 world.registerDynamicGetter(selector.name, selector);
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 2874
2872 Element localLookup(SourceString name) => library.find(name); 2875 Element localLookup(SourceString name) => library.find(name);
2873 Element lookup(SourceString name) => localLookup(name); 2876 Element lookup(SourceString name) => localLookup(name);
2874 Element lexicalLookup(SourceString name) => localLookup(name); 2877 Element lexicalLookup(SourceString name) => localLookup(name);
2875 2878
2876 Element add(Element newElement) { 2879 Element add(Element newElement) {
2877 throw "Cannot add an element in the top scope"; 2880 throw "Cannot add an element in the top scope";
2878 } 2881 }
2879 String toString() => '$element'; 2882 String toString() => '$element';
2880 } 2883 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698