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

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

Issue 9646030: Find diagnostic locations for use in new compiler API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased 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 | « dart/frog/leg/compiler.dart ('k') | dart/frog/leg/frog_leg.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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 } 591 }
592 592
593 Token position() => constructor.position(); 593 Token position() => constructor.position();
594 } 594 }
595 595
596 class SynthesizedConstructorElement extends FunctionElement { 596 class SynthesizedConstructorElement extends FunctionElement {
597 SynthesizedConstructorElement(Element enclosing) 597 SynthesizedConstructorElement(Element enclosing)
598 : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR, 598 : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR,
599 null, enclosing); 599 null, enclosing);
600 600
601 FunctionType computeType(Compiler compiler) { 601 Token position() => enclosing.position();
602 if (type != null) return type;
603 Type returnType = compiler.types.voidType;
604 type = new FunctionType(returnType, const EmptyLink<Type>(), this);
605 return type;
606 }
607
608 Node parseNode(DiagnosticListener listener) {
609 if (cachedNode != null) return cachedNode;
610 cachedNode = new FunctionExpression(
611 new Identifier(enclosingElement.position()),
612 new NodeList.empty(),
613 new Block(new NodeList.empty()),
614 null, null, null, null);
615 return cachedNode;
616 }
617
618 Token position() => null;
619 } 602 }
620 603
621 class ClassElement extends ContainerElement { 604 class ClassElement extends ContainerElement {
622 Type type; 605 Type type;
623 Type supertype; 606 Type supertype;
624 Type defaultClass; 607 Type defaultClass;
625 Link<Element> members = const EmptyLink<Element>(); 608 Link<Element> members = const EmptyLink<Element>();
626 Map<SourceString, Element> localMembers; 609 Map<SourceString, Element> localMembers;
627 Map<SourceString, Element> constructors; 610 Map<SourceString, Element> constructors;
628 Link<Type> interfaces = const EmptyLink<Type>(); 611 Link<Type> interfaces = const EmptyLink<Type>();
629 bool isResolved = false; 612 bool isResolved = false;
630 bool isBeingResolved = false; 613 bool isBeingResolved = false;
631 // backendMembers are members that have been added by the backend to simplify 614 // backendMembers are members that have been added by the backend to simplify
632 // compilation. They don't have any user-side counter-part. 615 // compilation. They don't have any user-side counter-part.
633 Link<Element> backendMembers = const EmptyLink<Element>(); 616 Link<Element> backendMembers = const EmptyLink<Element>();
634 SynthesizedConstructorElement synthesizedConstructor;
635 617
636 Link<Type> allSupertypes; 618 Link<Type> allSupertypes;
637 619
638 ClassElement(SourceString name, CompilationUnitElement enclosing) 620 ClassElement(SourceString name, CompilationUnitElement enclosing)
639 : localMembers = new Map<SourceString, Element>(), 621 : localMembers = new Map<SourceString, Element>(),
640 constructors = new Map<SourceString, Element>(), 622 constructors = new Map<SourceString, Element>(),
641 super(name, ElementKind.CLASS, enclosing); 623 super(name, ElementKind.CLASS, enclosing);
642 624
643 void addMember(Element element, DiagnosticListener listener) { 625 void addMember(Element element, DiagnosticListener listener) {
644 members = members.prepend(element); 626 members = members.prepend(element);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 } else { 677 } else {
696 normalizedName = className; 678 normalizedName = className;
697 } 679 }
698 Element result = constructors[normalizedName]; 680 Element result = constructors[normalizedName];
699 if (result === null && noMatch !== null) { 681 if (result === null && noMatch !== null) {
700 result = noMatch(lookupLocalMember(constructorName)); 682 result = noMatch(lookupLocalMember(constructorName));
701 } 683 }
702 return result; 684 return result;
703 } 685 }
704 686
705 bool canHaveDefaultConstructor() => constructors.length == 0;
706
707 SynthesizedConstructorElement getSynthesizedConstructor() {
708 // TODO(ahe): Get rid of this method. Add the
709 // SynthesizedConstructorElement to [constructors] if empty when
710 // [resolve] is called.
711 if (synthesizedConstructor === null && canHaveDefaultConstructor()) {
712 synthesizedConstructor = new SynthesizedConstructorElement(this);
713 }
714 return synthesizedConstructor;
715 }
716
717 /** 687 /**
718 * Returns the super class, if any. 688 * Returns the super class, if any.
719 * 689 *
720 * The returned element may not be resolved yet. 690 * The returned element may not be resolved yet.
721 */ 691 */
722 ClassElement get superclass() { 692 ClassElement get superclass() {
723 assert(isResolved); 693 assert(isResolved);
724 return supertype === null ? null : supertype.element; 694 return supertype === null ? null : supertype.element;
725 } 695 }
726 696
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 840
871 LabelElement addLabel(Identifier label, String labelName) { 841 LabelElement addLabel(Identifier label, String labelName) {
872 LabelElement result = new LabelElement(label, labelName, this, 842 LabelElement result = new LabelElement(label, labelName, this,
873 enclosingElement); 843 enclosingElement);
874 labels = labels.prepend(result); 844 labels = labels.prepend(result);
875 return result; 845 return result;
876 } 846 }
877 847
878 Node parseNode(DiagnosticListener l) => statement; 848 Node parseNode(DiagnosticListener l) => statement;
879 } 849 }
OLDNEW
« no previous file with comments | « dart/frog/leg/compiler.dart ('k') | dart/frog/leg/frog_leg.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698