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('dart:uri'); | 7 #import('dart:uri'); |
8 | 8 |
9 #import('../tree/tree.dart'); | 9 #import('../tree/tree.dart'); |
10 #import('../scanner/scannerlib.dart'); | 10 #import('../scanner/scannerlib.dart'); |
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 static SourceString constructConstructorName(SourceString receiver, | 1456 static SourceString constructConstructorName(SourceString receiver, |
1457 SourceString selector) { | 1457 SourceString selector) { |
1458 String r = receiver.slowToString(); | 1458 String r = receiver.slowToString(); |
1459 String s = selector.slowToString(); | 1459 String s = selector.slowToString(); |
1460 return new SourceString('$r\$$s'); | 1460 return new SourceString('$r\$$s'); |
1461 } | 1461 } |
1462 | 1462 |
1463 static const SourceString OPERATOR_EQUALS = | 1463 static const SourceString OPERATOR_EQUALS = |
1464 const SourceString(@'operator$eq'); | 1464 const SourceString(@'operator$eq'); |
1465 | 1465 |
1466 static SourceString constructOperatorName(SourceString receiver, | 1466 static SourceString constructOperatorName(SourceString selector, |
1467 SourceString selector, | 1467 bool isUnary) { |
1468 [bool isUnary = false]) { | |
1469 String str = selector.stringValue; | 1468 String str = selector.stringValue; |
1470 if (str === '==' || str === '!=') return OPERATOR_EQUALS; | 1469 if (str === '==' || str === '!=') return OPERATOR_EQUALS; |
1471 | 1470 |
1472 if (str === '~') str = 'not'; | 1471 if (str === '~') { |
1473 else if (str === 'negate' || (str === '-' && isUnary)) str = 'negate'; | 1472 str = 'not'; |
1474 else if (str === '[]') str = 'index'; | 1473 } else if (str === '-' && isUnary) { |
1475 else if (str === '[]=') str = 'indexSet'; | 1474 // TODO(ahe): Return something like 'unary -'. |
1476 else if (str === '*' || str === '*=') str = 'mul'; | 1475 return const SourceString('negate'); |
1477 else if (str === '/' || str === '/=') str = 'div'; | 1476 } else if (str === '[]') { |
1478 else if (str === '%' || str === '%=') str = 'mod'; | 1477 str = 'index'; |
1479 else if (str === '~/' || str === '~/=') str = 'tdiv'; | 1478 } else if (str === '[]=') { |
1480 else if (str === '+' || str === '+=') str = 'add'; | 1479 str = 'indexSet'; |
1481 else if (str === '-' || str === '-=') str = 'sub'; | 1480 } else if (str === '*' || str === '*=') { |
1482 else if (str === '<<' || str === '<<=') str = 'shl'; | 1481 str = 'mul'; |
1483 else if (str === '>>' || str === '>>=') str = 'shr'; | 1482 } else if (str === '/' || str === '/=') { |
1484 else if (str === '>=') str = 'ge'; | 1483 str = 'div'; |
1485 else if (str === '>') str = 'gt'; | 1484 } else if (str === '%' || str === '%=') { |
1486 else if (str === '<=') str = 'le'; | 1485 str = 'mod'; |
1487 else if (str === '<') str = 'lt'; | 1486 } else if (str === '~/' || str === '~/=') { |
1488 else if (str === '&' || str === '&=') str = 'and'; | 1487 str = 'tdiv'; |
1489 else if (str === '^' || str === '^=') str = 'xor'; | 1488 } else if (str === '+' || str === '+=') { |
1490 else if (str === '|' || str === '|=') str = 'or'; | 1489 str = 'add'; |
1491 else { | 1490 } else if (str === '-' || str === '-=') { |
| 1491 str = 'sub'; |
| 1492 } else if (str === '<<' || str === '<<=') { |
| 1493 str = 'shl'; |
| 1494 } else if (str === '>>' || str === '>>=') { |
| 1495 str = 'shr'; |
| 1496 } else if (str === '>=') { |
| 1497 str = 'ge'; |
| 1498 } else if (str === '>') { |
| 1499 str = 'gt'; |
| 1500 } else if (str === '<=') { |
| 1501 str = 'le'; |
| 1502 } else if (str === '<') { |
| 1503 str = 'lt'; |
| 1504 } else if (str === '&' || str === '&=') { |
| 1505 str = 'and'; |
| 1506 } else if (str === '^' || str === '^=') { |
| 1507 str = 'xor'; |
| 1508 } else if (str === '|' || str === '|=') { |
| 1509 str = 'or'; |
| 1510 } else if (selector == const SourceString('negate')) { |
| 1511 // TODO(ahe): Remove this case: Legacy support for pre-0.11 spec. |
| 1512 return selector; |
| 1513 } else { |
1492 throw new Exception('Unhandled selector: ${selector.slowToString()}'); | 1514 throw new Exception('Unhandled selector: ${selector.slowToString()}'); |
1493 } | 1515 } |
1494 return new SourceString('$receiver\$$str'); | 1516 return new SourceString('operator\$$str'); |
1495 } | 1517 } |
1496 | 1518 |
1497 static bool isStringSupertype(Element element, Compiler compiler) { | 1519 static bool isStringSupertype(Element element, Compiler compiler) { |
1498 LibraryElement coreLibrary = compiler.coreLibrary; | 1520 LibraryElement coreLibrary = compiler.coreLibrary; |
1499 return (element == coreLibrary.find(const SourceString('Comparable'))) | 1521 return (element == coreLibrary.find(const SourceString('Comparable'))) |
1500 || (element == coreLibrary.find(const SourceString('Hashable'))) | 1522 || (element == coreLibrary.find(const SourceString('Hashable'))) |
1501 || (element == coreLibrary.find(const SourceString('Pattern'))); | 1523 || (element == coreLibrary.find(const SourceString('Pattern'))); |
1502 } | 1524 } |
1503 | 1525 |
1504 static bool isListSupertype(Element element, Compiler compiler) { | 1526 static bool isListSupertype(Element element, Compiler compiler) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 | 1651 |
1630 MetadataAnnotation ensureResolved(Compiler compiler) { | 1652 MetadataAnnotation ensureResolved(Compiler compiler) { |
1631 if (resolutionState == STATE_NOT_STARTED) { | 1653 if (resolutionState == STATE_NOT_STARTED) { |
1632 compiler.resolver.resolveMetadataAnnotation(this); | 1654 compiler.resolver.resolveMetadataAnnotation(this); |
1633 } | 1655 } |
1634 return this; | 1656 return this; |
1635 } | 1657 } |
1636 | 1658 |
1637 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1659 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
1638 } | 1660 } |
OLD | NEW |