| 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 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. | 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. |
| 10 #import('../../compiler.dart', prefix: 'api_e'); | 10 #import('../../compiler.dart', prefix: 'api_e'); |
| (...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 } | 1468 } |
| 1469 SourceString fieldName = fieldMember.name; | 1469 SourceString fieldName = fieldMember.name; |
| 1470 while (true) { | 1470 while (true) { |
| 1471 Element foundMember = lookupClass.lookupMember(fieldName); | 1471 Element foundMember = lookupClass.lookupMember(fieldName); |
| 1472 if (foundMember == fieldMember) return false; | 1472 if (foundMember == fieldMember) return false; |
| 1473 if (foundMember.isField()) return true; | 1473 if (foundMember.isField()) return true; |
| 1474 lookupClass = foundMember.getEnclosingClass().superclass; | 1474 lookupClass = foundMember.getEnclosingClass().superclass; |
| 1475 } | 1475 } |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 Element validateConstructorLookupResults(Selector selector, | 1478 Element lookupConstructor(SourceString className, |
| 1479 Element result, | 1479 [SourceString constructorName = |
| 1480 Element noMatch(Element)) { | 1480 const SourceString(''), |
| 1481 if (result === null | 1481 Element noMatch(Element)]) { |
| 1482 || !result.isConstructor() | 1482 // TODO(karlklose): have a map from class names to a map of constructors |
| 1483 || (selector.name.isPrivate() | 1483 // instead of creating the name here? |
| 1484 && result.getLibrary() != selector.library)) { | |
| 1485 result = noMatch !== null ? noMatch(result) : null; | |
| 1486 } | |
| 1487 return result; | |
| 1488 } | |
| 1489 | |
| 1490 // TODO(aprelev@gmail.com): Peter believes that it would be great to | |
| 1491 // make noMatch a required argument. Peter's suspicion is that most | |
| 1492 // callers of this method would benefit from using the noMatch method. | |
| 1493 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) { | |
| 1494 SourceString normalizedName; | 1484 SourceString normalizedName; |
| 1495 SourceString className = this.name; | 1485 if (constructorName !== const SourceString('')) { |
| 1496 SourceString constructorName = selector.name; | |
| 1497 if (constructorName !== const SourceString('') && | |
| 1498 ((className === null) || | |
| 1499 (constructorName.slowToString() != className.slowToString()))) { | |
| 1500 normalizedName = Elements.constructConstructorName(className, | 1486 normalizedName = Elements.constructConstructorName(className, |
| 1501 constructorName); | 1487 constructorName); |
| 1502 } else { | 1488 } else { |
| 1503 normalizedName = className; | 1489 normalizedName = className; |
| 1504 } | 1490 } |
| 1505 Element result = localLookup(normalizedName); | 1491 Element result = localLookup(normalizedName); |
| 1506 return validateConstructorLookupResults(selector, result, noMatch); | 1492 if (result === null || !result.isConstructor()) { |
| 1507 } | 1493 result = noMatch !== null ? noMatch(result) : null; |
| 1508 | 1494 } |
| 1509 Element lookupFactoryConstructor(Selector selector, | 1495 return result; |
| 1510 [Element noMatch(Element)]) { | |
| 1511 SourceString constructorName = selector.name; | |
| 1512 Element result = localLookup(constructorName); | |
| 1513 return validateConstructorLookupResults(selector, result, noMatch); | |
| 1514 } | 1496 } |
| 1515 | 1497 |
| 1516 bool get hasConstructor { | 1498 bool get hasConstructor { |
| 1517 // Search in scope to be sure we search patched constructors. | 1499 // Search in scope to be sure we search patched constructors. |
| 1518 for (var element in localScope.getValues()) { | 1500 for (var element in localScope.getValues()) { |
| 1519 if (element.isConstructor()) return true; | 1501 if (element.isConstructor()) return true; |
| 1520 } | 1502 } |
| 1521 return false; | 1503 return false; |
| 1522 } | 1504 } |
| 1523 | 1505 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 | 1945 |
| 1964 MetadataAnnotation ensureResolved(Compiler compiler) { | 1946 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1965 if (resolutionState == STATE_NOT_STARTED) { | 1947 if (resolutionState == STATE_NOT_STARTED) { |
| 1966 compiler.resolver.resolveMetadataAnnotation(this); | 1948 compiler.resolver.resolveMetadataAnnotation(this); |
| 1967 } | 1949 } |
| 1968 return this; | 1950 return this; |
| 1969 } | 1951 } |
| 1970 | 1952 |
| 1971 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1953 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1972 } | 1954 } |
| OLD | NEW |