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

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

Issue 10823311: Clean up state handling in ClassElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 years, 4 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 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 * Creates the type variables, their type and corresponding element, for the 986 * Creates the type variables, their type and corresponding element, for the
987 * type variables declared in [parameter] on [element]. The bounds of the type 987 * type variables declared in [parameter] on [element]. The bounds of the type
988 * variables are not set until [element] has been resolved. 988 * variables are not set until [element] has been resolved.
989 */ 989 */
990 static Link<Type> createTypeVariables(TypeDeclarationElement element, 990 static Link<Type> createTypeVariables(TypeDeclarationElement element,
991 NodeList parameters) { 991 NodeList parameters) {
992 if (parameters === null) return const EmptyLink<Type>(); 992 if (parameters === null) return const EmptyLink<Type>();
993 993
994 // Create types and elements for type variable. 994 // Create types and elements for type variable.
995 var arguments = new LinkBuilder<Type>(); 995 var arguments = new LinkBuilder<Type>();
996 for (Link<Node> link = parameters.nodes; !link.isEmpty(); link = link.tail) { 996 for (Link link = parameters.nodes; !link.isEmpty(); link = link.tail) {
997 TypeVariable node = link.head; 997 TypeVariable node = link.head;
998 SourceString variableName = node.name.source; 998 SourceString variableName = node.name.source;
999 TypeVariableElement variableElement = 999 TypeVariableElement variableElement =
1000 new TypeVariableElement(variableName, element, node); 1000 new TypeVariableElement(variableName, element, node);
1001 TypeVariableType variableType = new TypeVariableType(variableElement); 1001 TypeVariableType variableType = new TypeVariableType(variableElement);
1002 variableElement.type = variableType; 1002 variableElement.type = variableType;
1003 arguments.addLast(variableType); 1003 arguments.addLast(variableType);
1004 } 1004 }
1005 return arguments.toLink(); 1005 return arguments.toLink();
1006 } 1006 }
1007 } 1007 }
1008 1008
1009 class ClassElement extends ScopeContainerElement 1009 class ClassElement extends ScopeContainerElement
1010 implements TypeDeclarationElement { 1010 implements TypeDeclarationElement {
1011 static final int STATE_NOT_STARTED = 0; 1011 static final int STATE_NOT_STARTED = 0;
1012 static final int STATE_STARTED = 1; 1012 static final int STATE_STARTED = 1;
1013 static final int STATE_DONE = 2; 1013 static final int STATE_DONE = 2;
1014 1014
1015 final int id; 1015 final int id;
1016 InterfaceType type; 1016 InterfaceType type;
1017 Type supertype; 1017 Type supertype;
1018 Type defaultClass; 1018 Type defaultClass;
1019 Link<Type> interfaces; 1019 Link<Type> interfaces;
1020 SourceString nativeName; 1020 SourceString nativeName;
1021 1021 int supertypeLoadState;
1022 int _supertypeLoadState = STATE_NOT_STARTED; 1022 int resolutionState;
1023 int get supertypeLoadState() => _supertypeLoadState;
1024 void set supertypeLoadState(int state) {
1025 assert(state == _supertypeLoadState + 1);
1026 assert(state <= STATE_DONE);
1027 _supertypeLoadState = state;
1028 }
1029
1030 int _resolutionState = STATE_NOT_STARTED;
1031 int get resolutionState() => _resolutionState;
1032 void set resolutionState(int state) {
1033 assert(state == _resolutionState + 1);
1034 assert(state <= STATE_DONE);
1035 _resolutionState = state;
1036 }
1037 1023
1038 // backendMembers are members that have been added by the backend to simplify 1024 // backendMembers are members that have been added by the backend to simplify
1039 // compilation. They don't have any user-side counter-part. 1025 // compilation. They don't have any user-side counter-part.
1040 Link<Element> backendMembers = const EmptyLink<Element>(); 1026 Link<Element> backendMembers = const EmptyLink<Element>();
1041 1027
1042 Link<Type> allSupertypes; 1028 Link<Type> allSupertypes;
1043 1029
1044 // Lazily applied patch of class members. 1030 // Lazily applied patch of class members.
1045 ClassElement patch = null; 1031 ClassElement patch = null;
1046 1032
1047 ClassElement(SourceString name, Element enclosing, this.id) 1033 ClassElement(SourceString name, Element enclosing, this.id, int initialState)
1048 : super(name, ElementKind.CLASS, enclosing); 1034 : supertypeLoadState = initialState,
1035 resolutionState = initialState,
1036 super(name, ElementKind.CLASS, enclosing);
1049 1037
1050 InterfaceType computeType(compiler) { 1038 InterfaceType computeType(compiler) {
1051 if (type == null) { 1039 if (type == null) {
1052 ClassNode node = parseNode(compiler); 1040 ClassNode node = parseNode(compiler);
1053 Link<Type> parameters = 1041 Link<Type> parameters =
1054 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); 1042 TypeDeclarationElement.createTypeVariables(this, node.typeParameters);
1055 type = new InterfaceType(this, parameters); 1043 type = new InterfaceType(this, parameters);
1056 } 1044 }
1057 return type; 1045 return type;
1058 } 1046 }
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 Node parseNode(compiler) => cachedNode; 1498 Node parseNode(compiler) => cachedNode;
1511 1499
1512 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1500 String toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1513 1501
1514 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { 1502 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) {
1515 TypeVariableElement result = 1503 TypeVariableElement result =
1516 new TypeVariableElement(name, enclosing, cachedNode, type, bound); 1504 new TypeVariableElement(name, enclosing, cachedNode, type, bound);
1517 return result; 1505 return result;
1518 } 1506 }
1519 } 1507 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/closure.dart ('k') | dart/lib/compiler/implementation/scanner/class_element_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698