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 // 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 DartType computeType(Compiler compiler) { | 141 DartType computeType(Compiler compiler) { |
| 142 compiler.internalError("$this.computeType.", token: position()); | 142 compiler.internalError("$this.computeType.", token: position()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void addMetadata(MetadataAnnotation annotation) { | 145 void addMetadata(MetadataAnnotation annotation) { |
| 146 assert(annotation.annotatedElement == null); | 146 assert(annotation.annotatedElement == null); |
| 147 annotation.annotatedElement = this; | 147 annotation.annotatedElement = this; |
| 148 metadata = metadata.prepend(annotation); | 148 metadata = metadata.prepend(annotation); |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool hasSignature() => isFunction() || isConstructor(); | |
|
ahe
2012/10/25 14:07:27
Let's try to add documentation comments to these m
karlklose
2012/10/26 11:08:48
Done.
| |
| 151 bool isFunction() => identical(kind, ElementKind.FUNCTION); | 152 bool isFunction() => identical(kind, ElementKind.FUNCTION); |
| 152 bool isConstructor() => isFactoryConstructor() || isGenerativeConstructor(); | 153 bool isConstructor() => isFactoryConstructor() || isGenerativeConstructor(); |
| 153 bool isClosure() => false; | 154 bool isClosure() => false; |
| 154 bool isMember() { | 155 bool isMember() { |
| 155 // Check that this element is defined in the scope of a Class. | 156 // Check that this element is defined in the scope of a Class. |
| 156 return enclosingElement != null && enclosingElement.isClass(); | 157 return enclosingElement != null && enclosingElement.isClass(); |
| 157 } | 158 } |
| 158 bool isInstanceMember() => false; | 159 bool isInstanceMember() => false; |
| 159 bool isFactoryConstructor() => modifiers.isFactory(); | 160 bool isFactoryConstructor() => modifiers.isFactory(); |
| 160 bool isGenerativeConstructor() => | 161 bool isGenerativeConstructor() => |
| (...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1645 return 'origin ${super.toString()}'; | 1646 return 'origin ${super.toString()}'; |
| 1646 } else { | 1647 } else { |
| 1647 return super.toString(); | 1648 return super.toString(); |
| 1648 } | 1649 } |
| 1649 } | 1650 } |
| 1650 } | 1651 } |
| 1651 | 1652 |
| 1652 class Elements { | 1653 class Elements { |
| 1653 static bool isUnresolved(Element e) => e == null || e.isErroneous(); | 1654 static bool isUnresolved(Element e) => e == null || e.isErroneous(); |
| 1654 static bool isErroneousElement(Element e) => e != null && e.isErroneous(); | 1655 static bool isErroneousElement(Element e) => e != null && e.isErroneous(); |
| 1656 static bool isValid(Element e) => !isUnresolved(e); | |
|
ahe
2012/10/25 14:07:27
A documentation comment would also be great here.
karlklose
2012/10/26 11:08:48
Done.
| |
| 1655 | 1657 |
| 1656 static bool isLocal(Element element) { | 1658 static bool isLocal(Element element) { |
| 1657 return !Elements.isUnresolved(element) | 1659 return !Elements.isUnresolved(element) |
| 1658 && !element.isInstanceMember() | 1660 && !element.isInstanceMember() |
| 1659 && !isStaticOrTopLevelField(element) | 1661 && !isStaticOrTopLevelField(element) |
| 1660 && !isStaticOrTopLevelFunction(element) | 1662 && !isStaticOrTopLevelFunction(element) |
| 1661 && (identical(element.kind, ElementKind.VARIABLE) || | 1663 && (identical(element.kind, ElementKind.VARIABLE) || |
| 1662 identical(element.kind, ElementKind.PARAMETER) || | 1664 identical(element.kind, ElementKind.PARAMETER) || |
| 1663 identical(element.kind, ElementKind.FUNCTION)); | 1665 identical(element.kind, ElementKind.FUNCTION)); |
| 1664 } | 1666 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1935 | 1937 |
| 1936 MetadataAnnotation ensureResolved(Compiler compiler) { | 1938 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1937 if (resolutionState == STATE_NOT_STARTED) { | 1939 if (resolutionState == STATE_NOT_STARTED) { |
| 1938 compiler.resolver.resolveMetadataAnnotation(this); | 1940 compiler.resolver.resolveMetadataAnnotation(this); |
| 1939 } | 1941 } |
| 1940 return this; | 1942 return this; |
| 1941 } | 1943 } |
| 1942 | 1944 |
| 1943 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1945 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1944 } | 1946 } |
| OLD | NEW |