Chromium Code Reviews| 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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1436 } | 1436 } |
| 1437 SourceString fieldName = fieldMember.name; | 1437 SourceString fieldName = fieldMember.name; |
| 1438 while (true) { | 1438 while (true) { |
| 1439 Element foundMember = lookupClass.lookupMember(fieldName); | 1439 Element foundMember = lookupClass.lookupMember(fieldName); |
| 1440 if (foundMember == fieldMember) return false; | 1440 if (foundMember == fieldMember) return false; |
| 1441 if (foundMember.isField()) return true; | 1441 if (foundMember.isField()) return true; |
| 1442 lookupClass = foundMember.getEnclosingClass().superclass; | 1442 lookupClass = foundMember.getEnclosingClass().superclass; |
| 1443 } | 1443 } |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 Element lookupConstructor(SourceString className, | 1446 Element validateConstructorLookupResults(Selector selector, |
| 1447 [SourceString constructorName = | 1447 Element result, |
| 1448 const SourceString(''), | 1448 Element noMatch(Element)) { |
| 1449 Element noMatch(Element)]) { | 1449 if (result === null |
| 1450 || !result.isConstructor() | |
| 1451 || (selector.name.isPrivate() | |
| 1452 && result.getLibrary() != selector.library)) { | |
| 1453 result = noMatch !== null ? noMatch(result) : null; | |
| 1454 } | |
| 1455 return result; | |
| 1456 } | |
| 1457 | |
| 1458 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) { | |
|
ahe
2012/10/11 04:55:40
Perhaps in a future CL, it would be great to make
aam-me
2012/10/11 06:14:00
Added as TODO.
| |
| 1450 // TODO(karlklose): have a map from class names to a map of constructors | 1459 // TODO(karlklose): have a map from class names to a map of constructors |
|
ahe
2012/10/11 04:55:40
I think this comment will soon be obsolete.
aam-me
2012/10/11 06:14:00
Removed the comment.
| |
| 1451 // instead of creating the name here? | 1460 // instead of creating the name here? |
| 1452 SourceString normalizedName; | 1461 SourceString normalizedName; |
| 1453 if (constructorName !== const SourceString('')) { | 1462 SourceString className = this.name; |
| 1463 SourceString constructorName = selector.name; | |
| 1464 if (constructorName !== const SourceString('') && | |
| 1465 ((className === null) || | |
| 1466 (constructorName.slowToString() != className.slowToString()))) { | |
| 1454 normalizedName = Elements.constructConstructorName(className, | 1467 normalizedName = Elements.constructConstructorName(className, |
| 1455 constructorName); | 1468 constructorName); |
| 1456 } else { | 1469 } else { |
| 1457 normalizedName = className; | 1470 normalizedName = className; |
| 1458 } | 1471 } |
| 1459 Element result = localLookup(normalizedName); | 1472 Element result = localLookup(normalizedName); |
| 1460 if (result === null || !result.isConstructor()) { | 1473 return validateConstructorLookupResults(selector, result, noMatch); |
| 1461 result = noMatch !== null ? noMatch(result) : null; | 1474 } |
| 1462 } | 1475 |
| 1463 return result; | 1476 Element lookupFactoryConstructor(Selector selector, |
| 1477 [Element noMatch(Element)]) { | |
|
ahe
2012/10/11 04:55:40
I don't understand why noMatch is optional here.
aam-me
2012/10/11 06:14:00
Some users of lookupFactoryConstructor just check
ahe
2012/10/11 07:14:46
I would probably prefer to not have the nomatch fu
| |
| 1478 // TODO(karlklose): have a map from class names to a map of constructors | |
|
ahe
2012/10/11 04:55:40
Ditto.
aam-me
2012/10/11 06:14:00
Removed the comment.
| |
| 1479 // instead of creating the name here? | |
| 1480 SourceString constructorName = selector.name; | |
| 1481 Element result = localLookup(constructorName); | |
| 1482 return validateConstructorLookupResults(selector, result, noMatch); | |
| 1464 } | 1483 } |
| 1465 | 1484 |
| 1466 bool get hasConstructor { | 1485 bool get hasConstructor { |
| 1467 // Search in scope to be sure we search patched constructors. | 1486 // Search in scope to be sure we search patched constructors. |
| 1468 for (var element in localScope.getValues()) { | 1487 for (var element in localScope.getValues()) { |
| 1469 if (element.isConstructor()) return true; | 1488 if (element.isConstructor()) return true; |
| 1470 } | 1489 } |
| 1471 return false; | 1490 return false; |
| 1472 } | 1491 } |
| 1473 | 1492 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1913 | 1932 |
| 1914 MetadataAnnotation ensureResolved(Compiler compiler) { | 1933 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1915 if (resolutionState == STATE_NOT_STARTED) { | 1934 if (resolutionState == STATE_NOT_STARTED) { |
| 1916 compiler.resolver.resolveMetadataAnnotation(this); | 1935 compiler.resolver.resolveMetadataAnnotation(this); |
| 1917 } | 1936 } |
| 1918 return this; | 1937 return this; |
| 1919 } | 1938 } |
| 1920 | 1939 |
| 1921 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1940 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1922 } | 1941 } |
| OLD | NEW |