| 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 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. | 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. |
| 10 import '../../compiler.dart' as api_e; | 10 import '../../compiler.dart' as api_e; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const ElementKind('statement', ElementCategory.NONE); | 113 const ElementKind('statement', ElementCategory.NONE); |
| 114 static const ElementKind LABEL = | 114 static const ElementKind LABEL = |
| 115 const ElementKind('label', ElementCategory.NONE); | 115 const ElementKind('label', ElementCategory.NONE); |
| 116 static const ElementKind VOID = | 116 static const ElementKind VOID = |
| 117 const ElementKind('void', ElementCategory.NONE); | 117 const ElementKind('void', ElementCategory.NONE); |
| 118 | 118 |
| 119 static const ElementKind AMBIGUOUS = | 119 static const ElementKind AMBIGUOUS = |
| 120 const ElementKind('ambiguous', ElementCategory.NONE); | 120 const ElementKind('ambiguous', ElementCategory.NONE); |
| 121 static const ElementKind ERROR = | 121 static const ElementKind ERROR = |
| 122 const ElementKind('error', ElementCategory.NONE); | 122 const ElementKind('error', ElementCategory.NONE); |
| 123 static const ElementKind MALFORMED_TYPE = |
| 124 const ElementKind('malformed', ElementCategory.NONE); |
| 123 | 125 |
| 124 toString() => id; | 126 toString() => id; |
| 125 } | 127 } |
| 126 | 128 |
| 127 class Element implements Spannable { | 129 class Element implements Spannable { |
| 128 static int elementHashCode = 0; | 130 static int elementHashCode = 0; |
| 129 | 131 |
| 130 final SourceString name; | 132 final SourceString name; |
| 131 final ElementKind kind; | 133 final ElementKind kind; |
| 132 final Element enclosingElement; | 134 final Element enclosingElement; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 bool isLibrary() => identical(kind, ElementKind.LIBRARY); | 195 bool isLibrary() => identical(kind, ElementKind.LIBRARY); |
| 194 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; | 196 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; |
| 195 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; | 197 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; |
| 196 | 198 |
| 197 /** See [ErroneousElement] for documentation. */ | 199 /** See [ErroneousElement] for documentation. */ |
| 198 bool isErroneous() => false; | 200 bool isErroneous() => false; |
| 199 | 201 |
| 200 /** See [AmbiguousElement] for documentation. */ | 202 /** See [AmbiguousElement] for documentation. */ |
| 201 bool isAmbiguous() => false; | 203 bool isAmbiguous() => false; |
| 202 | 204 |
| 205 bool isMalformed() => false; |
| 206 |
| 203 /** | 207 /** |
| 204 * Is [:true:] if this element has a corresponding patch. | 208 * Is [:true:] if this element has a corresponding patch. |
| 205 * | 209 * |
| 206 * If [:true:] this element has a non-null [patch] field. | 210 * If [:true:] this element has a non-null [patch] field. |
| 207 * | 211 * |
| 208 * See [:patch_parser.dart:] for a description of the terminology. | 212 * See [:patch_parser.dart:] for a description of the terminology. |
| 209 */ | 213 */ |
| 210 bool get isPatched => false; | 214 bool get isPatched => false; |
| 211 | 215 |
| 212 /** | 216 /** |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 class VoidElement extends Element { | 1316 class VoidElement extends Element { |
| 1313 VoidElement(Element enclosing) | 1317 VoidElement(Element enclosing) |
| 1314 : super(const SourceString('void'), ElementKind.VOID, enclosing); | 1318 : super(const SourceString('void'), ElementKind.VOID, enclosing); |
| 1315 DartType computeType(compiler) => compiler.types.voidType; | 1319 DartType computeType(compiler) => compiler.types.voidType; |
| 1316 Node parseNode(_) { | 1320 Node parseNode(_) { |
| 1317 throw 'internal error: parseNode on void'; | 1321 throw 'internal error: parseNode on void'; |
| 1318 } | 1322 } |
| 1319 bool impliesType() => true; | 1323 bool impliesType() => true; |
| 1320 } | 1324 } |
| 1321 | 1325 |
| 1326 class MalformedTypeElement extends Element { |
| 1327 final TypeAnnotation typeNode; |
| 1328 |
| 1329 MalformedTypeElement(this.typeNode, Element enclosing) |
| 1330 : super(const SourceString('malformed'), |
| 1331 ElementKind.MALFORMED_TYPE, |
| 1332 enclosing); |
| 1333 |
| 1334 DartType computeType(compiler) => compiler.types.malformedType; |
| 1335 |
| 1336 Node parseNode(_) => typeNode; |
| 1337 |
| 1338 bool impliesType() => true; |
| 1339 |
| 1340 bool isMalformed() => true; |
| 1341 } |
| 1342 |
| 1322 /** | 1343 /** |
| 1323 * [TypeDeclarationElement] defines the common interface for class/interface | 1344 * [TypeDeclarationElement] defines the common interface for class/interface |
| 1324 * declarations and typedefs. | 1345 * declarations and typedefs. |
| 1325 */ | 1346 */ |
| 1326 abstract class TypeDeclarationElement implements Element { | 1347 abstract class TypeDeclarationElement implements Element { |
| 1327 // TODO(johnniwinther): This class should eventually be a mixin. | 1348 // TODO(johnniwinther): This class should eventually be a mixin. |
| 1328 | 1349 |
| 1329 /** | 1350 /** |
| 1330 * The type variables declared on this declaration. The type variables are not | 1351 * The type variables declared on this declaration. The type variables are not |
| 1331 * available until the type of the element has been computed through | 1352 * available until the type of the element has been computed through |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1717 return 'patch ${super.toString()}'; | 1738 return 'patch ${super.toString()}'; |
| 1718 } else if (patch != null) { | 1739 } else if (patch != null) { |
| 1719 return 'origin ${super.toString()}'; | 1740 return 'origin ${super.toString()}'; |
| 1720 } else { | 1741 } else { |
| 1721 return super.toString(); | 1742 return super.toString(); |
| 1722 } | 1743 } |
| 1723 } | 1744 } |
| 1724 } | 1745 } |
| 1725 | 1746 |
| 1726 class Elements { | 1747 class Elements { |
| 1727 static bool isUnresolved(Element e) => e == null || e.isErroneous(); | 1748 static bool isUnresolved(Element e) { |
| 1749 return e == null || e.isErroneous() || e.isMalformed(); |
| 1750 } |
| 1728 static bool isErroneousElement(Element e) => e != null && e.isErroneous(); | 1751 static bool isErroneousElement(Element e) => e != null && e.isErroneous(); |
| 1752 static bool isMalformedElement(Element e) => e != null && e.isMalformed(); |
| 1729 | 1753 |
| 1730 static bool isClass(Element e) => e != null && e.kind == ElementKind.CLASS; | 1754 static bool isClass(Element e) => e != null && e.kind == ElementKind.CLASS; |
| 1731 static bool isTypedef(Element e) { | 1755 static bool isTypedef(Element e) { |
| 1732 return e != null && e.kind == ElementKind.TYPEDEF; | 1756 return e != null && e.kind == ElementKind.TYPEDEF; |
| 1733 } | 1757 } |
| 1734 | 1758 |
| 1735 static bool isLocal(Element element) { | 1759 static bool isLocal(Element element) { |
| 1736 return !Elements.isUnresolved(element) | 1760 return !Elements.isUnresolved(element) |
| 1737 && !element.isInstanceMember() | 1761 && !element.isInstanceMember() |
| 1738 && !isStaticOrTopLevelField(element) | 1762 && !isStaticOrTopLevelField(element) |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 | 2075 |
| 2052 MetadataAnnotation ensureResolved(Compiler compiler) { | 2076 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2053 if (resolutionState == STATE_NOT_STARTED) { | 2077 if (resolutionState == STATE_NOT_STARTED) { |
| 2054 compiler.resolver.resolveMetadataAnnotation(this); | 2078 compiler.resolver.resolveMetadataAnnotation(this); |
| 2055 } | 2079 } |
| 2056 return this; | 2080 return this; |
| 2057 } | 2081 } |
| 2058 | 2082 |
| 2059 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2083 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2060 } | 2084 } |
| OLD | NEW |