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

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

Issue 10827359: Fix field-accesses for private fields that were "shadowed" by other private fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 } 691 }
692 692
693 position() { 693 position() {
694 // The getter and setter may be defined in two different 694 // The getter and setter may be defined in two different
695 // compilation units. However, we know that one of them is 695 // compilation units. However, we know that one of them is
696 // non-null and defined in the same compilation unit as the 696 // non-null and defined in the same compilation unit as the
697 // abstract element. 697 // abstract element.
698 // 698 //
699 // We need to make sure that the position returned is relative to 699 // We need to make sure that the position returned is relative to
700 // the compilation unit of the abstract element. 700 // the compilation unit of the abstract element.
701 if (getter !== null 701 if (getter !== null
702 && getter.getCompilationUnit() === getCompilationUnit()) { 702 && getter.getCompilationUnit() === getCompilationUnit()) {
703 return getter.position(); 703 return getter.position();
704 } else { 704 } else {
705 return setter.position(); 705 return setter.position();
706 } 706 }
707 } 707 }
708 708
709 Modifiers get modifiers() { 709 Modifiers get modifiers() {
710 // The resolver ensures that the flags match (ignoring abstract). 710 // The resolver ensures that the flags match (ignoring abstract).
711 if (getter !== null) { 711 if (getter !== null) {
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 /** 1046 /**
1047 * Lookup local members in the class. This will ignore constructors. 1047 * Lookup local members in the class. This will ignore constructors.
1048 */ 1048 */
1049 Element lookupLocalMember(SourceString memberName) { 1049 Element lookupLocalMember(SourceString memberName) {
1050 var result = localLookup(memberName); 1050 var result = localLookup(memberName);
1051 if (result !== null && result.isConstructor()) return null; 1051 if (result !== null && result.isConstructor()) return null;
1052 return result; 1052 return result;
1053 } 1053 }
1054 1054
1055 /** 1055 /**
1056 * Lookup super members for the class. This will ignore constructors. 1056 * Lookup super members for the class. This will ignore constructors.
1057 */ 1057 */
1058 Element lookupSuperMember(SourceString memberName) { 1058 Element lookupSuperMember(SourceString memberName) {
1059 return lookupSuperMemberInLibrary(memberName, getLibrary());
1060 }
1061
1062 /**
1063 * Lookup super members for the class that is accessible in [library].
1064 * This will ignore constructors.
1065 */
1066 Element lookupSuperMemberInLibrary(SourceString memberName,
kasperl 2012/08/16 12:47:57 Would it be possible to start using Selector for l
floitsch 2012/08/16 16:15:55 Went a little bit into that direction. It's not co
1067 LibraryElement library) {
1059 bool isPrivate = memberName.isPrivate(); 1068 bool isPrivate = memberName.isPrivate();
1060 for (ClassElement s = superclass; s != null; s = s.superclass) { 1069 for (ClassElement s = superclass; s != null; s = s.superclass) {
1061 // Private members from a different library are not visible. 1070 // Private members from a different library are not visible.
1062 if (isPrivate && getLibrary() !== s.getLibrary()) continue; 1071 if (isPrivate && library !== s.getLibrary()) continue;
1063 Element e = s.lookupLocalMember(memberName); 1072 Element e = s.lookupLocalMember(memberName);
1064 if (e === null) continue; 1073 if (e === null) continue;
1065 // Static members are not inherited. 1074 // Static members are not inherited.
1066 if (e.modifiers.isStatic()) continue; 1075 if (e.modifiers.isStatic()) continue;
1067 return e; 1076 return e;
1068 } 1077 }
1069 return null; 1078 return null;
1070 } 1079 }
1071 1080
1072 /** 1081 /**
1073 * Find the first member in the class chain with the given 1082 * Find the first member in the class chain with the given
1083 * [memberName] that is accessible from within [library]. If the
1084 * [memberName] is not private then the [library] can be `null`.
1085 *
1086 * This method is NOT to be used for resolving
1087 * unqualified sends because it does not implement the scoping
1088 * rules, where library scope comes before superclass scope.
1089 */
1090 Element lookupMemberInLibrary(SourceString memberName,
1091 LibraryElement library) {
1092 Element localMember = lookupLocalMember(memberName);
1093 if (localMember != null &&
1094 (!memberName.isPrivate() || getLibrary() == library)) {
1095 return localMember;
1096 }
1097 return lookupSuperMemberInLibrary(memberName, library);
1098 }
1099
1100 /**
1101 * Find the first member in the class chain with the given
1074 * [memberName]. This method is NOT to be used for resolving 1102 * [memberName]. This method is NOT to be used for resolving
1075 * unqualified sends because it does not implement the scoping 1103 * unqualified sends because it does not implement the scoping
1076 * rules, where library scope comes before superclass scope. 1104 * rules, where library scope comes before superclass scope.
1077 */ 1105 */
1078 Element lookupMember(SourceString memberName) { 1106 Element lookupMember(SourceString memberName) {
1079 Element localMember = lookupLocalMember(memberName); 1107 Element localMember = lookupLocalMember(memberName);
1080 return localMember === null ? lookupSuperMember(memberName) : localMember; 1108 return localMember === null ? lookupSuperMember(memberName) : localMember;
1081 } 1109 }
1082 1110
1083 /** 1111 /**
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 Node parseNode(compiler) => cachedNode; 1455 Node parseNode(compiler) => cachedNode;
1428 1456
1429 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1457 String toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1430 1458
1431 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { 1459 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) {
1432 TypeVariableElement result = 1460 TypeVariableElement result =
1433 new TypeVariableElement(name, enclosing, node, type, bound); 1461 new TypeVariableElement(name, enclosing, node, type, bound);
1434 return result; 1462 return result;
1435 } 1463 }
1436 } 1464 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/optimize.dart » ('j') | lib/compiler/implementation/ssa/optimize.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698