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('../tree/tree.dart'); | 7 #import('../tree/tree.dart'); |
8 #import('../scanner/scannerlib.dart'); | 8 #import('../scanner/scannerlib.dart'); |
9 #import('../leg.dart'); // TODO(karlklose): we only need type. | 9 #import('../leg.dart'); // TODO(karlklose): we only need type. |
10 #import('../util/util.dart'); | 10 #import('../util/util.dart'); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 bool isTypedef() => kind === ElementKind.TYPEDEF; | 137 bool isTypedef() => kind === ElementKind.TYPEDEF; |
138 bool isTypeVariable() => kind === ElementKind.TYPE_VARIABLE; | 138 bool isTypeVariable() => kind === ElementKind.TYPE_VARIABLE; |
139 bool isField() => kind === ElementKind.FIELD; | 139 bool isField() => kind === ElementKind.FIELD; |
140 bool isGetter() => kind === ElementKind.GETTER; | 140 bool isGetter() => kind === ElementKind.GETTER; |
141 bool isSetter() => kind === ElementKind.SETTER; | 141 bool isSetter() => kind === ElementKind.SETTER; |
142 bool isAccessor() => isGetter() || isSetter(); | 142 bool isAccessor() => isGetter() || isSetter(); |
143 bool isForeign() => kind === ElementKind.FOREIGN; | 143 bool isForeign() => kind === ElementKind.FOREIGN; |
144 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; | 144 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; |
145 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; | 145 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; |
146 | 146 |
| 147 // TODO(johnniwinther): This breaks for libraries (for which enclosing |
| 148 // elements are null) and is invalid for top level variable declarations for |
| 149 // which the enclosing element is a VariableDeclarations and not a compilation |
| 150 // unit. |
147 bool isTopLevel() => enclosingElement.isCompilationUnit(); | 151 bool isTopLevel() => enclosingElement.isCompilationUnit(); |
148 | 152 |
149 bool isAssignable() { | 153 bool isAssignable() { |
150 if (modifiers != null && modifiers.isFinal()) return false; | 154 if (modifiers != null && modifiers.isFinal()) return false; |
151 if (isFunction() || isGenerativeConstructor()) return false; | 155 if (isFunction() || isGenerativeConstructor()) return false; |
152 return true; | 156 return true; |
153 } | 157 } |
154 | 158 |
155 Token position() => null; | 159 Token position() => null; |
156 | 160 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (e.isMember() || e.isTopLevel()) { | 209 if (e.isMember() || e.isTopLevel()) { |
206 return e; | 210 return e; |
207 } | 211 } |
208 } | 212 } |
209 return null; | 213 return null; |
210 } | 214 } |
211 | 215 |
212 String toString() { | 216 String toString() { |
213 // TODO(johnniwinther): Test for nullness of name, or make non-nullness an | 217 // TODO(johnniwinther): Test for nullness of name, or make non-nullness an |
214 // invariant for all element types. | 218 // invariant for all element types. |
215 if (!isTopLevel()) { | 219 if (enclosingElement !== null && !isTopLevel()) { |
216 String holderName = enclosingElement.name.slowToString(); | 220 String holderName = enclosingElement.name.slowToString(); |
217 return '$kind($holderName#${name.slowToString()})'; | 221 return '$kind($holderName#${name.slowToString()})'; |
218 } else { | 222 } else { |
219 return '$kind(${name.slowToString()})'; | 223 return '$kind(${name.slowToString()})'; |
220 } | 224 } |
221 } | 225 } |
222 | 226 |
223 bool _isNative = false; | 227 bool _isNative = false; |
224 void setNative() { _isNative = true; } | 228 void setNative() { _isNative = true; } |
225 bool isNative() => _isNative; | 229 bool isNative() => _isNative; |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 final Node node; | 1150 final Node node; |
1147 Type bound; | 1151 Type bound; |
1148 Type type; | 1152 Type type; |
1149 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1153 TypeVariableElement(name, Element enclosing, this.node, this.type, |
1150 [this.bound]) | 1154 [this.bound]) |
1151 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1155 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
1152 Type computeType(compiler) => type; | 1156 Type computeType(compiler) => type; |
1153 Node parseNode(compiler) => node; | 1157 Node parseNode(compiler) => node; |
1154 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1158 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
1155 } | 1159 } |
OLD | NEW |