OLD | NEW |
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 Element(this.name, this.kind, this.enclosingElement) { | 115 Element(this.name, this.kind, this.enclosingElement) { |
116 assert(getLibrary() !== null); | 116 assert(getLibrary() !== null); |
117 } | 117 } |
118 | 118 |
119 Modifiers get modifiers => null; | 119 Modifiers get modifiers => null; |
120 | 120 |
121 Node parseNode(DiagnosticListener listener) { | 121 Node parseNode(DiagnosticListener listener) { |
122 listener.cancel("Internal Error: $this.parseNode", token: position()); | 122 listener.cancel("Internal Error: $this.parseNode", token: position()); |
123 } | 123 } |
124 | 124 |
125 Type computeType(Compiler compiler) { | 125 DartType computeType(Compiler compiler) { |
126 compiler.internalError("$this.computeType.", token: position()); | 126 compiler.internalError("$this.computeType.", token: position()); |
127 } | 127 } |
128 | 128 |
129 void addMetadata(MetadataAnnotation annotation) { | 129 void addMetadata(MetadataAnnotation annotation) { |
130 assert(annotation.annotatedElement === null); | 130 assert(annotation.annotatedElement === null); |
131 annotation.annotatedElement = this; | 131 annotation.annotatedElement = this; |
132 metadata = metadata.prepend(annotation); | 132 metadata = metadata.prepend(annotation); |
133 } | 133 } |
134 | 134 |
135 bool isFunction() => kind === ElementKind.FUNCTION; | 135 bool isFunction() => kind === ElementKind.FUNCTION; |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 class PrefixElement extends Element { | 552 class PrefixElement extends Element { |
553 Map<SourceString, Element> imported; | 553 Map<SourceString, Element> imported; |
554 Token firstPosition; | 554 Token firstPosition; |
555 | 555 |
556 PrefixElement(SourceString prefix, Element enclosing, this.firstPosition) | 556 PrefixElement(SourceString prefix, Element enclosing, this.firstPosition) |
557 : imported = new Map<SourceString, Element>(), | 557 : imported = new Map<SourceString, Element>(), |
558 super(prefix, ElementKind.PREFIX, enclosing); | 558 super(prefix, ElementKind.PREFIX, enclosing); |
559 | 559 |
560 lookupLocalMember(SourceString memberName) => imported[memberName]; | 560 lookupLocalMember(SourceString memberName) => imported[memberName]; |
561 | 561 |
562 Type computeType(Compiler compiler) => compiler.types.dynamicType; | 562 DartType computeType(Compiler compiler) => compiler.types.dynamicType; |
563 | 563 |
564 Token position() => firstPosition; | 564 Token position() => firstPosition; |
565 | 565 |
566 PrefixElement cloneTo(Element enclosing, DiagnosticListener listener) { | 566 PrefixElement cloneTo(Element enclosing, DiagnosticListener listener) { |
567 return new PrefixElement(name, enclosing, firstPosition); | 567 return new PrefixElement(name, enclosing, firstPosition); |
568 } | 568 } |
569 } | 569 } |
570 | 570 |
571 class TypedefElement extends Element implements TypeDeclarationElement { | 571 class TypedefElement extends Element implements TypeDeclarationElement { |
572 Typedef cachedNode; | 572 Typedef cachedNode; |
573 TypedefType cachedType; | 573 TypedefType cachedType; |
574 Type alias; | 574 DartType alias; |
575 | 575 |
576 bool isResolved = false; | 576 bool isResolved = false; |
577 bool isBeingResolved = false; | 577 bool isBeingResolved = false; |
578 | 578 |
579 TypedefElement(SourceString name, Element enclosing) | 579 TypedefElement(SourceString name, Element enclosing) |
580 : super(name, ElementKind.TYPEDEF, enclosing); | 580 : super(name, ElementKind.TYPEDEF, enclosing); |
581 | 581 |
582 /** | 582 /** |
583 * Function signature for a typedef of a function type. The signature is | 583 * Function signature for a typedef of a function type. The signature is |
584 * kept to provide full information about parameter names through the mirror | 584 * kept to provide full information about parameter names through the mirror |
585 * system. | 585 * system. |
586 * | 586 * |
587 * The [functionSignature] is not available until the typedef element has been | 587 * The [functionSignature] is not available until the typedef element has been |
588 * resolved. | 588 * resolved. |
589 */ | 589 */ |
590 FunctionSignature functionSignature; | 590 FunctionSignature functionSignature; |
591 | 591 |
592 TypedefType computeType(Compiler compiler) { | 592 TypedefType computeType(Compiler compiler) { |
593 if (cachedType !== null) return cachedType; | 593 if (cachedType !== null) return cachedType; |
594 Typedef node = parseNode(compiler); | 594 Typedef node = parseNode(compiler); |
595 Link<Type> parameters = | 595 Link<DartType> parameters = |
596 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); | 596 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); |
597 cachedType = new TypedefType(this, parameters); | 597 cachedType = new TypedefType(this, parameters); |
598 compiler.resolveTypedef(this); | 598 compiler.resolveTypedef(this); |
599 return cachedType; | 599 return cachedType; |
600 } | 600 } |
601 | 601 |
602 Link<Type> get typeVariables => cachedType.typeArguments; | 602 Link<DartType> get typeVariables => cachedType.typeArguments; |
603 | 603 |
604 Scope buildScope() => | 604 Scope buildScope() => |
605 new TypeDeclarationScope(enclosingElement.buildScope(), this); | 605 new TypeDeclarationScope(enclosingElement.buildScope(), this); |
606 | 606 |
607 TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) { | 607 TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) { |
608 TypedefElement result = new TypedefElement(name, enclosing); | 608 TypedefElement result = new TypedefElement(name, enclosing); |
609 return result; | 609 return result; |
610 } | 610 } |
611 } | 611 } |
612 | 612 |
(...skipping 21 matching lines...) Expand all Loading... |
634 identifier = initializedIdentifier.asSendSet().selector.asIdentifier(); | 634 identifier = initializedIdentifier.asSendSet().selector.asIdentifier(); |
635 } | 635 } |
636 if (name === identifier.source) { | 636 if (name === identifier.source) { |
637 cachedNode = initializedIdentifier; | 637 cachedNode = initializedIdentifier; |
638 return cachedNode; | 638 return cachedNode; |
639 } | 639 } |
640 } | 640 } |
641 listener.cancel('internal error: could not find $name', node: variables); | 641 listener.cancel('internal error: could not find $name', node: variables); |
642 } | 642 } |
643 | 643 |
644 Type computeType(Compiler compiler) { | 644 DartType computeType(Compiler compiler) { |
645 return variables.computeType(compiler); | 645 return variables.computeType(compiler); |
646 } | 646 } |
647 | 647 |
648 Type get type => variables.type; | 648 DartType get type => variables.type; |
649 | 649 |
650 bool isInstanceMember() { | 650 bool isInstanceMember() { |
651 return isMember() && !modifiers.isStatic(); | 651 return isMember() && !modifiers.isStatic(); |
652 } | 652 } |
653 | 653 |
654 // Note: cachedNode.getBeginToken() will not be correct in all | 654 // Note: cachedNode.getBeginToken() will not be correct in all |
655 // cases, for example, for function typed parameters. | 655 // cases, for example, for function typed parameters. |
656 Token position() => findMyName(variables.position()); | 656 Token position() => findMyName(variables.position()); |
657 | 657 |
658 VariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | 658 VariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
(...skipping 28 matching lines...) Expand all Loading... |
687 return result; | 687 return result; |
688 } | 688 } |
689 } | 689 } |
690 | 690 |
691 // This element represents a list of variable or field declaration. | 691 // This element represents a list of variable or field declaration. |
692 // It contains the node, and the type. A [VariableElement] always | 692 // It contains the node, and the type. A [VariableElement] always |
693 // references its [VariableListElement]. It forwards its | 693 // references its [VariableListElement]. It forwards its |
694 // [computeType] and [parseNode] methods to this element. | 694 // [computeType] and [parseNode] methods to this element. |
695 class VariableListElement extends Element { | 695 class VariableListElement extends Element { |
696 VariableDefinitions cachedNode; | 696 VariableDefinitions cachedNode; |
697 Type type; | 697 DartType type; |
698 final Modifiers modifiers; | 698 final Modifiers modifiers; |
699 | 699 |
700 /** | 700 /** |
701 * Function signature for a variable with a function type. The signature is | 701 * Function signature for a variable with a function type. The signature is |
702 * kept to provide full information about parameter names through the mirror | 702 * kept to provide full information about parameter names through the mirror |
703 * system. | 703 * system. |
704 */ | 704 */ |
705 FunctionSignature functionSignature; | 705 FunctionSignature functionSignature; |
706 | 706 |
707 VariableListElement(ElementKind kind, | 707 VariableListElement(ElementKind kind, |
708 Modifiers this.modifiers, | 708 Modifiers this.modifiers, |
709 Element enclosing) | 709 Element enclosing) |
710 : super(null, kind, enclosing); | 710 : super(null, kind, enclosing); |
711 | 711 |
712 VariableListElement.node(VariableDefinitions node, | 712 VariableListElement.node(VariableDefinitions node, |
713 ElementKind kind, | 713 ElementKind kind, |
714 Element enclosing) | 714 Element enclosing) |
715 : super(null, kind, enclosing), | 715 : super(null, kind, enclosing), |
716 this.cachedNode = node, | 716 this.cachedNode = node, |
717 this.modifiers = node.modifiers; | 717 this.modifiers = node.modifiers; |
718 | 718 |
719 VariableDefinitions parseNode(DiagnosticListener listener) { | 719 VariableDefinitions parseNode(DiagnosticListener listener) { |
720 return cachedNode; | 720 return cachedNode; |
721 } | 721 } |
722 | 722 |
723 Type computeType(Compiler compiler) { | 723 DartType computeType(Compiler compiler) { |
724 if (type != null) return type; | 724 if (type != null) return type; |
725 VariableDefinitions node = parseNode(compiler); | 725 VariableDefinitions node = parseNode(compiler); |
726 if (node.type !== null) { | 726 if (node.type !== null) { |
727 type = compiler.resolveTypeAnnotation(this, node.type); | 727 type = compiler.resolveTypeAnnotation(this, node.type); |
728 } else { | 728 } else { |
729 // Is node.definitions exactly one FunctionExpression? | 729 // Is node.definitions exactly one FunctionExpression? |
730 Link<Node> link = node.definitions.nodes; | 730 Link<Node> link = node.definitions.nodes; |
731 if (!link.isEmpty() && | 731 if (!link.isEmpty() && |
732 link.head.asFunctionExpression() !== null && | 732 link.head.asFunctionExpression() !== null && |
733 link.tail.isEmpty()) { | 733 link.tail.isEmpty()) { |
(...skipping 23 matching lines...) Expand all Loading... |
757 result = new VariableListElement(kind, modifiers, enclosing); | 757 result = new VariableListElement(kind, modifiers, enclosing); |
758 } | 758 } |
759 return result; | 759 return result; |
760 } | 760 } |
761 } | 761 } |
762 | 762 |
763 class ForeignElement extends Element { | 763 class ForeignElement extends Element { |
764 ForeignElement(SourceString name, ContainerElement enclosingElement) | 764 ForeignElement(SourceString name, ContainerElement enclosingElement) |
765 : super(name, ElementKind.FOREIGN, enclosingElement); | 765 : super(name, ElementKind.FOREIGN, enclosingElement); |
766 | 766 |
767 Type computeType(Compiler compiler) { | 767 DartType computeType(Compiler compiler) { |
768 return compiler.types.dynamicType; | 768 return compiler.types.dynamicType; |
769 } | 769 } |
770 | 770 |
771 parseNode(DiagnosticListener listener) { | 771 parseNode(DiagnosticListener listener) { |
772 throw "internal error: ForeignElement has no node"; | 772 throw "internal error: ForeignElement has no node"; |
773 } | 773 } |
774 | 774 |
775 ForeignElement cloneTo(Element enclosing, DiagnosticListener listener) { | 775 ForeignElement cloneTo(Element enclosing, DiagnosticListener listener) { |
776 ForeignElement result = new ForeignElement(name, enclosing); | 776 ForeignElement result = new ForeignElement(name, enclosing); |
777 return result; | 777 return result; |
778 } | 778 } |
779 } | 779 } |
780 | 780 |
781 class AbstractFieldElement extends Element { | 781 class AbstractFieldElement extends Element { |
782 FunctionElement getter; | 782 FunctionElement getter; |
783 FunctionElement setter; | 783 FunctionElement setter; |
784 | 784 |
785 AbstractFieldElement(SourceString name, Element enclosing) | 785 AbstractFieldElement(SourceString name, Element enclosing) |
786 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); | 786 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); |
787 | 787 |
788 Type computeType(Compiler compiler) { | 788 DartType computeType(Compiler compiler) { |
789 throw "internal error: AbstractFieldElement has no type"; | 789 throw "internal error: AbstractFieldElement has no type"; |
790 } | 790 } |
791 | 791 |
792 Node parseNode(DiagnosticListener listener) { | 792 Node parseNode(DiagnosticListener listener) { |
793 throw "internal error: AbstractFieldElement has no node"; | 793 throw "internal error: AbstractFieldElement has no node"; |
794 } | 794 } |
795 | 795 |
796 position() { | 796 position() { |
797 // The getter and setter may be defined in two different | 797 // The getter and setter may be defined in two different |
798 // compilation units. However, we know that one of them is | 798 // compilation units. However, we know that one of them is |
(...skipping 29 matching lines...) Expand all Loading... |
828 listener.cancel("Cannot clone synthetic AbstractFieldElement", | 828 listener.cancel("Cannot clone synthetic AbstractFieldElement", |
829 element: this); | 829 element: this); |
830 } | 830 } |
831 } | 831 } |
832 | 832 |
833 // TODO(johnniwinther): [FunctionSignature] should be merged with | 833 // TODO(johnniwinther): [FunctionSignature] should be merged with |
834 // [FunctionType]. | 834 // [FunctionType]. |
835 class FunctionSignature { | 835 class FunctionSignature { |
836 Link<Element> requiredParameters; | 836 Link<Element> requiredParameters; |
837 Link<Element> optionalParameters; | 837 Link<Element> optionalParameters; |
838 Type returnType; | 838 DartType returnType; |
839 int requiredParameterCount; | 839 int requiredParameterCount; |
840 int optionalParameterCount; | 840 int optionalParameterCount; |
841 FunctionSignature(this.requiredParameters, | 841 FunctionSignature(this.requiredParameters, |
842 this.optionalParameters, | 842 this.optionalParameters, |
843 this.requiredParameterCount, | 843 this.requiredParameterCount, |
844 this.optionalParameterCount, | 844 this.optionalParameterCount, |
845 this.returnType); | 845 this.returnType); |
846 | 846 |
847 void forEachParameter(void function(Element parameter)) { | 847 void forEachParameter(void function(Element parameter)) { |
848 for (Link<Element> link = requiredParameters; | 848 for (Link<Element> link = requiredParameters; |
849 !link.isEmpty(); | 849 !link.isEmpty(); |
850 link = link.tail) { | 850 link = link.tail) { |
851 function(link.head); | 851 function(link.head); |
852 } | 852 } |
853 for (Link<Element> link = optionalParameters; | 853 for (Link<Element> link = optionalParameters; |
854 !link.isEmpty(); | 854 !link.isEmpty(); |
855 link = link.tail) { | 855 link = link.tail) { |
856 function(link.head); | 856 function(link.head); |
857 } | 857 } |
858 } | 858 } |
859 | 859 |
860 int get parameterCount => requiredParameterCount + optionalParameterCount; | 860 int get parameterCount => requiredParameterCount + optionalParameterCount; |
861 } | 861 } |
862 | 862 |
863 class FunctionElement extends Element { | 863 class FunctionElement extends Element { |
864 FunctionExpression cachedNode; | 864 FunctionExpression cachedNode; |
865 Type type; | 865 DartType type; |
866 final Modifiers modifiers; | 866 final Modifiers modifiers; |
867 | 867 |
868 FunctionSignature functionSignature; | 868 FunctionSignature functionSignature; |
869 | 869 |
870 /** | 870 /** |
871 * A function declaration that should be parsed instead of the current one. | 871 * A function declaration that should be parsed instead of the current one. |
872 * The patch should be parsed as if it was in the current scope. Its | 872 * The patch should be parsed as if it was in the current scope. Its |
873 * signature must match this function's signature. | 873 * signature must match this function's signature. |
874 */ | 874 */ |
875 // TODO(lrn): Consider using [defaultImplementation] to store the patch. | 875 // TODO(lrn): Consider using [defaultImplementation] to store the patch. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 | 1031 |
1032 SynthesizedConstructorElement cloneTo(Element enclosing, | 1032 SynthesizedConstructorElement cloneTo(Element enclosing, |
1033 DiagnosticListener listener) { | 1033 DiagnosticListener listener) { |
1034 return new SynthesizedConstructorElement(enclosing); | 1034 return new SynthesizedConstructorElement(enclosing); |
1035 } | 1035 } |
1036 } | 1036 } |
1037 | 1037 |
1038 class VoidElement extends Element { | 1038 class VoidElement extends Element { |
1039 VoidElement(Element enclosing) | 1039 VoidElement(Element enclosing) |
1040 : super(const SourceString('void'), ElementKind.VOID, enclosing); | 1040 : super(const SourceString('void'), ElementKind.VOID, enclosing); |
1041 Type computeType(compiler) => compiler.types.voidType; | 1041 DartType computeType(compiler) => compiler.types.voidType; |
1042 Node parseNode(_) { | 1042 Node parseNode(_) { |
1043 throw 'internal error: parseNode on void'; | 1043 throw 'internal error: parseNode on void'; |
1044 } | 1044 } |
1045 bool impliesType() => true; | 1045 bool impliesType() => true; |
1046 } | 1046 } |
1047 | 1047 |
1048 /** | 1048 /** |
1049 * [TypeDeclarationElement] defines the common interface for class/interface | 1049 * [TypeDeclarationElement] defines the common interface for class/interface |
1050 * declarations and typedefs. | 1050 * declarations and typedefs. |
1051 */ | 1051 */ |
1052 abstract class TypeDeclarationElement implements Element { | 1052 abstract class TypeDeclarationElement implements Element { |
1053 // TODO(johnniwinther): This class should eventually be a mixin. | 1053 // TODO(johnniwinther): This class should eventually be a mixin. |
1054 | 1054 |
1055 /** | 1055 /** |
1056 * The type variables declared on this declaration. The type variables are not | 1056 * The type variables declared on this declaration. The type variables are not |
1057 * available until the type of the element has been computed through | 1057 * available until the type of the element has been computed through |
1058 * [computeType]. | 1058 * [computeType]. |
1059 */ | 1059 */ |
1060 // TODO(johnniwinther): Find a (better) way to decouple [typeVariables] from | 1060 // TODO(johnniwinther): Find a (better) way to decouple [typeVariables] from |
1061 // [Compiler]. | 1061 // [Compiler]. |
1062 abstract Link<Type> get typeVariables; | 1062 abstract Link<DartType> get typeVariables; |
1063 | 1063 |
1064 /** | 1064 /** |
1065 * Creates the type variables, their type and corresponding element, for the | 1065 * Creates the type variables, their type and corresponding element, for the |
1066 * type variables declared in [parameter] on [element]. The bounds of the type | 1066 * type variables declared in [parameter] on [element]. The bounds of the type |
1067 * variables are not set until [element] has been resolved. | 1067 * variables are not set until [element] has been resolved. |
1068 */ | 1068 */ |
1069 static Link<Type> createTypeVariables(TypeDeclarationElement element, | 1069 static Link<DartType> createTypeVariables(TypeDeclarationElement element, |
1070 NodeList parameters) { | 1070 NodeList parameters) { |
1071 if (parameters === null) return const EmptyLink<Type>(); | 1071 if (parameters === null) return const EmptyLink<DartType>(); |
1072 | 1072 |
1073 // Create types and elements for type variable. | 1073 // Create types and elements for type variable. |
1074 var arguments = new LinkBuilder<Type>(); | 1074 var arguments = new LinkBuilder<DartType>(); |
1075 for (Link link = parameters.nodes; !link.isEmpty(); link = link.tail) { | 1075 for (Link link = parameters.nodes; !link.isEmpty(); link = link.tail) { |
1076 TypeVariable node = link.head; | 1076 TypeVariable node = link.head; |
1077 SourceString variableName = node.name.source; | 1077 SourceString variableName = node.name.source; |
1078 TypeVariableElement variableElement = | 1078 TypeVariableElement variableElement = |
1079 new TypeVariableElement(variableName, element, node); | 1079 new TypeVariableElement(variableName, element, node); |
1080 TypeVariableType variableType = new TypeVariableType(variableElement); | 1080 TypeVariableType variableType = new TypeVariableType(variableElement); |
1081 variableElement.type = variableType; | 1081 variableElement.type = variableType; |
1082 arguments.addLast(variableType); | 1082 arguments.addLast(variableType); |
1083 } | 1083 } |
1084 return arguments.toLink(); | 1084 return arguments.toLink(); |
1085 } | 1085 } |
1086 } | 1086 } |
1087 | 1087 |
1088 class ClassElement extends ScopeContainerElement | 1088 class ClassElement extends ScopeContainerElement |
1089 implements TypeDeclarationElement { | 1089 implements TypeDeclarationElement { |
1090 final int id; | 1090 final int id; |
1091 InterfaceType type; | 1091 InterfaceType type; |
1092 Type supertype; | 1092 DartType supertype; |
1093 Type defaultClass; | 1093 DartType defaultClass; |
1094 Link<Type> interfaces; | 1094 Link<DartType> interfaces; |
1095 SourceString nativeName; | 1095 SourceString nativeName; |
1096 int supertypeLoadState; | 1096 int supertypeLoadState; |
1097 int resolutionState; | 1097 int resolutionState; |
1098 | 1098 |
1099 // backendMembers are members that have been added by the backend to simplify | 1099 // backendMembers are members that have been added by the backend to simplify |
1100 // compilation. They don't have any user-side counter-part. | 1100 // compilation. They don't have any user-side counter-part. |
1101 Link<Element> backendMembers = const EmptyLink<Element>(); | 1101 Link<Element> backendMembers = const EmptyLink<Element>(); |
1102 | 1102 |
1103 Link<Type> allSupertypes; | 1103 Link<DartType> allSupertypes; |
1104 | 1104 |
1105 // Lazily applied patch of class members. | 1105 // Lazily applied patch of class members. |
1106 ClassElement patch = null; | 1106 ClassElement patch = null; |
1107 | 1107 |
1108 ClassElement(SourceString name, Element enclosing, this.id, int initialState) | 1108 ClassElement(SourceString name, Element enclosing, this.id, int initialState) |
1109 : supertypeLoadState = initialState, | 1109 : supertypeLoadState = initialState, |
1110 resolutionState = initialState, | 1110 resolutionState = initialState, |
1111 super(name, ElementKind.CLASS, enclosing); | 1111 super(name, ElementKind.CLASS, enclosing); |
1112 | 1112 |
1113 InterfaceType computeType(compiler) { | 1113 InterfaceType computeType(compiler) { |
1114 if (type == null) { | 1114 if (type == null) { |
1115 ClassNode node = parseNode(compiler); | 1115 ClassNode node = parseNode(compiler); |
1116 Link<Type> parameters = | 1116 Link<DartType> parameters = |
1117 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); | 1117 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); |
1118 type = new InterfaceType(this, parameters); | 1118 type = new InterfaceType(this, parameters); |
1119 } | 1119 } |
1120 return type; | 1120 return type; |
1121 } | 1121 } |
1122 | 1122 |
1123 bool get isPatched => patch != null; | 1123 bool get isPatched => patch != null; |
1124 | 1124 |
1125 Link<Type> get typeVariables => type.arguments; | 1125 Link<DartType> get typeVariables => type.arguments; |
1126 | 1126 |
1127 ClassElement ensureResolved(Compiler compiler) { | 1127 ClassElement ensureResolved(Compiler compiler) { |
1128 if (resolutionState == STATE_NOT_STARTED) { | 1128 if (resolutionState == STATE_NOT_STARTED) { |
1129 compiler.resolver.resolveClass(this); | 1129 compiler.resolver.resolveClass(this); |
1130 } | 1130 } |
1131 return this; | 1131 return this; |
1132 } | 1132 } |
1133 | 1133 |
1134 /** | 1134 /** |
1135 * Lookup local members in the class. This will ignore constructors. | 1135 * Lookup local members in the class. This will ignore constructors. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 void fieldFilter(ClassElement enclosingClass, Element member) { | 1337 void fieldFilter(ClassElement enclosingClass, Element member) { |
1338 if (member.isInstanceMember() && member.kind == ElementKind.FIELD) { | 1338 if (member.isInstanceMember() && member.kind == ElementKind.FIELD) { |
1339 f(enclosingClass, member); | 1339 f(enclosingClass, member); |
1340 } | 1340 } |
1341 } | 1341 } |
1342 | 1342 |
1343 forEachMember(fieldFilter, includeBackendMembers, includeSuperMembers); | 1343 forEachMember(fieldFilter, includeBackendMembers, includeSuperMembers); |
1344 } | 1344 } |
1345 | 1345 |
1346 bool implementsInterface(ClassElement intrface) { | 1346 bool implementsInterface(ClassElement intrface) { |
1347 for (Type implementedInterfaceType in allSupertypes) { | 1347 for (DartType implementedInterfaceType in allSupertypes) { |
1348 ClassElement implementedInterface = implementedInterfaceType.element; | 1348 ClassElement implementedInterface = implementedInterfaceType.element; |
1349 if (implementedInterface === intrface) { | 1349 if (implementedInterface === intrface) { |
1350 return true; | 1350 return true; |
1351 } | 1351 } |
1352 } | 1352 } |
1353 return false; | 1353 return false; |
1354 } | 1354 } |
1355 | 1355 |
1356 /** | 1356 /** |
1357 * Returns true if [this] is a subclass of [cls]. | 1357 * Returns true if [this] is a subclass of [cls]. |
(...skipping 13 matching lines...) Expand all Loading... |
1371 bool isNative() => nativeName != null; | 1371 bool isNative() => nativeName != null; |
1372 int hashCode() => id; | 1372 int hashCode() => id; |
1373 | 1373 |
1374 Scope buildScope() => | 1374 Scope buildScope() => |
1375 new ClassScope(enclosingElement.buildScope(), this); | 1375 new ClassScope(enclosingElement.buildScope(), this); |
1376 | 1376 |
1377 ClassElement cloneTo(Element enclosing, DiagnosticListener listener) { | 1377 ClassElement cloneTo(Element enclosing, DiagnosticListener listener) { |
1378 listener.internalErrorOnElement(this, 'unsupported operation'); | 1378 listener.internalErrorOnElement(this, 'unsupported operation'); |
1379 } | 1379 } |
1380 | 1380 |
1381 Link<Type> get allSupertypesAndSelf { | 1381 Link<DartType> get allSupertypesAndSelf { |
1382 return allSupertypes.prepend(new InterfaceType(this)); | 1382 return allSupertypes.prepend(new InterfaceType(this)); |
1383 } | 1383 } |
1384 } | 1384 } |
1385 | 1385 |
1386 class Elements { | 1386 class Elements { |
1387 static bool isLocal(Element element) { | 1387 static bool isLocal(Element element) { |
1388 return !Element.isInvalid(element) | 1388 return !Element.isInvalid(element) |
1389 && !element.isInstanceMember() | 1389 && !element.isInstanceMember() |
1390 && !isStaticOrTopLevelField(element) | 1390 && !isStaticOrTopLevelField(element) |
1391 && !isStaticOrTopLevelFunction(element) | 1391 && !isStaticOrTopLevelFunction(element) |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 | 1582 |
1583 bool get isSwitch => statement is SwitchStatement; | 1583 bool get isSwitch => statement is SwitchStatement; |
1584 | 1584 |
1585 Token position() => statement.getBeginToken(); | 1585 Token position() => statement.getBeginToken(); |
1586 String toString() => statement.toString(); | 1586 String toString() => statement.toString(); |
1587 } | 1587 } |
1588 | 1588 |
1589 class TypeVariableElement extends Element { | 1589 class TypeVariableElement extends Element { |
1590 final Node cachedNode; | 1590 final Node cachedNode; |
1591 TypeVariableType type; | 1591 TypeVariableType type; |
1592 Type bound; | 1592 DartType bound; |
1593 | 1593 |
1594 TypeVariableElement(name, Element enclosing, this.cachedNode, | 1594 TypeVariableElement(name, Element enclosing, this.cachedNode, |
1595 [this.type, this.bound]) | 1595 [this.type, this.bound]) |
1596 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1596 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
1597 | 1597 |
1598 TypeVariableType computeType(compiler) => type; | 1598 TypeVariableType computeType(compiler) => type; |
1599 | 1599 |
1600 Node parseNode(compiler) => cachedNode; | 1600 Node parseNode(compiler) => cachedNode; |
1601 | 1601 |
1602 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1602 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 | 1649 |
1650 MetadataAnnotation ensureResolved(Compiler compiler) { | 1650 MetadataAnnotation ensureResolved(Compiler compiler) { |
1651 if (resolutionState == STATE_NOT_STARTED) { | 1651 if (resolutionState == STATE_NOT_STARTED) { |
1652 compiler.resolver.resolveMetadataAnnotation(this); | 1652 compiler.resolver.resolveMetadataAnnotation(this); |
1653 } | 1653 } |
1654 return this; | 1654 return this; |
1655 } | 1655 } |
1656 | 1656 |
1657 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1657 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
1658 } | 1658 } |
OLD | NEW |