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

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

Issue 10666052: Revert "Implement override checks." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | « lib/compiler/implementation/dart2js.dart ('k') | lib/compiler/implementation/resolver.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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 String holderName = enclosingElement.name.slowToString(); 209 String holderName = enclosingElement.name.slowToString();
210 return '$kind($holderName#${name.slowToString()})'; 210 return '$kind($holderName#${name.slowToString()})';
211 } else { 211 } else {
212 return '$kind(${name.slowToString()})'; 212 return '$kind(${name.slowToString()})';
213 } 213 }
214 } 214 }
215 215
216 bool _isNative = false; 216 bool _isNative = false;
217 void setNative() { _isNative = true; } 217 void setNative() { _isNative = true; }
218 bool isNative() => _isNative; 218 bool isNative() => _isNative;
219
220 FunctionElement asFunctionElement() => null;
221 } 219 }
222 220
223 class ContainerElement extends Element { 221 class ContainerElement extends Element {
224 ContainerElement(name, kind, enclosingElement) : 222 ContainerElement(name, kind, enclosingElement) :
225 super(name, kind, enclosingElement); 223 super(name, kind, enclosingElement);
226 224
227 abstract void addMember(Element element, DiagnosticListener listener); 225 abstract void addMember(Element element, DiagnosticListener listener);
228 226
229 void addGetterOrSetter(Element element, 227 void addGetterOrSetter(Element element,
230 Element existing, 228 Element existing,
(...skipping 16 matching lines...) Expand all
247 field.getter = element; 245 field.getter = element;
248 } else { 246 } else {
249 if (field.setter != null && field.setter != element) { 247 if (field.setter != null && field.setter != element) {
250 reportError(field.setter); 248 reportError(field.setter);
251 } 249 }
252 field.setter = element; 250 field.setter = element;
253 } 251 }
254 } 252 }
255 } else { 253 } else {
256 AbstractFieldElement field = new AbstractFieldElement(element.name, this); 254 AbstractFieldElement field = new AbstractFieldElement(element.name, this);
255 addMember(field, listener);
257 if (element.kind == ElementKind.GETTER) { 256 if (element.kind == ElementKind.GETTER) {
258 field.getter = element; 257 field.getter = element;
259 } else { 258 } else {
260 field.setter = element; 259 field.setter = element;
261 } 260 }
262 addMember(field, listener);
263 } 261 }
264 } 262 }
265 } 263 }
266 264
267 class CompilationUnitElement extends ContainerElement { 265 class CompilationUnitElement extends ContainerElement {
268 final Script script; 266 final Script script;
269 Link<Element> topLevelElements = const EmptyLink<Element>(); 267 Link<Element> topLevelElements = const EmptyLink<Element>();
270 268
271 CompilationUnitElement(Script script, Element enclosing) 269 CompilationUnitElement(Script script, Element enclosing)
272 : this.script = script, 270 : this.script = script,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 } 495 }
498 496
499 parseNode(DiagnosticListener listener) { 497 parseNode(DiagnosticListener listener) {
500 throw "internal error: ForeignElement has no node"; 498 throw "internal error: ForeignElement has no node";
501 } 499 }
502 } 500 }
503 501
504 class AbstractFieldElement extends Element { 502 class AbstractFieldElement extends Element {
505 FunctionElement getter; 503 FunctionElement getter;
506 FunctionElement setter; 504 FunctionElement setter;
505 Modifiers modifiers;
507 506
508 AbstractFieldElement(SourceString name, Element enclosing) 507 AbstractFieldElement(SourceString name, Element enclosing)
509 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); 508 : super(name, ElementKind.ABSTRACT_FIELD, enclosing),
509 modifiers = new Modifiers.empty();
510 510
511 Type computeType(Compiler compiler) { 511 Type computeType(Compiler compiler) {
512 throw "internal error: AbstractFieldElement has no type"; 512 throw "internal error: AbstractFieldElement has no type";
513 } 513 }
514 514
515 Node parseNode(DiagnosticListener listener) { 515 Node parseNode(DiagnosticListener listener) {
516 throw "internal error: AbstractFieldElement has no node"; 516 throw "internal error: AbstractFieldElement has no node";
517 } 517 }
518 518
519 position() { 519 position() {
520 // The getter and setter may be defined in two different 520 // The getter and setter may be defined in two different
521 // compilation units. However, we know that one of them is 521 // compilation units. However, we know that one of them is
522 // non-null and defined in the same compilation unit as the 522 // non-null and defined in the same compilation unit as the
523 // abstract element. 523 // abstract element.
524 // 524 //
525 // We need to make sure that the position returned is relative to 525 // We need to make sure that the position returned is relative to
526 // the compilation unit of the abstract element. 526 // the compilation unit of the abstract element.
527 if (getter !== null && getter.enclosingElement === enclosingElement) { 527 if (getter !== null && getter.enclosingElement === enclosingElement) {
528 return getter.position(); 528 return getter.position();
529 } else { 529 } else if (setter != null) {
530 // TODO(ahe): checking for null should not be necessary.
530 return setter.position(); 531 return setter.position();
531 } 532 }
532 } 533 }
533
534 Modifiers get modifiers() {
535 // The resolver ensures that the flags match (ignoring abstract).
536 if (getter !== null) {
537 return new Modifiers.withFlags(
538 getter.modifiers.nodes,
539 getter.modifiers.flags | Modifiers.FLAG_ABSTRACT);
540 } else {
541 return new Modifiers.withFlags(
542 setter.modifiers.nodes,
543 setter.modifiers.flags | Modifiers.FLAG_ABSTRACT);
544 }
545 }
546 } 534 }
547 535
548 class FunctionSignature { 536 class FunctionSignature {
549 Link<Element> requiredParameters; 537 Link<Element> requiredParameters;
550 Link<Element> optionalParameters; 538 Link<Element> optionalParameters;
551 Type returnType; 539 Type returnType;
552 int requiredParameterCount; 540 int requiredParameterCount;
553 int optionalParameterCount; 541 int optionalParameterCount;
554 FunctionSignature(this.requiredParameters, 542 FunctionSignature(this.requiredParameters,
555 this.optionalParameters, 543 this.optionalParameters,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 635
648 FunctionType computeType(Compiler compiler) { 636 FunctionType computeType(Compiler compiler) {
649 if (type != null) return type; 637 if (type != null) return type;
650 type = compiler.computeFunctionType(this, computeSignature(compiler)); 638 type = compiler.computeFunctionType(this, computeSignature(compiler));
651 return type; 639 return type;
652 } 640 }
653 641
654 Node parseNode(DiagnosticListener listener) => cachedNode; 642 Node parseNode(DiagnosticListener listener) => cachedNode;
655 643
656 Token position() => cachedNode.getBeginToken(); 644 Token position() => cachedNode.getBeginToken();
657
658 FunctionElement asFunctionElement() => this;
659 } 645 }
660 646
661 class ConstructorBodyElement extends FunctionElement { 647 class ConstructorBodyElement extends FunctionElement {
662 FunctionElement constructor; 648 FunctionElement constructor;
663 649
664 ConstructorBodyElement(FunctionElement constructor) 650 ConstructorBodyElement(FunctionElement constructor)
665 : this.constructor = constructor, 651 : this.constructor = constructor,
666 super(constructor.name, 652 super(constructor.name,
667 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, 653 ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
668 null, 654 null,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 return result; 749 return result;
764 } 750 }
765 751
766 Element lookupLocalMember(SourceString memberName) { 752 Element lookupLocalMember(SourceString memberName) {
767 return localMembers[memberName]; 753 return localMembers[memberName];
768 } 754 }
769 755
770 Element lookupSuperMember(SourceString memberName) { 756 Element lookupSuperMember(SourceString memberName) {
771 for (ClassElement s = superclass; s != null; s = s.superclass) { 757 for (ClassElement s = superclass; s != null; s = s.superclass) {
772 Element e = s.lookupLocalMember(memberName); 758 Element e = s.lookupLocalMember(memberName);
773 if (e === null) continue; 759 if (e !== null) {
774 // Private members from a different library are not visible. 760 if (!memberName.isPrivate() || getLibrary() === e.getLibrary()) {
775 if (memberName.isPrivate() && getLibrary() !== e.getLibrary()) continue; 761 return e;
776 // Static members are not inherited. 762 }
777 if (e.modifiers.isStatic()) continue; 763 }
778 return e;
779 } 764 }
780 return null; 765 return null;
781 } 766 }
782 767
783 /** 768 /**
784 * Find the first member in the class chain with the given 769 * Find the first member in the class chain with the given
785 * [memberName]. This method is NOT to be used for resolving 770 * [memberName]. This method is NOT to be used for resolving
786 * unqualified sends because it does not implement the scoping 771 * unqualified sends because it does not implement the scoping
787 * rules, where library scope comes before superclass scope. 772 * rules, where library scope comes before superclass scope.
788 */ 773 */
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 final Node node; 1064 final Node node;
1080 Type bound; 1065 Type bound;
1081 Type type; 1066 Type type;
1082 TypeVariableElement(name, Element enclosing, this.node, this.type, 1067 TypeVariableElement(name, Element enclosing, this.node, this.type,
1083 [this.bound]) 1068 [this.bound])
1084 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1069 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1085 Type computeType(compiler) => type; 1070 Type computeType(compiler) => type;
1086 Node parseNode(compiler) => node; 1071 Node parseNode(compiler) => node;
1087 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1072 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1088 } 1073 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/dart2js.dart ('k') | lib/compiler/implementation/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698