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

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: Another attempt at implementing private-aware constructor lookup logic - with normalized constructo… Created 8 years, 3 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 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 } 1369 }
1370 SourceString fieldName = fieldMember.name; 1370 SourceString fieldName = fieldMember.name;
1371 while (true) { 1371 while (true) {
1372 Element foundMember = lookupClass.lookupMember(fieldName); 1372 Element foundMember = lookupClass.lookupMember(fieldName);
1373 if (foundMember == fieldMember) return false; 1373 if (foundMember == fieldMember) return false;
1374 if (foundMember.isField()) return true; 1374 if (foundMember.isField()) return true;
1375 lookupClass = foundMember.getEnclosingClass().superclass; 1375 lookupClass = foundMember.getEnclosingClass().superclass;
1376 } 1376 }
1377 } 1377 }
1378 1378
1379 Element lookupConstructor(SourceString className, 1379 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) {
1380 [SourceString constructorName =
1381 const SourceString(''),
1382 Element noMatch(Element)]) {
1383 // TODO(karlklose): have a map from class names to a map of constructors 1380 // TODO(karlklose): have a map from class names to a map of constructors
1384 // instead of creating the name here? 1381 // instead of creating the name here?
1385 SourceString normalizedName; 1382 Element result = localLookup(selector.normalizedConstructorName);
1386 if (constructorName !== const SourceString('')) { 1383 if (result === null
1387 normalizedName = Elements.constructConstructorName(className, 1384 || !result.isConstructor()
1388 constructorName); 1385 || (selector.name.isPrivate()
1389 } else { 1386 && result.getLibrary() != selector.library)) {
1390 normalizedName = className;
1391 }
1392 Element result = localLookup(normalizedName);
1393 if (result === null || !result.isConstructor()) {
1394 result = noMatch !== null ? noMatch(result) : null; 1387 result = noMatch !== null ? noMatch(result) : null;
1395 } 1388 }
1396 return result; 1389 return result;
1397 } 1390 }
1398 1391
1399 bool get hasConstructor { 1392 bool get hasConstructor {
1400 // Search in scope to be sure we search patched constructors. 1393 // Search in scope to be sure we search patched constructors.
1401 for (var element in localScope.getValues()) { 1394 for (var element in localScope.getValues()) {
1402 if (element.isConstructor()) return true; 1395 if (element.isConstructor()) return true;
1403 } 1396 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 1785
1793 MetadataAnnotation ensureResolved(Compiler compiler) { 1786 MetadataAnnotation ensureResolved(Compiler compiler) {
1794 if (resolutionState == STATE_NOT_STARTED) { 1787 if (resolutionState == STATE_NOT_STARTED) {
1795 compiler.resolver.resolveMetadataAnnotation(this); 1788 compiler.resolver.resolveMetadataAnnotation(this);
1796 } 1789 }
1797 return this; 1790 return this;
1798 } 1791 }
1799 1792
1800 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 1793 String toString() => 'MetadataAnnotation($value, $resolutionState)';
1801 } 1794 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698