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

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

Issue 10661029: Ensure interfaces are loaded. (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('../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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 441
442 class TypedefElement extends Element implements TypeDeclarationElement { 442 class TypedefElement extends Element implements TypeDeclarationElement {
443 Type cachedType; 443 Type cachedType;
444 Typedef cachedNode; 444 Typedef cachedNode;
445 445
446 TypedefElement(SourceString name, Element enclosing) 446 TypedefElement(SourceString name, Element enclosing)
447 : super(name, ElementKind.TYPEDEF, enclosing); 447 : super(name, ElementKind.TYPEDEF, enclosing);
448 448
449 Type computeType(Compiler compiler) { 449 Type computeType(Compiler compiler) {
450 if (cachedType !== null) return cachedType; 450 if (cachedType !== null) return cachedType;
451 cachedType = compiler.computeFunctionType( 451 cachedType = new FunctionType(null, null, this);
452 this, compiler.resolveTypedef(this)); 452 cachedType.initializeFrom(
453 compiler.computeFunctionType(this, compiler.resolveTypedef(this)));
453 return cachedType; 454 return cachedType;
454 } 455 }
455 456
456 Link<Type> get typeVariables() => const EmptyLink<Type>(); 457 Link<Type> get typeVariables() => const EmptyLink<Type>();
457 458
458 Scope buildScope() => 459 Scope buildScope() =>
459 new TypeDeclarationScope(enclosingElement.buildScope(), this); 460 new TypeDeclarationScope(enclosingElement.buildScope(), this);
460 } 461 }
461 462
462 class VariableElement extends Element { 463 class VariableElement extends Element {
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 final int id; 885 final int id;
885 InterfaceType type; 886 InterfaceType type;
886 Type supertype; 887 Type supertype;
887 Type defaultClass; 888 Type defaultClass;
888 Link<Element> members = const EmptyLink<Element>(); 889 Link<Element> members = const EmptyLink<Element>();
889 Map<SourceString, Element> localMembers; 890 Map<SourceString, Element> localMembers;
890 Map<SourceString, Element> constructors; 891 Map<SourceString, Element> constructors;
891 Link<Type> interfaces = const EmptyLink<Type>(); 892 Link<Type> interfaces = const EmptyLink<Type>();
892 bool isResolved = false; 893 bool isResolved = false;
893 bool isBeingResolved = false; 894 bool isBeingResolved = false;
895 bool isLoadingSupertypes = false;
896 bool supertypesAreLoaded = false;
897
894 // backendMembers are members that have been added by the backend to simplify 898 // backendMembers are members that have been added by the backend to simplify
895 // compilation. They don't have any user-side counter-part. 899 // compilation. They don't have any user-side counter-part.
896 Link<Element> backendMembers = const EmptyLink<Element>(); 900 Link<Element> backendMembers = const EmptyLink<Element>();
897 901
898 Link<Type> allSupertypes; 902 Link<Type> allSupertypes;
899 ClassElement patch = null; 903 ClassElement patch = null;
900 904
901 ClassElement(SourceString name, CompilationUnitElement enclosing, this.id) 905 ClassElement(SourceString name, CompilationUnitElement enclosing, this.id)
902 : localMembers = new Map<SourceString, Element>(), 906 : localMembers = new Map<SourceString, Element>(),
903 constructors = new Map<SourceString, Element>(), 907 constructors = new Map<SourceString, Element>(),
(...skipping 18 matching lines...) Expand all
922 Link<Type> parameters = 926 Link<Type> parameters =
923 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); 927 TypeDeclarationElement.createTypeVariables(this, node.typeParameters);
924 type = new InterfaceType(this, parameters); 928 type = new InterfaceType(this, parameters);
925 } 929 }
926 return type; 930 return type;
927 } 931 }
928 932
929 Link<Type> get typeVariables() => type.arguments; 933 Link<Type> get typeVariables() => type.arguments;
930 934
931 ClassElement ensureResolved(Compiler compiler) { 935 ClassElement ensureResolved(Compiler compiler) {
932 compiler.resolveClass(this); 936 if (!isResolved && !isBeingResolved) {
937 isBeingResolved = true;
938 compiler.resolver.resolveClass(this);
939 isBeingResolved = false;
940 isResolved = true;
941 }
933 return this; 942 return this;
934 } 943 }
935 944
936 Element lookupLocalMember(SourceString memberName) { 945 Element lookupLocalMember(SourceString memberName) {
937 return localMembers[memberName]; 946 return localMembers[memberName];
938 } 947 }
939 948
940 Element lookupSuperMember(SourceString memberName) { 949 Element lookupSuperMember(SourceString memberName) {
941 bool isPrivate = memberName.isPrivate(); 950 bool isPrivate = memberName.isPrivate();
942 for (ClassElement s = superclass; s != null; s = s.superclass) { 951 for (ClassElement s = superclass; s != null; s = s.superclass) {
943 // Private members from a different library are not visible. 952 // Private members from a different library are not visible.
944 if (isPrivate && getLibrary() !== s.getLibrary()) continue; 953 if (isPrivate && getLibrary() !== s.getLibrary()) continue;
945 Element e = s.lookupLocalMember(memberName); 954 Element e = s.lookupLocalMember(memberName);
946 if (e === null) continue; 955 if (e === null) continue;
947 // Static members are not inherited. 956 // Static members are not inherited.
948 if (e.modifiers.isStatic()) continue; 957 if (e.modifiers.isStatic()) continue;
949 return e; 958 return e;
950 } 959 }
960 if (isInterface()) {
961 return lookupSuperInterfaceMember(memberName, getLibrary());
962 }
951 return null; 963 return null;
952 } 964 }
953 965
966 Element lookupSuperInterfaceMember(SourceString memberName,
967 LibraryElement fromLibrary) {
968 for (Type t in interfaces) {
969 Element e = t.element.lookupLocalMember(memberName);
970 if (e === null) continue;
971 // Private members from a different library are not visible.
972 if (memberName.isPrivate() && fromLibrary !== e.getLibrary()) continue;
973 // Static members are not inherited.
974 if (e.modifiers.isStatic()) continue;
975 return e;
976 }
977 }
978
954 /** 979 /**
955 * Find the first member in the class chain with the given 980 * Find the first member in the class chain with the given
956 * [memberName]. This method is NOT to be used for resolving 981 * [memberName]. This method is NOT to be used for resolving
957 * unqualified sends because it does not implement the scoping 982 * unqualified sends because it does not implement the scoping
958 * rules, where library scope comes before superclass scope. 983 * rules, where library scope comes before superclass scope.
959 */ 984 */
960 Element lookupMember(SourceString memberName) { 985 Element lookupMember(SourceString memberName) {
961 Element localMember = localMembers[memberName]; 986 Element localMember = localMembers[memberName];
962 return localMember === null ? lookupSuperMember(memberName) : localMember; 987 return localMember === null ? lookupSuperMember(memberName) : localMember;
963 } 988 }
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 TypeVariableElement(name, Element enclosing, this.cachedNode, 1310 TypeVariableElement(name, Element enclosing, this.cachedNode,
1286 [this.type, this.bound]) 1311 [this.type, this.bound])
1287 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1312 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1288 1313
1289 TypeVariableType computeType(compiler) => type; 1314 TypeVariableType computeType(compiler) => type;
1290 1315
1291 Node parseNode(compiler) => cachedNode; 1316 Node parseNode(compiler) => cachedNode;
1292 1317
1293 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1318 String toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1294 } 1319 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/compiler.dart ('k') | dart/lib/compiler/implementation/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698