| 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 'dart:uri'; | 7 import 'dart:uri'; |
| 8 import 'dart:collection' show LinkedHashMap; | 8 import 'dart:collection' show LinkedHashMap; |
| 9 | 9 |
| 10 import 'elements.dart'; | 10 import 'elements.dart'; |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 DartType type; | 1085 DartType type; |
| 1086 final Modifiers modifiers; | 1086 final Modifiers modifiers; |
| 1087 | 1087 |
| 1088 FunctionSignature functionSignature; | 1088 FunctionSignature functionSignature; |
| 1089 | 1089 |
| 1090 /** | 1090 /** |
| 1091 * A function declaration that should be parsed instead of the current one. | 1091 * A function declaration that should be parsed instead of the current one. |
| 1092 * The patch should be parsed as if it was in the current scope. Its | 1092 * The patch should be parsed as if it was in the current scope. Its |
| 1093 * signature must match this function's signature. | 1093 * signature must match this function's signature. |
| 1094 */ | 1094 */ |
| 1095 // TODO(lrn): Consider using [defaultImplementation] to store the patch. | |
| 1096 FunctionElement patch = null; | 1095 FunctionElement patch = null; |
| 1097 FunctionElement origin = null; | 1096 FunctionElement origin = null; |
| 1098 | 1097 |
| 1099 /** | 1098 /** |
| 1100 * If this is a redirecting factory, [defaultImplementation] will be | 1099 * If this is a redirecting factory, [defaultImplementation] will be |
| 1101 * changed by the resolver to point to the redirection target. If | 1100 * changed by the resolver to point to the redirection target. |
| 1102 * this is an interface constructor, [defaultImplementation] will be | |
| 1103 * changed by the resolver to point to the default implementation. | |
| 1104 * Otherwise, [:identical(defaultImplementation, this):]. | 1101 * Otherwise, [:identical(defaultImplementation, this):]. |
| 1105 */ | 1102 */ |
| 1106 // TODO(ahe): Rename this field to redirectionTarget and remove | 1103 // TODO(ahe): Rename this field to redirectionTarget. |
| 1107 // mention of interface constructors above. | |
| 1108 FunctionElement defaultImplementation; | 1104 FunctionElement defaultImplementation; |
| 1109 | 1105 |
| 1110 FunctionElementX(SourceString name, | 1106 FunctionElementX(SourceString name, |
| 1111 ElementKind kind, | 1107 ElementKind kind, |
| 1112 Modifiers modifiers, | 1108 Modifiers modifiers, |
| 1113 Element enclosing) | 1109 Element enclosing) |
| 1114 : this.tooMuchOverloading(name, null, kind, modifiers, enclosing, null); | 1110 : this.tooMuchOverloading(name, null, kind, modifiers, enclosing, null); |
| 1115 | 1111 |
| 1116 FunctionElementX.node(SourceString name, | 1112 FunctionElementX.node(SourceString name, |
| 1117 FunctionExpression node, | 1113 FunctionExpression node, |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 * type arguments. For instance should [:List:] be the [rawType] of the | 1398 * type arguments. For instance should [:List:] be the [rawType] of the |
| 1403 * [:List:] class element whereas [:List<dynamic>:] should be its own | 1399 * [:List:] class element whereas [:List<dynamic>:] should be its own |
| 1404 * instantiation of [InterfaceType] with [:dynamic:] as type argument. Using | 1400 * instantiation of [InterfaceType] with [:dynamic:] as type argument. Using |
| 1405 * this distinction, we can print the raw type with type arguments only when | 1401 * this distinction, we can print the raw type with type arguments only when |
| 1406 * the input source has used explicit type arguments. | 1402 * the input source has used explicit type arguments. |
| 1407 * | 1403 * |
| 1408 * This type is computed together with [thisType] in [computeType]. | 1404 * This type is computed together with [thisType] in [computeType]. |
| 1409 */ | 1405 */ |
| 1410 InterfaceType rawTypeCache; | 1406 InterfaceType rawTypeCache; |
| 1411 DartType supertype; | 1407 DartType supertype; |
| 1412 DartType defaultClass; | |
| 1413 Link<DartType> interfaces; | 1408 Link<DartType> interfaces; |
| 1414 SourceString nativeTagInfo; | 1409 SourceString nativeTagInfo; |
| 1415 int supertypeLoadState; | 1410 int supertypeLoadState; |
| 1416 int resolutionState; | 1411 int resolutionState; |
| 1417 | 1412 |
| 1418 // backendMembers are members that have been added by the backend to simplify | 1413 // backendMembers are members that have been added by the backend to simplify |
| 1419 // compilation. They don't have any user-side counter-part. | 1414 // compilation. They don't have any user-side counter-part. |
| 1420 Link<Element> backendMembers = const Link<Element>(); | 1415 Link<Element> backendMembers = const Link<Element>(); |
| 1421 | 1416 |
| 1422 Link<DartType> allSupertypes; | 1417 Link<DartType> allSupertypes; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 bool isPrivate = memberName.isPrivate(); | 1528 bool isPrivate = memberName.isPrivate(); |
| 1534 for (ClassElement s = superclass; s != null; s = s.superclass) { | 1529 for (ClassElement s = superclass; s != null; s = s.superclass) { |
| 1535 // Private members from a different library are not visible. | 1530 // Private members from a different library are not visible. |
| 1536 if (isPrivate && !identical(library, s.getLibrary())) continue; | 1531 if (isPrivate && !identical(library, s.getLibrary())) continue; |
| 1537 Element e = s.lookupLocalMember(memberName); | 1532 Element e = s.lookupLocalMember(memberName); |
| 1538 if (e == null) continue; | 1533 if (e == null) continue; |
| 1539 // Static members are not inherited. | 1534 // Static members are not inherited. |
| 1540 if (e.modifiers.isStatic()) continue; | 1535 if (e.modifiers.isStatic()) continue; |
| 1541 return e; | 1536 return e; |
| 1542 } | 1537 } |
| 1543 if (isInterface()) { | |
| 1544 return lookupSuperInterfaceMember(memberName, getLibrary()); | |
| 1545 } | |
| 1546 return null; | 1538 return null; |
| 1547 } | 1539 } |
| 1548 | 1540 |
| 1549 Element lookupSuperInterfaceMember(SourceString memberName, | 1541 Element lookupSuperInterfaceMember(SourceString memberName, |
| 1550 LibraryElement fromLibrary) { | 1542 LibraryElement fromLibrary) { |
| 1551 bool isPrivate = memberName.isPrivate(); | 1543 bool isPrivate = memberName.isPrivate(); |
| 1552 for (InterfaceType t in interfaces) { | 1544 for (InterfaceType t in interfaces) { |
| 1553 ClassElement cls = t.element; | 1545 ClassElement cls = t.element; |
| 1554 Element e = cls.lookupLocalMember(memberName); | 1546 Element e = cls.lookupLocalMember(memberName); |
| 1555 if (e == null) continue; | 1547 if (e == null) continue; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1800 bool isSubclassOf(ClassElement cls) { | 1792 bool isSubclassOf(ClassElement cls) { |
| 1801 // Use [declaration] for both [this] and [cls], because | 1793 // Use [declaration] for both [this] and [cls], because |
| 1802 // declaration classes hold the superclass hierarchy. | 1794 // declaration classes hold the superclass hierarchy. |
| 1803 cls = cls.declaration; | 1795 cls = cls.declaration; |
| 1804 for (ClassElement s = declaration; s != null; s = s.superclass) { | 1796 for (ClassElement s = declaration; s != null; s = s.superclass) { |
| 1805 if (identical(s, cls)) return true; | 1797 if (identical(s, cls)) return true; |
| 1806 } | 1798 } |
| 1807 return false; | 1799 return false; |
| 1808 } | 1800 } |
| 1809 | 1801 |
| 1810 bool isInterface() => false; | |
| 1811 bool isNative() => nativeTagInfo != null; | 1802 bool isNative() => nativeTagInfo != null; |
| 1812 void setNative(String name) { | 1803 void setNative(String name) { |
| 1813 nativeTagInfo = new SourceString(name); | 1804 nativeTagInfo = new SourceString(name); |
| 1814 } | 1805 } |
| 1815 } | 1806 } |
| 1816 | 1807 |
| 1817 abstract class ClassElementX extends BaseClassElementX { | 1808 abstract class ClassElementX extends BaseClassElementX { |
| 1818 // Lazily applied patch of class members. | 1809 // Lazily applied patch of class members. |
| 1819 ClassElement patch = null; | 1810 ClassElement patch = null; |
| 1820 ClassElement origin = null; | 1811 ClassElement origin = null; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 | 2075 |
| 2085 MetadataAnnotation ensureResolved(Compiler compiler) { | 2076 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2086 if (resolutionState == STATE_NOT_STARTED) { | 2077 if (resolutionState == STATE_NOT_STARTED) { |
| 2087 compiler.resolver.resolveMetadataAnnotation(this); | 2078 compiler.resolver.resolveMetadataAnnotation(this); |
| 2088 } | 2079 } |
| 2089 return this; | 2080 return this; |
| 2090 } | 2081 } |
| 2091 | 2082 |
| 2092 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2083 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2093 } | 2084 } |
| OLD | NEW |