| 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 Type getType(TypeAnnotation annotation); | 8 Type getType(TypeAnnotation annotation); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 getter = field.getter; | 1301 getter = field.getter; |
| 1302 } | 1302 } |
| 1303 | 1303 |
| 1304 visit(node.argumentsNode); | 1304 visit(node.argumentsNode); |
| 1305 | 1305 |
| 1306 // TODO(ngeoffray): Check if the target can be assigned. | 1306 // TODO(ngeoffray): Check if the target can be assigned. |
| 1307 // TODO(ngeoffray): Warn if target is null and the send is | 1307 // TODO(ngeoffray): Warn if target is null and the send is |
| 1308 // unqualified. | 1308 // unqualified. |
| 1309 | 1309 |
| 1310 Selector selector = mapping.getSelector(node); | 1310 Selector selector = mapping.getSelector(node); |
| 1311 Identifier identifier = node.assignmentOperator; | 1311 String source = node.assignmentOperator.source.stringValue; |
| 1312 bool isCompound = identifier.source.stringValue !== '='; | 1312 bool isComplex = source !== '='; |
| 1313 if (isCompound) { | 1313 if (isComplex) { |
| 1314 if (selector.isSetter()) { | 1314 if (selector.isSetter()) { |
| 1315 useElement(node.selector, getter); | 1315 useElement(node.selector, getter); |
| 1316 registerSend(new Selector.getterFrom(selector), getter); | 1316 registerSend(new Selector.getterFrom(selector), getter); |
| 1317 } else { | 1317 } else { |
| 1318 // TODO(kasperl): If [getter] is resolved, it will actually | 1318 // TODO(kasperl): If [getter] is resolved, it will actually |
| 1319 // refer to the []= operator which isn't the one we want to | 1319 // refer to the []= operator which isn't the one we want to |
| 1320 // register here. We should consider using some notation of | 1320 // register here. We should consider using some notion of |
| 1321 // abstract indexable element that we can resolve to so we can | 1321 // abstract indexable element that we can resolve to so we can |
| 1322 // distinguish the two. | 1322 // distinguish the two. |
| 1323 assert(selector.isIndexSet()); | 1323 assert(selector.isIndexSet()); |
| 1324 registerSend(new Selector.index(), null); | 1324 registerSend(new Selector.index(), null); |
| 1325 } | 1325 } |
| 1326 |
| 1327 // Make sure we include the + and - operators if we are using |
| 1328 // the ++ and -- ones. |
| 1329 void registerBinaryOperator(SourceString name) { |
| 1330 Selector binop = new Selector.binaryOperator(name); |
| 1331 world.registerDynamicInvocation(binop.name, binop); |
| 1332 } |
| 1333 if (source === '++') registerBinaryOperator(const SourceString('+')); |
| 1334 if (source === '--') registerBinaryOperator(const SourceString('-')); |
| 1326 } | 1335 } |
| 1327 | 1336 |
| 1328 registerSend(selector, setter); | 1337 registerSend(selector, setter); |
| 1329 return useElement(node, setter); | 1338 return useElement(node, setter); |
| 1330 } | 1339 } |
| 1331 | 1340 |
| 1332 void registerSend(Selector selector, Element target) { | 1341 void registerSend(Selector selector, Element target) { |
| 1333 if (target === null || target.isInstanceMember()) { | 1342 if (target === null || target.isInstanceMember()) { |
| 1334 if (selector.isGetter()) { | 1343 if (selector.isGetter()) { |
| 1335 world.registerDynamicGetter(selector.name, selector); | 1344 world.registerDynamicGetter(selector.name, selector); |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2430 TopScope(LibraryElement library) : super(null, library); | 2439 TopScope(LibraryElement library) : super(null, library); |
| 2431 Element lookup(SourceString name) { | 2440 Element lookup(SourceString name) { |
| 2432 return library.find(name); | 2441 return library.find(name); |
| 2433 } | 2442 } |
| 2434 | 2443 |
| 2435 Element add(Element newElement) { | 2444 Element add(Element newElement) { |
| 2436 throw "Cannot add an element in the top scope"; | 2445 throw "Cannot add an element in the top scope"; |
| 2437 } | 2446 } |
| 2438 String toString() => '$element'; | 2447 String toString() => '$element'; |
| 2439 } | 2448 } |
| OLD | NEW |