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 #import('../tree/tree.dart'); | 9 #import('../tree/tree.dart'); |
10 #import('../scanner/scannerlib.dart'); | 10 #import('../scanner/scannerlib.dart'); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 bool _isNative = false; | 337 bool _isNative = false; |
338 void setNative() { _isNative = true; } | 338 void setNative() { _isNative = true; } |
339 bool isNative() => _isNative; | 339 bool isNative() => _isNative; |
340 | 340 |
341 FunctionElement asFunctionElement() => null; | 341 FunctionElement asFunctionElement() => null; |
342 | 342 |
343 static bool isInvalid(Element e) => e == null || e.isErroneous(); | 343 static bool isInvalid(Element e) => e == null || e.isErroneous(); |
344 | |
345 bool inStaticContext() { | |
346 return modifiers !== null && modifiers.isStatic(); | |
ahe
2012/10/04 07:51:02
Didn't Johnni land a change that ensures modifiers
aam-me
2012/10/10 02:48:40
Done.
| |
347 } | |
348 | |
344 Element cloneTo(Element enclosing, DiagnosticListener listener) { | 349 Element cloneTo(Element enclosing, DiagnosticListener listener) { |
345 listener.cancel("Unimplemented cloneTo", element: this); | 350 listener.cancel("Unimplemented cloneTo", element: this); |
346 } | 351 } |
347 } | 352 } |
348 | 353 |
349 /** | 354 /** |
350 * Represents an unresolvable or duplicated element. | 355 * Represents an unresolvable or duplicated element. |
351 * | 356 * |
352 * An [ErroneousElement] is used instead of [null] to provide additional | 357 * An [ErroneousElement] is used instead of [null] to provide additional |
353 * information about the error that caused the element to be unresolvable | 358 * information about the error that caused the element to be unresolvable |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
919 } else { | 924 } else { |
920 result = new VariableListElement(kind, modifiers, enclosing); | 925 result = new VariableListElement(kind, modifiers, enclosing); |
921 } | 926 } |
922 return result; | 927 return result; |
923 } | 928 } |
924 | 929 |
925 bool isInstanceMember() { | 930 bool isInstanceMember() { |
926 return isMember() && !modifiers.isStatic(); | 931 return isMember() && !modifiers.isStatic(); |
927 } | 932 } |
928 | 933 |
929 // TODO(johnniwinther): Rewrite to avoid the optional argument. | 934 bool inStaticContext() { |
930 Scope buildScope({bool patchScope: false}) { | 935 return super.inStaticContext() || enclosingElement.inStaticContext(); |
931 Scope result = new VariableScope( | |
932 enclosingElement.buildScope(patchScope: patchScope), this); | |
933 if (enclosingElement.isClass()) { | |
934 Scope clsScope = result.parent; | |
935 clsScope.inStaticContext = !isInstanceMember(); | |
936 } | |
937 return result; | |
938 } | 936 } |
939 } | 937 } |
940 | 938 |
941 class ForeignElement extends Element { | 939 class ForeignElement extends Element { |
942 ForeignElement(SourceString name, ContainerElement enclosingElement) | 940 ForeignElement(SourceString name, ContainerElement enclosingElement) |
943 : super(name, ElementKind.FOREIGN, enclosingElement); | 941 : super(name, ElementKind.FOREIGN, enclosingElement); |
944 | 942 |
945 DartType computeType(Compiler compiler) { | 943 DartType computeType(Compiler compiler) { |
946 return compiler.types.dynamicType; | 944 return compiler.types.dynamicType; |
947 } | 945 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1191 return 'origin ${super.toString()}'; | 1189 return 'origin ${super.toString()}'; |
1192 } else { | 1190 } else { |
1193 return super.toString(); | 1191 return super.toString(); |
1194 } | 1192 } |
1195 } | 1193 } |
1196 | 1194 |
1197 // TODO(johnniwinther): Rewrite to avoid the optional argument. | 1195 // TODO(johnniwinther): Rewrite to avoid the optional argument. |
1198 Scope buildScope({bool patchScope: false}) { | 1196 Scope buildScope({bool patchScope: false}) { |
1199 Scope result = new MethodScope( | 1197 Scope result = new MethodScope( |
1200 enclosingElement.buildScope(patchScope: patchScope), this); | 1198 enclosingElement.buildScope(patchScope: patchScope), this); |
1201 if (enclosingElement.isClass()) { | |
1202 Scope clsScope = result.parent; | |
1203 clsScope.inStaticContext = !isInstanceMember() && !isConstructor(); | |
1204 } | |
1205 return result; | 1199 return result; |
1206 } | 1200 } |
1207 } | 1201 } |
1208 | 1202 |
1209 class ConstructorBodyElement extends FunctionElement { | 1203 class ConstructorBodyElement extends FunctionElement { |
1210 FunctionElement constructor; | 1204 FunctionElement constructor; |
1211 | 1205 |
1212 ConstructorBodyElement(FunctionElement constructor) | 1206 ConstructorBodyElement(FunctionElement constructor) |
1213 : this.constructor = constructor, | 1207 : this.constructor = constructor, |
1214 super(constructor.name, | 1208 super(constructor.name, |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1964 | 1958 |
1965 MetadataAnnotation ensureResolved(Compiler compiler) { | 1959 MetadataAnnotation ensureResolved(Compiler compiler) { |
1966 if (resolutionState == STATE_NOT_STARTED) { | 1960 if (resolutionState == STATE_NOT_STARTED) { |
1967 compiler.resolver.resolveMetadataAnnotation(this); | 1961 compiler.resolver.resolveMetadataAnnotation(this); |
1968 } | 1962 } |
1969 return this; | 1963 return this; |
1970 } | 1964 } |
1971 | 1965 |
1972 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1966 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
1973 } | 1967 } |
OLD | NEW |