Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: lib/compiler/implementation/elements/elements.dart

Issue 11111017: Re-land r13557 on behalf of Alexander. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 lookupConstructor(SourceString className, 1478 Element validateConstructorLookupResults(Selector selector,
1479 [SourceString constructorName = 1479 Element result,
1480 const SourceString(''), 1480 Element noMatch(Element)) {
1481 Element noMatch(Element)]) { 1481 if (result === null
1482 // TODO(karlklose): have a map from class names to a map of constructors 1482 || !result.isConstructor()
1483 // instead of creating the name here? 1483 || (selector.name.isPrivate()
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)]) {
1484 SourceString normalizedName; 1494 SourceString normalizedName;
1485 if (constructorName !== const SourceString('')) { 1495 SourceString className = this.name;
1496 SourceString constructorName = selector.name;
1497 if (constructorName !== const SourceString('') &&
1498 ((className === null) ||
1499 (constructorName.slowToString() != className.slowToString()))) {
1486 normalizedName = Elements.constructConstructorName(className, 1500 normalizedName = Elements.constructConstructorName(className,
1487 constructorName); 1501 constructorName);
1488 } else { 1502 } else {
1489 normalizedName = className; 1503 normalizedName = className;
1490 } 1504 }
1491 Element result = localLookup(normalizedName); 1505 Element result = localLookup(normalizedName);
1492 if (result === null || !result.isConstructor()) { 1506 return validateConstructorLookupResults(selector, result, noMatch);
1493 result = noMatch !== null ? noMatch(result) : null; 1507 }
1494 } 1508
1495 return result; 1509 Element lookupFactoryConstructor(Selector selector,
1510 [Element noMatch(Element)]) {
1511 SourceString constructorName = selector.name;
1512 Element result = localLookup(constructorName);
1513 return validateConstructorLookupResults(selector, result, noMatch);
1496 } 1514 }
1497 1515
1498 bool get hasConstructor { 1516 bool get hasConstructor {
1499 // Search in scope to be sure we search patched constructors. 1517 // Search in scope to be sure we search patched constructors.
1500 for (var element in localScope.getValues()) { 1518 for (var element in localScope.getValues()) {
1501 if (element.isConstructor()) return true; 1519 if (element.isConstructor()) return true;
1502 } 1520 }
1503 return false; 1521 return false;
1504 } 1522 }
1505 1523
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 1963
1946 MetadataAnnotation ensureResolved(Compiler compiler) { 1964 MetadataAnnotation ensureResolved(Compiler compiler) {
1947 if (resolutionState == STATE_NOT_STARTED) { 1965 if (resolutionState == STATE_NOT_STARTED) {
1948 compiler.resolver.resolveMetadataAnnotation(this); 1966 compiler.resolver.resolveMetadataAnnotation(this);
1949 } 1967 }
1950 return this; 1968 return this;
1951 } 1969 }
1952 1970
1953 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 1971 String toString() => 'MetadataAnnotation($value, $resolutionState)';
1954 } 1972 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/compile_time_constants.dart ('k') | lib/compiler/implementation/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698