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 'elements.dart'; | 7 import 'elements.dart'; |
8 import '../tree/tree.dart'; | 8 import '../tree/tree.dart'; |
9 import '../util/util.dart'; | 9 import '../util/util.dart'; |
10 import '../resolution/resolution.dart'; | 10 import '../resolution/resolution.dart'; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 Element getOutermostEnclosingMemberOrTopLevel() { | 253 Element getOutermostEnclosingMemberOrTopLevel() { |
254 // TODO(lrn): Why is this called "Outermost"? | 254 // TODO(lrn): Why is this called "Outermost"? |
255 for (Element e = this; e != null; e = e.enclosingElement) { | 255 for (Element e = this; e != null; e = e.enclosingElement) { |
256 if (e.isMember() || e.isTopLevel()) { | 256 if (e.isMember() || e.isTopLevel()) { |
257 return e; | 257 return e; |
258 } | 258 } |
259 } | 259 } |
260 return null; | 260 return null; |
261 } | 261 } |
262 | 262 |
263 ClassElement get contextClass { | |
264 ClassElement cls; | |
265 for (Element e = this; e != null; e = e.enclosingElement) { | |
266 if (e.isClass()) { | |
267 cls = e.declaration; | |
karlklose
2014/05/07 12:46:37
Break or return value here?
Johnni Winther
2014/05/08 07:03:59
No. We need the last class -- the first might be a
| |
268 } | |
269 } | |
270 return cls; | |
271 } | |
272 | |
263 /** | 273 /** |
264 * Creates the scope for this element. | 274 * Creates the scope for this element. |
265 */ | 275 */ |
266 Scope buildScope() => enclosingElement.buildScope(); | 276 Scope buildScope() => enclosingElement.buildScope(); |
267 | 277 |
268 String toString() { | 278 String toString() { |
269 // TODO(johnniwinther): Test for nullness of name, or make non-nullness an | 279 // TODO(johnniwinther): Test for nullness of name, or make non-nullness an |
270 // invariant for all element types? | 280 // invariant for all element types? |
271 var nameText = name != null ? name : '?'; | 281 var nameText = name != null ? name : '?'; |
272 if (enclosingElement != null && !isTopLevel()) { | 282 if (enclosingElement != null && !isTopLevel()) { |
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1969 } | 1979 } |
1970 } | 1980 } |
1971 } | 1981 } |
1972 | 1982 |
1973 InterfaceType createType(Link<DartType> typeArguments) { | 1983 InterfaceType createType(Link<DartType> typeArguments) { |
1974 return new InterfaceType(this, typeArguments); | 1984 return new InterfaceType(this, typeArguments); |
1975 } | 1985 } |
1976 | 1986 |
1977 Link<DartType> computeTypeParameters(Compiler compiler); | 1987 Link<DartType> computeTypeParameters(Compiler compiler); |
1978 | 1988 |
1989 InterfaceType asInstanceOf(ClassElement cls) { | |
1990 if (cls == this) return thisType; | |
1991 return allSupertypesAndSelf.asInstanceOf(cls); | |
1992 } | |
1993 | |
1979 /** | 1994 /** |
1980 * Return [:true:] if this element is the [:Object:] class for the [compiler]. | 1995 * Return [:true:] if this element is the [:Object:] class for the [compiler]. |
1981 */ | 1996 */ |
1982 bool isObject(Compiler compiler) => | 1997 bool isObject(Compiler compiler) => |
1983 identical(declaration, compiler.objectClass); | 1998 identical(declaration, compiler.objectClass); |
1984 | 1999 |
1985 void ensureResolved(Compiler compiler) { | 2000 void ensureResolved(Compiler compiler) { |
1986 if (resolutionState == STATE_NOT_STARTED) { | 2001 if (resolutionState == STATE_NOT_STARTED) { |
1987 compiler.resolver.resolveClass(this); | 2002 compiler.resolver.resolveClass(this); |
1988 } | 2003 } |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2619 | 2634 |
2620 ParameterMetadataAnnotation(Metadata this.metadata); | 2635 ParameterMetadataAnnotation(Metadata this.metadata); |
2621 | 2636 |
2622 Node parseNode(DiagnosticListener listener) => metadata.expression; | 2637 Node parseNode(DiagnosticListener listener) => metadata.expression; |
2623 | 2638 |
2624 Token get beginToken => metadata.getBeginToken(); | 2639 Token get beginToken => metadata.getBeginToken(); |
2625 | 2640 |
2626 Token get endToken => metadata.getEndToken(); | 2641 Token get endToken => metadata.getEndToken(); |
2627 } | 2642 } |
2628 | 2643 |
OLD | NEW |