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

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

Issue 10947024: Made dart2js constructor lookup logic "private"-aware, fixed 4740 bug. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed normalizedConstructorName from Selector. 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 #import('../tree/tree.dart'); 9 #import('../tree/tree.dart');
10 #import('../scanner/scannerlib.dart'); 10 #import('../scanner/scannerlib.dart');
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 } 1396 }
1397 SourceString fieldName = fieldMember.name; 1397 SourceString fieldName = fieldMember.name;
1398 while (true) { 1398 while (true) {
1399 Element foundMember = lookupClass.lookupMember(fieldName); 1399 Element foundMember = lookupClass.lookupMember(fieldName);
1400 if (foundMember == fieldMember) return false; 1400 if (foundMember == fieldMember) return false;
1401 if (foundMember.isField()) return true; 1401 if (foundMember.isField()) return true;
1402 lookupClass = foundMember.getEnclosingClass().superclass; 1402 lookupClass = foundMember.getEnclosingClass().superclass;
1403 } 1403 }
1404 } 1404 }
1405 1405
1406 Element lookupConstructor(SourceString className, 1406 Element validateConstructorLookupResults(Selector selector,
1407 [SourceString constructorName = 1407 Element result,
1408 const SourceString(''), 1408 Element noMatch(Element)) {
1409 Element noMatch(Element)]) { 1409 if (result === null
1410 || !result.isConstructor()
1411 || (selector.name.isPrivate()
1412 && result.getLibrary() != selector.library)) {
1413 result = noMatch !== null ? noMatch(result) : null;
1414 }
1415 return result;
1416 }
1417
1418 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) {
1410 // TODO(karlklose): have a map from class names to a map of constructors 1419 // TODO(karlklose): have a map from class names to a map of constructors
1411 // instead of creating the name here? 1420 // instead of creating the name here?
1412 SourceString normalizedName; 1421 SourceString normalizedName;
1413 if (constructorName !== const SourceString('')) { 1422 SourceString className = this.name;
1423 SourceString constructorName = selector.name;
1424 if (constructorName !== const SourceString('') &&
1425 ((className === null) ||
1426 (constructorName.slowToString() != className.slowToString()))) {
kasperl 2012/10/09 13:56:02 Shouldn't this be indented with an extra space?
aam-me 2012/10/10 00:22:40 Done.
1414 normalizedName = Elements.constructConstructorName(className, 1427 normalizedName = Elements.constructConstructorName(className,
1415 constructorName); 1428 constructorName);
1416 } else { 1429 } else {
1417 normalizedName = className; 1430 normalizedName = className;
1418 } 1431 }
1419 Element result = localLookup(normalizedName); 1432 Element result = localLookup(normalizedName);
1420 if (result === null || !result.isConstructor()) { 1433 return validateConstructorLookupResults(selector, result, noMatch);
1421 result = noMatch !== null ? noMatch(result) : null; 1434 }
1422 } 1435
1423 return result; 1436 Element lookupFactoryConstructor(Selector selector,
1437 [Element noMatch(Element)]) {
1438 // TODO(karlklose): have a map from class names to a map of constructors
1439 // instead of creating the name here?
1440 SourceString constructorName = selector.name;
1441 Element result = localLookup(constructorName);
1442 return validateConstructorLookupResults(selector, result, noMatch);
1424 } 1443 }
1425 1444
1426 bool get hasConstructor { 1445 bool get hasConstructor {
1427 // Search in scope to be sure we search patched constructors. 1446 // Search in scope to be sure we search patched constructors.
1428 for (var element in localScope.getValues()) { 1447 for (var element in localScope.getValues()) {
1429 if (element.isConstructor()) return true; 1448 if (element.isConstructor()) return true;
1430 } 1449 }
1431 return false; 1450 return false;
1432 } 1451 }
1433 1452
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 1892
1874 MetadataAnnotation ensureResolved(Compiler compiler) { 1893 MetadataAnnotation ensureResolved(Compiler compiler) {
1875 if (resolutionState == STATE_NOT_STARTED) { 1894 if (resolutionState == STATE_NOT_STARTED) {
1876 compiler.resolver.resolveMetadataAnnotation(this); 1895 compiler.resolver.resolveMetadataAnnotation(this);
1877 } 1896 }
1878 return this; 1897 return this;
1879 } 1898 }
1880 1899
1881 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 1900 String toString() => 'MetadataAnnotation($value, $resolutionState)';
1882 } 1901 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698