| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'elements.dart'; | 7 import 'elements.dart'; |
| 8 import '../../compiler.dart' as api; | 8 import '../../compiler.dart' as api; |
| 9 import '../tree/tree.dart'; | 9 import '../tree/tree.dart'; |
| 10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 void setNative(String name) { | 280 void setNative(String name) { |
| 281 _isNative = true; | 281 _isNative = true; |
| 282 _fixedBackendName = name; | 282 _fixedBackendName = name; |
| 283 } | 283 } |
| 284 void setFixedBackendName(String name) { | 284 void setFixedBackendName(String name) { |
| 285 _fixedBackendName = name; | 285 _fixedBackendName = name; |
| 286 } | 286 } |
| 287 | 287 |
| 288 FunctionElement asFunctionElement() => null; | 288 FunctionElement asFunctionElement() => null; |
| 289 | 289 |
| 290 static bool isInvalid(Element e) => e == null || e.isErroneous(); | |
| 291 | |
| 292 bool get isAbstract => modifiers.isAbstract(); | 290 bool get isAbstract => modifiers.isAbstract(); |
| 293 bool isForeign(Compiler compiler) => getLibrary() == compiler.foreignLibrary; | 291 bool isForeign(Compiler compiler) => getLibrary() == compiler.foreignLibrary; |
| 294 | 292 |
| 295 FunctionElement get targetConstructor => null; | 293 FunctionElement get targetConstructor => null; |
| 296 | 294 |
| 297 void diagnose(Element context, DiagnosticListener listener) {} | 295 void diagnose(Element context, DiagnosticListener listener) {} |
| 298 } | 296 } |
| 299 | 297 |
| 300 /** | 298 /** |
| 301 * Represents an unresolvable or duplicated element. | 299 * Represents an unresolvable or duplicated element. |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1865 if (isPrivate && !identical(library, s.getLibrary())) continue; | 1863 if (isPrivate && !identical(library, s.getLibrary())) continue; |
| 1866 Element e = s.lookupLocalMember(memberName); | 1864 Element e = s.lookupLocalMember(memberName); |
| 1867 if (e == null) continue; | 1865 if (e == null) continue; |
| 1868 // Static members are not inherited. | 1866 // Static members are not inherited. |
| 1869 if (e.modifiers.isStatic()) continue; | 1867 if (e.modifiers.isStatic()) continue; |
| 1870 return e; | 1868 return e; |
| 1871 } | 1869 } |
| 1872 return null; | 1870 return null; |
| 1873 } | 1871 } |
| 1874 | 1872 |
| 1875 Element lookupSuperInterfaceMember(String memberName, | |
| 1876 LibraryElement fromLibrary) { | |
| 1877 bool isPrivate = isPrivateName(memberName); | |
| 1878 for (InterfaceType t in interfaces) { | |
| 1879 ClassElement cls = t.element; | |
| 1880 Element e = cls.lookupLocalMember(memberName); | |
| 1881 if (e == null) continue; | |
| 1882 // Private members from a different library are not visible. | |
| 1883 if (isPrivate && !identical(fromLibrary, e.getLibrary())) continue; | |
| 1884 // Static members are not inherited. | |
| 1885 if (e.modifiers.isStatic()) continue; | |
| 1886 return e; | |
| 1887 } | |
| 1888 return null; | |
| 1889 } | |
| 1890 | |
| 1891 /** | 1873 /** |
| 1892 * Find the first member in the class chain with the given [selector]. | 1874 * Find the first member in the class chain with the given [selector]. |
| 1893 * | 1875 * |
| 1894 * This method is NOT to be used for resolving | 1876 * This method is NOT to be used for resolving |
| 1895 * unqualified sends because it does not implement the scoping | 1877 * unqualified sends because it does not implement the scoping |
| 1896 * rules, where library scope comes before superclass scope. | 1878 * rules, where library scope comes before superclass scope. |
| 1897 * | 1879 * |
| 1898 * When called on the implementation element both members declared in the | 1880 * When called on the implementation element both members declared in the |
| 1899 * origin and the patch class are returned. | 1881 * origin and the patch class are returned. |
| 1900 */ | 1882 */ |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 } | 1983 } |
| 2002 | 1984 |
| 2003 // TODO(aprelev@gmail.com): Peter believes that it would be great to | 1985 // TODO(aprelev@gmail.com): Peter believes that it would be great to |
| 2004 // make noMatch a required argument. Peter's suspicion is that most | 1986 // make noMatch a required argument. Peter's suspicion is that most |
| 2005 // callers of this method would benefit from using the noMatch method. | 1987 // callers of this method would benefit from using the noMatch method. |
| 2006 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) { | 1988 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) { |
| 2007 Element result = localLookup(selector.name); | 1989 Element result = localLookup(selector.name); |
| 2008 return validateConstructorLookupResults(selector, result, noMatch); | 1990 return validateConstructorLookupResults(selector, result, noMatch); |
| 2009 } | 1991 } |
| 2010 | 1992 |
| 2011 Element lookupFactoryConstructor(Selector selector, | |
| 2012 [Element noMatch(Element)]) { | |
| 2013 String constructorName = selector.name; | |
| 2014 Element result = localLookup(constructorName); | |
| 2015 return validateConstructorLookupResults(selector, result, noMatch); | |
| 2016 } | |
| 2017 | |
| 2018 Link<Element> get constructors { | 1993 Link<Element> get constructors { |
| 2019 // TODO(ajohnsen): See if we can avoid this method at some point. | 1994 // TODO(ajohnsen): See if we can avoid this method at some point. |
| 2020 Link<Element> result = const Link<Element>(); | 1995 Link<Element> result = const Link<Element>(); |
| 2021 // TODO(johnniwinther): Should we include injected constructors? | 1996 // TODO(johnniwinther): Should we include injected constructors? |
| 2022 forEachMember((_, Element member) { | 1997 forEachMember((_, Element member) { |
| 2023 if (member.isConstructor()) result = result.prepend(member); | 1998 if (member.isConstructor()) result = result.prepend(member); |
| 2024 }); | 1999 }); |
| 2025 return result; | 2000 return result; |
| 2026 } | 2001 } |
| 2027 | 2002 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2434 | 2409 |
| 2435 MetadataAnnotation ensureResolved(Compiler compiler) { | 2410 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2436 if (resolutionState == STATE_NOT_STARTED) { | 2411 if (resolutionState == STATE_NOT_STARTED) { |
| 2437 compiler.resolver.resolveMetadataAnnotation(this); | 2412 compiler.resolver.resolveMetadataAnnotation(this); |
| 2438 } | 2413 } |
| 2439 return this; | 2414 return this; |
| 2440 } | 2415 } |
| 2441 | 2416 |
| 2442 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2417 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2443 } | 2418 } |
| OLD | NEW |