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

Side by Side Diff: dart/frog/leg/elements/elements.dart

Issue 9689045: Library privacy. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | dart/frog/leg/emitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 Token position() => null; 136 Token position() => null;
137 137
138 Token findMyName(Token token) { 138 Token findMyName(Token token) {
139 for (Token t = token; t !== EOF_TOKEN; t = t.next) { 139 for (Token t = token; t !== EOF_TOKEN; t = t.next) {
140 if (t.value == name) return t; 140 if (t.value == name) return t;
141 } 141 }
142 return token; 142 return token;
143 } 143 }
144 144
145 const Element(this.name, this.kind, this.enclosingElement); 145 Element(this.name, this.kind, this.enclosingElement) {
146 assert(getLibrary() !== null);
147 }
146 148
147 // TODO(kasperl): This is a very bad hash code for the element and 149 // TODO(kasperl): This is a very bad hash code for the element and
148 // there's no reason why two elements with the same name should have 150 // there's no reason why two elements with the same name should have
149 // the same hash code. Replace this with a simple id in the element? 151 // the same hash code. Replace this with a simple id in the element?
150 int hashCode() => name.hashCode(); 152 int hashCode() => name.hashCode();
151 153
152 CompilationUnitElement getCompilationUnit() { 154 CompilationUnitElement getCompilationUnit() {
153 Element element = this; 155 Element element = this;
154 while (element !== null && !element.isCompilationUnit()) { 156 while (element !== null && !element.isCompilationUnit()) {
155 element = element.enclosingElement; 157 element = element.enclosingElement;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 287
286 Element find(SourceString elementName) { 288 Element find(SourceString elementName) {
287 return elements[elementName]; 289 return elements[elementName];
288 } 290 }
289 291
290 void forEachExport(f(Element element)) { 292 void forEachExport(f(Element element)) {
291 elements.forEach((SourceString _, Element e) { 293 elements.forEach((SourceString _, Element e) {
292 if (this === e.getLibrary() 294 if (this === e.getLibrary()
293 && e.kind !== ElementKind.PREFIX 295 && e.kind !== ElementKind.PREFIX
294 && e.kind !== ElementKind.FOREIGN) { 296 && e.kind !== ElementKind.FOREIGN) {
295 f(e); 297 if (!e.name.isPrivate()) f(e);
296 } 298 }
297 }); 299 });
298 } 300 }
299 } 301 }
300 302
301 class PrefixElement extends Element { 303 class PrefixElement extends Element {
302 Map<SourceString, Element> imported; 304 Map<SourceString, Element> imported;
303 305
304 PrefixElement(SourceString prefix, Element enclosing) 306 PrefixElement(SourceString prefix, Element enclosing)
305 : imported = new Map<SourceString, Element>(), 307 : imported = new Map<SourceString, Element>(),
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 return result; 710 return result;
709 } 711 }
710 712
711 Element lookupLocalMember(SourceString memberName) { 713 Element lookupLocalMember(SourceString memberName) {
712 return localMembers[memberName]; 714 return localMembers[memberName];
713 } 715 }
714 716
715 Element lookupSuperMember(SourceString memberName) { 717 Element lookupSuperMember(SourceString memberName) {
716 for (ClassElement s = superclass; s != null; s = s.superclass) { 718 for (ClassElement s = superclass; s != null; s = s.superclass) {
717 Element e = s.lookupLocalMember(memberName); 719 Element e = s.lookupLocalMember(memberName);
718 if (e !== null) return e; 720 if (e !== null) {
721 if (!memberName.isPrivate() || getLibrary() === e.getLibrary()) {
722 return e;
723 }
724 }
719 } 725 }
720 return null; 726 return null;
721 } 727 }
722 728
723 Element lookupConstructor(SourceString className, 729 Element lookupConstructor(SourceString className,
724 [SourceString constructorName = 730 [SourceString constructorName =
725 const SourceString(''), 731 const SourceString(''),
726 Element noMatch(Element)]) { 732 Element noMatch(Element)]) {
727 // TODO(karlklose): have a map from class names to a map of constructors 733 // TODO(karlklose): have a map from class names to a map of constructors
728 // instead of creating the name here? 734 // instead of creating the name here?
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 final Node node; 924 final Node node;
919 Type bound; 925 Type bound;
920 Type type; 926 Type type;
921 TypeVariableElement(name, Element enclosing, this.node, this.type, 927 TypeVariableElement(name, Element enclosing, this.node, this.type,
922 [this.bound]) 928 [this.bound])
923 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 929 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
924 Type computeType(compiler) => type; 930 Type computeType(compiler) => type;
925 Node parseNode(compiler) => node; 931 Node parseNode(compiler) => node;
926 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 932 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
927 } 933 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698