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