| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 bool isLibrary() => identical(kind, ElementKind.LIBRARY); | 195 bool isLibrary() => identical(kind, ElementKind.LIBRARY); |
| 196 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; | 196 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; |
| 197 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; | 197 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; |
| 198 | 198 |
| 199 /** See [ErroneousElement] for documentation. */ | 199 /** See [ErroneousElement] for documentation. */ |
| 200 bool isErroneous() => false; | 200 bool isErroneous() => false; |
| 201 | 201 |
| 202 /** See [AmbiguousElement] for documentation. */ | 202 /** See [AmbiguousElement] for documentation. */ |
| 203 bool isAmbiguous() => false; | 203 bool isAmbiguous() => false; |
| 204 | 204 |
| 205 bool isMalformed() => false; | |
| 206 | |
| 207 /** | 205 /** |
| 208 * Is [:true:] if this element has a corresponding patch. | 206 * Is [:true:] if this element has a corresponding patch. |
| 209 * | 207 * |
| 210 * If [:true:] this element has a non-null [patch] field. | 208 * If [:true:] this element has a non-null [patch] field. |
| 211 * | 209 * |
| 212 * See [:patch_parser.dart:] for a description of the terminology. | 210 * See [:patch_parser.dart:] for a description of the terminology. |
| 213 */ | 211 */ |
| 214 bool get isPatched => false; | 212 bool get isPatched => false; |
| 215 | 213 |
| 216 /** | 214 /** |
| (...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 class VoidElement extends Element { | 1337 class VoidElement extends Element { |
| 1340 VoidElement(Element enclosing) | 1338 VoidElement(Element enclosing) |
| 1341 : super(const SourceString('void'), ElementKind.VOID, enclosing); | 1339 : super(const SourceString('void'), ElementKind.VOID, enclosing); |
| 1342 DartType computeType(compiler) => compiler.types.voidType; | 1340 DartType computeType(compiler) => compiler.types.voidType; |
| 1343 Node parseNode(_) { | 1341 Node parseNode(_) { |
| 1344 throw 'internal error: parseNode on void'; | 1342 throw 'internal error: parseNode on void'; |
| 1345 } | 1343 } |
| 1346 bool impliesType() => true; | 1344 bool impliesType() => true; |
| 1347 } | 1345 } |
| 1348 | 1346 |
| 1349 class MalformedTypeElement extends Element { | |
| 1350 final TypeAnnotation typeNode; | |
| 1351 | |
| 1352 MalformedTypeElement(this.typeNode, Element enclosing) | |
| 1353 : super(const SourceString('malformed'), | |
| 1354 ElementKind.MALFORMED_TYPE, | |
| 1355 enclosing); | |
| 1356 | |
| 1357 DartType computeType(compiler) => compiler.types.malformedType; | |
| 1358 | |
| 1359 Node parseNode(_) => typeNode; | |
| 1360 | |
| 1361 bool impliesType() => true; | |
| 1362 | |
| 1363 bool isMalformed() => true; | |
| 1364 } | |
| 1365 | |
| 1366 /** | 1347 /** |
| 1367 * [TypeDeclarationElement] defines the common interface for class/interface | 1348 * [TypeDeclarationElement] defines the common interface for class/interface |
| 1368 * declarations and typedefs. | 1349 * declarations and typedefs. |
| 1369 */ | 1350 */ |
| 1370 abstract class TypeDeclarationElement implements Element { | 1351 abstract class TypeDeclarationElement implements Element { |
| 1371 // TODO(johnniwinther): This class should eventually be a mixin. | 1352 // TODO(johnniwinther): This class should eventually be a mixin. |
| 1372 | 1353 |
| 1373 /** | 1354 /** |
| 1374 * The type variables declared on this declaration. The type variables are not | 1355 * The type variables declared on this declaration. The type variables are not |
| 1375 * available until the type of the element has been computed through | 1356 * available until the type of the element has been computed through |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 } else if (patch != null) { | 1779 } else if (patch != null) { |
| 1799 return 'origin ${super.toString()}'; | 1780 return 'origin ${super.toString()}'; |
| 1800 } else { | 1781 } else { |
| 1801 return super.toString(); | 1782 return super.toString(); |
| 1802 } | 1783 } |
| 1803 } | 1784 } |
| 1804 } | 1785 } |
| 1805 | 1786 |
| 1806 class Elements { | 1787 class Elements { |
| 1807 static bool isUnresolved(Element e) { | 1788 static bool isUnresolved(Element e) { |
| 1808 return e == null || e.isErroneous() || e.isMalformed(); | 1789 return e == null || e.isErroneous(); |
| 1809 } | 1790 } |
| 1810 static bool isErroneousElement(Element e) => e != null && e.isErroneous(); | 1791 static bool isErroneousElement(Element e) => e != null && e.isErroneous(); |
| 1811 static bool isMalformedElement(Element e) => e != null && e.isMalformed(); | |
| 1812 | 1792 |
| 1813 static bool isClass(Element e) => e != null && e.kind == ElementKind.CLASS; | 1793 static bool isClass(Element e) => e != null && e.kind == ElementKind.CLASS; |
| 1814 static bool isTypedef(Element e) { | 1794 static bool isTypedef(Element e) { |
| 1815 return e != null && e.kind == ElementKind.TYPEDEF; | 1795 return e != null && e.kind == ElementKind.TYPEDEF; |
| 1816 } | 1796 } |
| 1817 | 1797 |
| 1818 static bool isLocal(Element element) { | 1798 static bool isLocal(Element element) { |
| 1819 return !Elements.isUnresolved(element) | 1799 return !Elements.isUnresolved(element) |
| 1820 && !element.isInstanceMember() | 1800 && !element.isInstanceMember() |
| 1821 && !isStaticOrTopLevelField(element) | 1801 && !isStaticOrTopLevelField(element) |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2147 | 2127 |
| 2148 MetadataAnnotation ensureResolved(Compiler compiler) { | 2128 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2149 if (resolutionState == STATE_NOT_STARTED) { | 2129 if (resolutionState == STATE_NOT_STARTED) { |
| 2150 compiler.resolver.resolveMetadataAnnotation(this); | 2130 compiler.resolver.resolveMetadataAnnotation(this); |
| 2151 } | 2131 } |
| 2152 return this; | 2132 return this; |
| 2153 } | 2133 } |
| 2154 | 2134 |
| 2155 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2135 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2156 } | 2136 } |
| OLD | NEW |