Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: lib/compiler/implementation/elements/elements.dart

Issue 10996039: Bring type variables into static scope, but produce compile-time error when they are used. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed passing test from the exception list. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 return '$kind(${nameText})'; 335 return '$kind(${nameText})';
336 } 336 }
337 } 337 }
338 338
339 bool _isNative = false; 339 bool _isNative = false;
340 void setNative() { _isNative = true; } 340 void setNative() { _isNative = true; }
341 bool isNative() => _isNative; 341 bool isNative() => _isNative;
342 342
343 FunctionElement asFunctionElement() => null; 343 FunctionElement asFunctionElement() => null;
344 344
345 bool inStaticContext() {
346 return modifiers !== null && modifiers.isStatic();
347 }
348
345 Element cloneTo(Element enclosing, DiagnosticListener listener) { 349 Element cloneTo(Element enclosing, DiagnosticListener listener) {
346 listener.cancel("Unimplemented cloneTo", element: this); 350 listener.cancel("Unimplemented cloneTo", element: this);
347 } 351 }
348 } 352 }
349 353
350 /** 354 /**
351 * Represents an unresolvable or duplicated element. 355 * Represents an unresolvable or duplicated element.
352 * 356 *
353 * An [ErroneousElement] is used instead of [null] to provide additional 357 * An [ErroneousElement] is used instead of [null] to provide additional
354 * information about the error that caused the element to be unresolvable 358 * information about the error that caused the element to be unresolvable
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 } else { 853 } else {
850 result = new VariableListElement(kind, modifiers, enclosing); 854 result = new VariableListElement(kind, modifiers, enclosing);
851 } 855 }
852 return result; 856 return result;
853 } 857 }
854 858
855 bool isInstanceMember() { 859 bool isInstanceMember() {
856 return isMember() && !modifiers.isStatic(); 860 return isMember() && !modifiers.isStatic();
857 } 861 }
858 862
863 bool inStaticContext() {
864 return super.inStaticContext() || enclosingElement.inStaticContext();
865 }
866
859 Scope buildScope() { 867 Scope buildScope() {
860 Scope result = new VariableScope(enclosingElement.buildScope(), this); 868 return new VariableScope(enclosingElement.buildScope(), this);
861 if (enclosingElement.isClass()) {
862 ClassScope clsScope = result.parent;
863 clsScope.inStaticContext = !isInstanceMember();
864 }
865 return result;
866 } 869 }
867 } 870 }
868 871
869 class ForeignElement extends Element { 872 class ForeignElement extends Element {
870 ForeignElement(SourceString name, ContainerElement enclosingElement) 873 ForeignElement(SourceString name, ContainerElement enclosingElement)
871 : super(name, ElementKind.FOREIGN, enclosingElement); 874 : super(name, ElementKind.FOREIGN, enclosingElement);
872 875
873 DartType computeType(Compiler compiler) { 876 DartType computeType(Compiler compiler) {
874 return compiler.types.dynamicType; 877 return compiler.types.dynamicType;
875 } 878 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 String toString() { 1120 String toString() {
1118 if (isPatch) { 1121 if (isPatch) {
1119 return 'patch ${super.toString()}'; 1122 return 'patch ${super.toString()}';
1120 } else if (isPatched) { 1123 } else if (isPatched) {
1121 return 'origin ${super.toString()}'; 1124 return 'origin ${super.toString()}';
1122 } else { 1125 } else {
1123 return super.toString(); 1126 return super.toString();
1124 } 1127 }
1125 } 1128 }
1126 1129
1127 Scope buildScope() { 1130 Scope buildScope() {
Johnni Winther 2012/10/02 09:07:30 Remove this method. MethodScope is mutable and sho
aam-me 2012/10/02 12:50:39 Johnni, removing this method causes "Internal e
Johnni Winther 2012/10/03 10:40:33 OK. Just leave it there. I'll try to remove it in
1128 Scope result = 1131 return new MethodScope(enclosingElement.buildScope(), this);
1129 new MethodScope(enclosingElement.buildScope(), this);
1130 if (enclosingElement.isClass()) {
1131 Scope clsScope = result.parent;
1132 clsScope.inStaticContext = !isInstanceMember() && !isConstructor();
1133 }
1134 return result;
1135 } 1132 }
1136 } 1133 }
1137 1134
1138 class ConstructorBodyElement extends FunctionElement { 1135 class ConstructorBodyElement extends FunctionElement {
1139 FunctionElement constructor; 1136 FunctionElement constructor;
1140 1137
1141 ConstructorBodyElement(FunctionElement constructor) 1138 ConstructorBodyElement(FunctionElement constructor)
1142 : this.constructor = constructor, 1139 : this.constructor = constructor,
1143 super(constructor.name, 1140 super(constructor.name,
1144 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, 1141 ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 1828
1832 MetadataAnnotation ensureResolved(Compiler compiler) { 1829 MetadataAnnotation ensureResolved(Compiler compiler) {
1833 if (resolutionState == STATE_NOT_STARTED) { 1830 if (resolutionState == STATE_NOT_STARTED) {
1834 compiler.resolver.resolveMetadataAnnotation(this); 1831 compiler.resolver.resolveMetadataAnnotation(this);
1835 } 1832 }
1836 return this; 1833 return this;
1837 } 1834 }
1838 1835
1839 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 1836 String toString() => 'MetadataAnnotation($value, $resolutionState)';
1840 } 1837 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/resolver.dart » ('j') | lib/compiler/implementation/resolver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698