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 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 lookupConstructor(Selector selector, [Element noMatch(Element)]) { |
| 1407 [SourceString constructorName = | |
| 1408 const SourceString(''), | |
| 1409 Element noMatch(Element)]) { | |
| 1410 // TODO(karlklose): have a map from class names to a map of constructors | 1407 // TODO(karlklose): have a map from class names to a map of constructors |
| 1411 // instead of creating the name here? | 1408 // instead of creating the name here? |
| 1412 SourceString normalizedName; | 1409 Element result = localLookup(selector.normalizedConstructorName); |
|
kasperl
2012/10/08 08:06:41
Can't you construct the normalized constructor nam
aam-me
2012/10/09 04:08:42
Thanks for the tips. I gave it a try.
| |
| 1413 if (constructorName !== const SourceString('')) { | 1410 if (result === null |
| 1414 normalizedName = Elements.constructConstructorName(className, | 1411 || !result.isConstructor() |
| 1415 constructorName); | 1412 || (selector.name.isPrivate() |
| 1416 } else { | 1413 && result.getLibrary() != selector.library)) { |
| 1417 normalizedName = className; | |
| 1418 } | |
| 1419 Element result = localLookup(normalizedName); | |
| 1420 if (result === null || !result.isConstructor()) { | |
| 1421 result = noMatch !== null ? noMatch(result) : null; | 1414 result = noMatch !== null ? noMatch(result) : null; |
| 1422 } | 1415 } |
| 1423 return result; | 1416 return result; |
| 1424 } | 1417 } |
| 1425 | 1418 |
| 1426 bool get hasConstructor { | 1419 bool get hasConstructor { |
| 1427 // Search in scope to be sure we search patched constructors. | 1420 // Search in scope to be sure we search patched constructors. |
| 1428 for (var element in localScope.getValues()) { | 1421 for (var element in localScope.getValues()) { |
| 1429 if (element.isConstructor()) return true; | 1422 if (element.isConstructor()) return true; |
| 1430 } | 1423 } |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1873 | 1866 |
| 1874 MetadataAnnotation ensureResolved(Compiler compiler) { | 1867 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1875 if (resolutionState == STATE_NOT_STARTED) { | 1868 if (resolutionState == STATE_NOT_STARTED) { |
| 1876 compiler.resolver.resolveMetadataAnnotation(this); | 1869 compiler.resolver.resolveMetadataAnnotation(this); |
| 1877 } | 1870 } |
| 1878 return this; | 1871 return this; |
| 1879 } | 1872 } |
| 1880 | 1873 |
| 1881 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1874 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1882 } | 1875 } |
| OLD | NEW |