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 #import('../tree/tree.dart'); | 9 #import('../tree/tree.dart'); |
| 10 #import('../scanner/scannerlib.dart'); | 10 #import('../scanner/scannerlib.dart'); |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 } | 1268 } |
| 1269 SourceString fieldName = fieldMember.name; | 1269 SourceString fieldName = fieldMember.name; |
| 1270 while (true) { | 1270 while (true) { |
| 1271 Element foundMember = lookupClass.lookupMember(fieldName); | 1271 Element foundMember = lookupClass.lookupMember(fieldName); |
| 1272 if (foundMember == fieldMember) return false; | 1272 if (foundMember == fieldMember) return false; |
| 1273 if (foundMember.isField()) return true; | 1273 if (foundMember.isField()) return true; |
| 1274 lookupClass = foundMember.getEnclosingClass().superclass; | 1274 lookupClass = foundMember.getEnclosingClass().superclass; |
| 1275 } | 1275 } |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 Element lookupConstructor(SourceString className, | 1278 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) { |
| 1279 [SourceString constructorName = | 1279 SourceString className = selector.selectorName.className; |
|
kasperl
2012/09/21 12:12:06
This makes it look like all you really need is to
aam-me
2012/09/21 12:35:27
Right.
| |
| 1280 const SourceString(''), | 1280 SourceString constructorName = selector.selectorName.name; |
| 1281 Element noMatch(Element)]) { | 1281 |
| 1282 LibraryElement fromLibrary = selector.library; | |
| 1282 // TODO(karlklose): have a map from class names to a map of constructors | 1283 // TODO(karlklose): have a map from class names to a map of constructors |
| 1283 // instead of creating the name here? | 1284 // instead of creating the name here? |
| 1284 SourceString normalizedName; | 1285 SourceString normalizedName; |
| 1285 if (constructorName !== const SourceString('')) { | 1286 if (constructorName !== const SourceString('')) { |
| 1286 normalizedName = Elements.constructConstructorName(className, | 1287 normalizedName = Elements.constructConstructorName(className, |
| 1287 constructorName); | 1288 constructorName); |
| 1288 } else { | 1289 } else { |
| 1289 normalizedName = className; | 1290 normalizedName = className; |
| 1290 } | 1291 } |
| 1291 Element result = localLookup(normalizedName); | 1292 Element result = localLookup(normalizedName); |
| 1292 if (result === null || !result.isConstructor()) { | 1293 if (result === null |
| 1294 || !result.isConstructor() | |
| 1295 || (selector.selectorName.isPrivate() | |
| 1296 && result.getLibrary() != fromLibrary)) { | |
| 1293 result = noMatch !== null ? noMatch(result) : null; | 1297 result = noMatch !== null ? noMatch(result) : null; |
| 1294 } | 1298 } |
| 1295 return result; | 1299 return result; |
| 1296 } | 1300 } |
| 1297 | 1301 |
| 1298 bool get hasConstructor { | 1302 bool get hasConstructor { |
| 1299 // Search in scope to be sure we search patched constructors. | 1303 // Search in scope to be sure we search patched constructors. |
| 1300 for (var element in localScope.getValues()) { | 1304 for (var element in localScope.getValues()) { |
| 1301 if (element.isConstructor()) return true; | 1305 if (element.isConstructor()) return true; |
| 1302 } | 1306 } |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1691 | 1695 |
| 1692 MetadataAnnotation ensureResolved(Compiler compiler) { | 1696 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1693 if (resolutionState == STATE_NOT_STARTED) { | 1697 if (resolutionState == STATE_NOT_STARTED) { |
| 1694 compiler.resolver.resolveMetadataAnnotation(this); | 1698 compiler.resolver.resolveMetadataAnnotation(this); |
| 1695 } | 1699 } |
| 1696 return this; | 1700 return this; |
| 1697 } | 1701 } |
| 1698 | 1702 |
| 1699 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1703 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1700 } | 1704 } |
| OLD | NEW |