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

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

Issue 10575033: Implement override checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 String holderName = enclosingElement.name.slowToString(); 207 String holderName = enclosingElement.name.slowToString();
208 return '$kind($holderName#${name.slowToString()})'; 208 return '$kind($holderName#${name.slowToString()})';
209 } else { 209 } else {
210 return '$kind(${name.slowToString()})'; 210 return '$kind(${name.slowToString()})';
211 } 211 }
212 } 212 }
213 213
214 bool _isNative = false; 214 bool _isNative = false;
215 void setNative() { _isNative = true; } 215 void setNative() { _isNative = true; }
216 bool isNative() => _isNative; 216 bool isNative() => _isNative;
217
218 FunctionElement asFunctionElement() => null;
217 } 219 }
218 220
219 class ContainerElement extends Element { 221 class ContainerElement extends Element {
220 ContainerElement(name, kind, enclosingElement) : 222 ContainerElement(name, kind, enclosingElement) :
221 super(name, kind, enclosingElement); 223 super(name, kind, enclosingElement);
222 224
223 abstract void addMember(Element element, DiagnosticListener listener); 225 abstract void addMember(Element element, DiagnosticListener listener);
224 226
225 void addGetterOrSetter(Element element, 227 void addGetterOrSetter(Element element,
226 Element existing, 228 Element existing,
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 635
634 FunctionType computeType(Compiler compiler) { 636 FunctionType computeType(Compiler compiler) {
635 if (type != null) return type; 637 if (type != null) return type;
636 type = compiler.computeFunctionType(this, computeSignature(compiler)); 638 type = compiler.computeFunctionType(this, computeSignature(compiler));
637 return type; 639 return type;
638 } 640 }
639 641
640 Node parseNode(DiagnosticListener listener) => cachedNode; 642 Node parseNode(DiagnosticListener listener) => cachedNode;
641 643
642 Token position() => cachedNode.getBeginToken(); 644 Token position() => cachedNode.getBeginToken();
645
646 FunctionElement asFunctionElement() => this;
643 } 647 }
644 648
645 class ConstructorBodyElement extends FunctionElement { 649 class ConstructorBodyElement extends FunctionElement {
646 FunctionElement constructor; 650 FunctionElement constructor;
647 651
648 ConstructorBodyElement(FunctionElement constructor) 652 ConstructorBodyElement(FunctionElement constructor)
649 : this.constructor = constructor, 653 : this.constructor = constructor,
650 super(constructor.name, 654 super(constructor.name,
651 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, 655 ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
652 null, 656 null,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 return result; 751 return result;
748 } 752 }
749 753
750 Element lookupLocalMember(SourceString memberName) { 754 Element lookupLocalMember(SourceString memberName) {
751 return localMembers[memberName]; 755 return localMembers[memberName];
752 } 756 }
753 757
754 Element lookupSuperMember(SourceString memberName) { 758 Element lookupSuperMember(SourceString memberName) {
755 for (ClassElement s = superclass; s != null; s = s.superclass) { 759 for (ClassElement s = superclass; s != null; s = s.superclass) {
756 Element e = s.lookupLocalMember(memberName); 760 Element e = s.lookupLocalMember(memberName);
757 if (e !== null) { 761 if (e === null) continue;
758 if (!memberName.isPrivate() || getLibrary() === e.getLibrary()) { 762 // Private members from a different library are not visible.
759 return e; 763 if (memberName.isPrivate() && getLibrary() !== e.getLibrary()) continue;
760 } 764 // Static members are not inherited.
761 } 765 if (e.modifiers.isStatic()) continue;
766 return e;
762 } 767 }
763 return null; 768 return null;
764 } 769 }
765 770
766 /** 771 /**
767 * Find the first member in the class chain with the given 772 * Find the first member in the class chain with the given
768 * [memberName]. This method is NOT to be used for resolving 773 * [memberName]. This method is NOT to be used for resolving
769 * unqualified sends because it does not implement the scoping 774 * unqualified sends because it does not implement the scoping
770 * rules, where library scope comes before superclass scope. 775 * rules, where library scope comes before superclass scope.
771 */ 776 */
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 final Node node; 1064 final Node node;
1060 Type bound; 1065 Type bound;
1061 Type type; 1066 Type type;
1062 TypeVariableElement(name, Element enclosing, this.node, this.type, 1067 TypeVariableElement(name, Element enclosing, this.node, this.type,
1063 [this.bound]) 1068 [this.bound])
1064 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1069 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1065 Type computeType(compiler) => type; 1070 Type computeType(compiler) => type;
1066 Node parseNode(compiler) => node; 1071 Node parseNode(compiler) => node;
1067 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1072 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1068 } 1073 }
OLDNEW
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/resolver.dart » ('j') | dart/lib/compiler/implementation/resolver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698