| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 static const ElementKind GETTER = | 83 static const ElementKind GETTER = |
| 84 const ElementKind('getter', ElementCategory.NONE); | 84 const ElementKind('getter', ElementCategory.NONE); |
| 85 static const ElementKind SETTER = | 85 static const ElementKind SETTER = |
| 86 const ElementKind('setter', ElementCategory.NONE); | 86 const ElementKind('setter', ElementCategory.NONE); |
| 87 static const ElementKind TYPE_VARIABLE = | 87 static const ElementKind TYPE_VARIABLE = |
| 88 const ElementKind('type_variable', ElementCategory.TYPE_VARIABLE); | 88 const ElementKind('type_variable', ElementCategory.TYPE_VARIABLE); |
| 89 static const ElementKind ABSTRACT_FIELD = | 89 static const ElementKind ABSTRACT_FIELD = |
| 90 const ElementKind('abstract_field', ElementCategory.VARIABLE); | 90 const ElementKind('abstract_field', ElementCategory.VARIABLE); |
| 91 static const ElementKind LIBRARY = | 91 static const ElementKind LIBRARY = |
| 92 const ElementKind('library', ElementCategory.NONE); | 92 const ElementKind('library', ElementCategory.NONE); |
| 93 static const ElementKind COMPILATION_UNIT_OVERRIDE = | |
| 94 const ElementKind('compilation_unit_override', ElementCategory.NONE); | |
| 95 static const ElementKind PREFIX = | 93 static const ElementKind PREFIX = |
| 96 const ElementKind('prefix', ElementCategory.PREFIX); | 94 const ElementKind('prefix', ElementCategory.PREFIX); |
| 97 static const ElementKind TYPEDEF = | 95 static const ElementKind TYPEDEF = |
| 98 const ElementKind('typedef', ElementCategory.ALIAS); | 96 const ElementKind('typedef', ElementCategory.ALIAS); |
| 99 | 97 |
| 100 static const ElementKind STATEMENT = | 98 static const ElementKind STATEMENT = |
| 101 const ElementKind('statement', ElementCategory.NONE); | 99 const ElementKind('statement', ElementCategory.NONE); |
| 102 static const ElementKind LABEL = | 100 static const ElementKind LABEL = |
| 103 const ElementKind('label', ElementCategory.NONE); | 101 const ElementKind('label', ElementCategory.NONE); |
| 104 static const ElementKind VOID = | 102 static const ElementKind VOID = |
| (...skipping 26 matching lines...) Expand all Loading... |
| 131 assert(annotation.annotatedElement === null); | 129 assert(annotation.annotatedElement === null); |
| 132 annotation.annotatedElement = this; | 130 annotation.annotatedElement = this; |
| 133 metadata = metadata.prepend(annotation); | 131 metadata = metadata.prepend(annotation); |
| 134 } | 132 } |
| 135 | 133 |
| 136 bool isFunction() => kind === ElementKind.FUNCTION; | 134 bool isFunction() => kind === ElementKind.FUNCTION; |
| 137 bool isConstructor() => isFactoryConstructor() || isGenerativeConstructor(); | 135 bool isConstructor() => isFactoryConstructor() || isGenerativeConstructor(); |
| 138 bool isClosure() => false; | 136 bool isClosure() => false; |
| 139 bool isMember() { | 137 bool isMember() { |
| 140 // Check that this element is defined in the scope of a Class. | 138 // Check that this element is defined in the scope of a Class. |
| 141 Element enclosing = enclosingElement; | 139 return enclosingElement !== null && enclosingElement.isClass(); |
| 142 if (enclosing !== null && | |
| 143 enclosing.kind === ElementKind.COMPILATION_UNIT_OVERRIDE) { | |
| 144 enclosing = enclosing.enclosingElement; | |
| 145 } | |
| 146 return enclosing !== null && enclosing.isClass(); | |
| 147 } | 140 } |
| 148 bool isInstanceMember() => false; | 141 bool isInstanceMember() => false; |
| 149 bool isFactoryConstructor() => modifiers.isFactory(); | 142 bool isFactoryConstructor() => modifiers.isFactory(); |
| 150 bool isGenerativeConstructor() => kind === ElementKind.GENERATIVE_CONSTRUCTOR; | 143 bool isGenerativeConstructor() => kind === ElementKind.GENERATIVE_CONSTRUCTOR; |
| 151 bool isGenerativeConstructorBody() => | 144 bool isGenerativeConstructorBody() => |
| 152 kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY; | 145 kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY; |
| 153 bool isCompilationUnit() => kind === ElementKind.COMPILATION_UNIT; | 146 bool isCompilationUnit() => kind === ElementKind.COMPILATION_UNIT; |
| 154 bool isClass() => kind === ElementKind.CLASS; | 147 bool isClass() => kind === ElementKind.CLASS; |
| 155 bool isPrefix() => kind === ElementKind.PREFIX; | 148 bool isPrefix() => kind === ElementKind.PREFIX; |
| 156 bool isVariable() => kind === ElementKind.VARIABLE; | 149 bool isVariable() => kind === ElementKind.VARIABLE; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 236 } |
| 244 | 237 |
| 245 // TODO(kasperl): This is a very bad hash code for the element and | 238 // TODO(kasperl): This is a very bad hash code for the element and |
| 246 // there's no reason why two elements with the same name should have | 239 // there's no reason why two elements with the same name should have |
| 247 // the same hash code. Replace this with a simple id in the element? | 240 // the same hash code. Replace this with a simple id in the element? |
| 248 int hashCode() => name === null ? 0 : name.hashCode(); | 241 int hashCode() => name === null ? 0 : name.hashCode(); |
| 249 | 242 |
| 250 CompilationUnitElement getCompilationUnit() { | 243 CompilationUnitElement getCompilationUnit() { |
| 251 Element element = this; | 244 Element element = this; |
| 252 while (element !== null && !element.isCompilationUnit()) { | 245 while (element !== null && !element.isCompilationUnit()) { |
| 253 if (element is CompilationUnitOverrideElement) { | |
| 254 CompilationUnitOverrideElement override = element; | |
| 255 return override.compilationUnit; | |
| 256 } | |
| 257 if (element.isLibrary()) { | 246 if (element.isLibrary()) { |
| 258 LibraryElement library = element; | 247 LibraryElement library = element; |
| 259 return library.entryCompilationUnit; | 248 return library.entryCompilationUnit; |
| 260 } | 249 } |
| 261 element = element.enclosingElement; | 250 element = element.enclosingElement; |
| 262 } | 251 } |
| 263 return element; | 252 return element; |
| 264 } | 253 } |
| 265 | 254 |
| 266 LibraryElement getLibrary() => enclosingElement.getLibrary(); | 255 LibraryElement getLibrary() => enclosingElement.getLibrary(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 323 } |
| 335 } | 324 } |
| 336 | 325 |
| 337 bool _isNative = false; | 326 bool _isNative = false; |
| 338 void setNative() { _isNative = true; } | 327 void setNative() { _isNative = true; } |
| 339 bool isNative() => _isNative; | 328 bool isNative() => _isNative; |
| 340 | 329 |
| 341 FunctionElement asFunctionElement() => null; | 330 FunctionElement asFunctionElement() => null; |
| 342 | 331 |
| 343 static bool isInvalid(Element e) => e == null || e.isErroneous(); | 332 static bool isInvalid(Element e) => e == null || e.isErroneous(); |
| 344 Element cloneTo(Element enclosing, DiagnosticListener listener) { | |
| 345 listener.cancel("Unimplemented cloneTo", element: this); | |
| 346 } | |
| 347 } | 333 } |
| 348 | 334 |
| 349 /** | 335 /** |
| 350 * Represents an unresolvable or duplicated element. | 336 * Represents an unresolvable or duplicated element. |
| 351 * | 337 * |
| 352 * An [ErroneousElement] is used instead of [null] to provide additional | 338 * An [ErroneousElement] is used instead of [null] to provide additional |
| 353 * information about the error that caused the element to be unresolvable | 339 * information about the error that caused the element to be unresolvable |
| 354 * or otherwise invalid. | 340 * or otherwise invalid. |
| 355 * | 341 * |
| 356 * Accessing any field or calling any method defined on [ErroneousElement] | 342 * Accessing any field or calling any method defined on [ErroneousElement] |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 super.addMember(element, listener); | 507 super.addMember(element, listener); |
| 522 // Provide the member to the library to build scope. | 508 // Provide the member to the library to build scope. |
| 523 if (enclosingElement.isPatch) { | 509 if (enclosingElement.isPatch) { |
| 524 getImplementationLibrary().addMember(element, listener); | 510 getImplementationLibrary().addMember(element, listener); |
| 525 } else { | 511 } else { |
| 526 getLibrary().addMember(element, listener); | 512 getLibrary().addMember(element, listener); |
| 527 } | 513 } |
| 528 } | 514 } |
| 529 } | 515 } |
| 530 | 516 |
| 531 class CompilationUnitOverrideElement extends Element { | |
| 532 final CompilationUnitElement compilationUnit; | |
| 533 | |
| 534 CompilationUnitOverrideElement(CompilationUnitElement compilationUnit, | |
| 535 Element enclosing) | |
| 536 : this.compilationUnit = compilationUnit, | |
| 537 super(compilationUnit.name, | |
| 538 ElementKind.COMPILATION_UNIT_OVERRIDE, | |
| 539 enclosing); | |
| 540 } | |
| 541 | |
| 542 class LibraryElement extends ScopeContainerElement { | 517 class LibraryElement extends ScopeContainerElement { |
| 543 final Uri uri; | 518 final Uri uri; |
| 544 CompilationUnitElement entryCompilationUnit; | 519 CompilationUnitElement entryCompilationUnit; |
| 545 Link<CompilationUnitElement> compilationUnits = | 520 Link<CompilationUnitElement> compilationUnits = |
| 546 const EmptyLink<CompilationUnitElement>(); | 521 const EmptyLink<CompilationUnitElement>(); |
| 547 Link<LibraryTag> tags = const EmptyLink<LibraryTag>(); | 522 Link<LibraryTag> tags = const EmptyLink<LibraryTag>(); |
| 548 LibraryTag libraryTag; | 523 LibraryTag libraryTag; |
| 549 bool canUseNative = false; | 524 bool canUseNative = false; |
| 550 | 525 |
| 551 /** | 526 /** |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 | 690 |
| 716 PrefixElement(SourceString prefix, Element enclosing, this.firstPosition) | 691 PrefixElement(SourceString prefix, Element enclosing, this.firstPosition) |
| 717 : imported = new Map<SourceString, Element>(), | 692 : imported = new Map<SourceString, Element>(), |
| 718 super(prefix, ElementKind.PREFIX, enclosing); | 693 super(prefix, ElementKind.PREFIX, enclosing); |
| 719 | 694 |
| 720 lookupLocalMember(SourceString memberName) => imported[memberName]; | 695 lookupLocalMember(SourceString memberName) => imported[memberName]; |
| 721 | 696 |
| 722 DartType computeType(Compiler compiler) => compiler.types.dynamicType; | 697 DartType computeType(Compiler compiler) => compiler.types.dynamicType; |
| 723 | 698 |
| 724 Token position() => firstPosition; | 699 Token position() => firstPosition; |
| 725 | |
| 726 PrefixElement cloneTo(Element enclosing, DiagnosticListener listener) { | |
| 727 return new PrefixElement(name, enclosing, firstPosition); | |
| 728 } | |
| 729 } | 700 } |
| 730 | 701 |
| 731 class TypedefElement extends Element implements TypeDeclarationElement { | 702 class TypedefElement extends Element implements TypeDeclarationElement { |
| 732 Typedef cachedNode; | 703 Typedef cachedNode; |
| 733 TypedefType cachedType; | 704 TypedefType cachedType; |
| 734 DartType alias; | 705 DartType alias; |
| 735 | 706 |
| 736 bool isResolved = false; | 707 bool isResolved = false; |
| 737 bool isBeingResolved = false; | 708 bool isBeingResolved = false; |
| 738 | 709 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 759 return cachedType; | 730 return cachedType; |
| 760 } | 731 } |
| 761 | 732 |
| 762 Link<DartType> get typeVariables => cachedType.typeArguments; | 733 Link<DartType> get typeVariables => cachedType.typeArguments; |
| 763 | 734 |
| 764 // TODO(johnniwinther): Rewrite to avoid the optional argument. | 735 // TODO(johnniwinther): Rewrite to avoid the optional argument. |
| 765 Scope buildScope({bool patchScope: false}) { | 736 Scope buildScope({bool patchScope: false}) { |
| 766 return new TypeDeclarationScope( | 737 return new TypeDeclarationScope( |
| 767 enclosingElement.buildScope(patchScope: patchScope), this); | 738 enclosingElement.buildScope(patchScope: patchScope), this); |
| 768 } | 739 } |
| 769 | |
| 770 TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) { | |
| 771 TypedefElement result = new TypedefElement(name, enclosing); | |
| 772 return result; | |
| 773 } | |
| 774 } | 740 } |
| 775 | 741 |
| 776 class VariableElement extends Element { | 742 class VariableElement extends Element { |
| 777 final VariableListElement variables; | 743 final VariableListElement variables; |
| 778 Expression cachedNode; // The send or the identifier in the variables list. | 744 Expression cachedNode; // The send or the identifier in the variables list. |
| 779 | 745 |
| 780 Modifiers get modifiers => variables.modifiers; | 746 Modifiers get modifiers => variables.modifiers; |
| 781 | 747 |
| 782 VariableElement(SourceString name, | 748 VariableElement(SourceString name, |
| 783 VariableListElement this.variables, | 749 VariableListElement this.variables, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 808 return variables.computeType(compiler); | 774 return variables.computeType(compiler); |
| 809 } | 775 } |
| 810 | 776 |
| 811 DartType get type => variables.type; | 777 DartType get type => variables.type; |
| 812 | 778 |
| 813 bool isInstanceMember() => variables.isInstanceMember(); | 779 bool isInstanceMember() => variables.isInstanceMember(); |
| 814 | 780 |
| 815 // Note: cachedNode.getBeginToken() will not be correct in all | 781 // Note: cachedNode.getBeginToken() will not be correct in all |
| 816 // cases, for example, for function typed parameters. | 782 // cases, for example, for function typed parameters. |
| 817 Token position() => findMyName(variables.position()); | 783 Token position() => findMyName(variables.position()); |
| 818 | |
| 819 VariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | |
| 820 VariableListElement clonedVariables = | |
| 821 variables.cloneTo(enclosing, listener); | |
| 822 VariableElement result = new VariableElement( | |
| 823 name, clonedVariables, kind, enclosing, cachedNode); | |
| 824 return result; | |
| 825 } | |
| 826 } | 784 } |
| 827 | 785 |
| 828 /** | 786 /** |
| 829 * Parameters in constructors that directly initialize fields. For example: | 787 * Parameters in constructors that directly initialize fields. For example: |
| 830 * [:A(this.field):]. | 788 * [:A(this.field):]. |
| 831 */ | 789 */ |
| 832 class FieldParameterElement extends VariableElement { | 790 class FieldParameterElement extends VariableElement { |
| 833 VariableElement fieldElement; | 791 VariableElement fieldElement; |
| 834 | 792 |
| 835 FieldParameterElement(SourceString name, | 793 FieldParameterElement(SourceString name, |
| 836 this.fieldElement, | 794 this.fieldElement, |
| 837 VariableListElement variables, | 795 VariableListElement variables, |
| 838 Element enclosing, | 796 Element enclosing, |
| 839 Node node) | 797 Node node) |
| 840 : super(name, variables, ElementKind.FIELD_PARAMETER, enclosing, node); | 798 : super(name, variables, ElementKind.FIELD_PARAMETER, enclosing, node); |
| 841 | |
| 842 FieldParameterElement cloneTo(Element enclosing, | |
| 843 DiagnosticListener listener) { | |
| 844 FieldParameterElement result = | |
| 845 new FieldParameterElement(name, fieldElement, | |
| 846 variables.cloneTo(enclosing, listener), | |
| 847 enclosing, cachedNode); | |
| 848 return result; | |
| 849 } | |
| 850 } | 799 } |
| 851 | 800 |
| 852 // This element represents a list of variable or field declaration. | 801 // This element represents a list of variable or field declaration. |
| 853 // It contains the node, and the type. A [VariableElement] always | 802 // It contains the node, and the type. A [VariableElement] always |
| 854 // references its [VariableListElement]. It forwards its | 803 // references its [VariableListElement]. It forwards its |
| 855 // [computeType] and [parseNode] methods to this element. | 804 // [computeType] and [parseNode] methods to this element. |
| 856 class VariableListElement extends Element { | 805 class VariableListElement extends Element { |
| 857 VariableDefinitions cachedNode; | 806 VariableDefinitions cachedNode; |
| 858 DartType type; | 807 DartType type; |
| 859 final Modifiers modifiers; | 808 final Modifiers modifiers; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 type = compiler.types.dynamicType; | 854 type = compiler.types.dynamicType; |
| 906 } | 855 } |
| 907 } | 856 } |
| 908 }); | 857 }); |
| 909 assert(type != null); | 858 assert(type != null); |
| 910 return type; | 859 return type; |
| 911 } | 860 } |
| 912 | 861 |
| 913 Token position() => cachedNode.getBeginToken(); | 862 Token position() => cachedNode.getBeginToken(); |
| 914 | 863 |
| 915 VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) { | |
| 916 VariableListElement result; | |
| 917 if (cachedNode !== null) { | |
| 918 result = new VariableListElement.node(cachedNode, kind, enclosing); | |
| 919 } else { | |
| 920 result = new VariableListElement(kind, modifiers, enclosing); | |
| 921 } | |
| 922 return result; | |
| 923 } | |
| 924 | |
| 925 bool isInstanceMember() { | 864 bool isInstanceMember() { |
| 926 return isMember() && !modifiers.isStatic(); | 865 return isMember() && !modifiers.isStatic(); |
| 927 } | 866 } |
| 928 | 867 |
| 929 // TODO(johnniwinther): Rewrite to avoid the optional argument. | 868 // TODO(johnniwinther): Rewrite to avoid the optional argument. |
| 930 Scope buildScope({bool patchScope: false}) { | 869 Scope buildScope({bool patchScope: false}) { |
| 931 Scope result = new VariableScope( | 870 Scope result = new VariableScope( |
| 932 enclosingElement.buildScope(patchScope: patchScope), this); | 871 enclosingElement.buildScope(patchScope: patchScope), this); |
| 933 if (enclosingElement.isClass()) { | 872 if (enclosingElement.isClass()) { |
| 934 Scope clsScope = result.parent; | 873 Scope clsScope = result.parent; |
| 935 clsScope.inStaticContext = !isInstanceMember(); | 874 clsScope.inStaticContext = !isInstanceMember(); |
| 936 } | 875 } |
| 937 return result; | 876 return result; |
| 938 } | 877 } |
| 939 } | 878 } |
| 940 | 879 |
| 941 class ForeignElement extends Element { | 880 class ForeignElement extends Element { |
| 942 ForeignElement(SourceString name, ContainerElement enclosingElement) | 881 ForeignElement(SourceString name, ContainerElement enclosingElement) |
| 943 : super(name, ElementKind.FOREIGN, enclosingElement); | 882 : super(name, ElementKind.FOREIGN, enclosingElement); |
| 944 | 883 |
| 945 DartType computeType(Compiler compiler) { | 884 DartType computeType(Compiler compiler) { |
| 946 return compiler.types.dynamicType; | 885 return compiler.types.dynamicType; |
| 947 } | 886 } |
| 948 | 887 |
| 949 parseNode(DiagnosticListener listener) { | 888 parseNode(DiagnosticListener listener) { |
| 950 throw "internal error: ForeignElement has no node"; | 889 throw "internal error: ForeignElement has no node"; |
| 951 } | 890 } |
| 952 | |
| 953 ForeignElement cloneTo(Element enclosing, DiagnosticListener listener) { | |
| 954 ForeignElement result = new ForeignElement(name, enclosing); | |
| 955 return result; | |
| 956 } | |
| 957 } | 891 } |
| 958 | 892 |
| 959 class AbstractFieldElement extends Element { | 893 class AbstractFieldElement extends Element { |
| 960 FunctionElement getter; | 894 FunctionElement getter; |
| 961 FunctionElement setter; | 895 FunctionElement setter; |
| 962 | 896 |
| 963 AbstractFieldElement(SourceString name, Element enclosing) | 897 AbstractFieldElement(SourceString name, Element enclosing) |
| 964 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); | 898 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); |
| 965 | 899 |
| 966 DartType computeType(Compiler compiler) { | 900 DartType computeType(Compiler compiler) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 994 if (getter !== null) { | 928 if (getter !== null) { |
| 995 return new Modifiers.withFlags( | 929 return new Modifiers.withFlags( |
| 996 getter.modifiers.nodes, | 930 getter.modifiers.nodes, |
| 997 getter.modifiers.flags | Modifiers.FLAG_ABSTRACT); | 931 getter.modifiers.flags | Modifiers.FLAG_ABSTRACT); |
| 998 } else { | 932 } else { |
| 999 return new Modifiers.withFlags( | 933 return new Modifiers.withFlags( |
| 1000 setter.modifiers.nodes, | 934 setter.modifiers.nodes, |
| 1001 setter.modifiers.flags | Modifiers.FLAG_ABSTRACT); | 935 setter.modifiers.flags | Modifiers.FLAG_ABSTRACT); |
| 1002 } | 936 } |
| 1003 } | 937 } |
| 1004 | |
| 1005 AbstractFieldElement cloneTo(Element enclosing, DiagnosticListener listener) { | |
| 1006 listener.cancel("Cannot clone synthetic AbstractFieldElement", | |
| 1007 element: this); | |
| 1008 } | |
| 1009 } | 938 } |
| 1010 | 939 |
| 1011 // TODO(johnniwinther): [FunctionSignature] should be merged with | 940 // TODO(johnniwinther): [FunctionSignature] should be merged with |
| 1012 // [FunctionType]. | 941 // [FunctionType]. |
| 1013 class FunctionSignature { | 942 class FunctionSignature { |
| 1014 final Link<Element> requiredParameters; | 943 final Link<Element> requiredParameters; |
| 1015 final Link<Element> optionalParameters; | 944 final Link<Element> optionalParameters; |
| 1016 final DartType returnType; | 945 final DartType returnType; |
| 1017 final int requiredParameterCount; | 946 final int requiredParameterCount; |
| 1018 final int optionalParameterCount; | 947 final int optionalParameterCount; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 } | 1154 } |
| 1226 | 1155 |
| 1227 Node parseNode(DiagnosticListener listener) { | 1156 Node parseNode(DiagnosticListener listener) { |
| 1228 if (cachedNode !== null) return cachedNode; | 1157 if (cachedNode !== null) return cachedNode; |
| 1229 cachedNode = constructor.parseNode(listener); | 1158 cachedNode = constructor.parseNode(listener); |
| 1230 assert(cachedNode !== null); | 1159 assert(cachedNode !== null); |
| 1231 return cachedNode; | 1160 return cachedNode; |
| 1232 } | 1161 } |
| 1233 | 1162 |
| 1234 Token position() => constructor.position(); | 1163 Token position() => constructor.position(); |
| 1235 | |
| 1236 ConstructorBodyElement cloneTo(Element enclosing, | |
| 1237 DiagnosticListener listener) { | |
| 1238 ConstructorBodyElement result = | |
| 1239 new ConstructorBodyElement(constructor.cloneTo(enclosing, listener)); | |
| 1240 return result; | |
| 1241 } | |
| 1242 } | 1164 } |
| 1243 | 1165 |
| 1244 class SynthesizedConstructorElement extends FunctionElement { | 1166 class SynthesizedConstructorElement extends FunctionElement { |
| 1245 SynthesizedConstructorElement(Element enclosing) | 1167 SynthesizedConstructorElement(Element enclosing) |
| 1246 : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR, | 1168 : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR, |
| 1247 Modifiers.EMPTY, enclosing); | 1169 Modifiers.EMPTY, enclosing); |
| 1248 | 1170 |
| 1249 Token position() => enclosingElement.position(); | 1171 Token position() => enclosingElement.position(); |
| 1250 | |
| 1251 SynthesizedConstructorElement cloneTo(Element enclosing, | |
| 1252 DiagnosticListener listener) { | |
| 1253 return new SynthesizedConstructorElement(enclosing); | |
| 1254 } | |
| 1255 } | 1172 } |
| 1256 | 1173 |
| 1257 class VoidElement extends Element { | 1174 class VoidElement extends Element { |
| 1258 VoidElement(Element enclosing) | 1175 VoidElement(Element enclosing) |
| 1259 : super(const SourceString('void'), ElementKind.VOID, enclosing); | 1176 : super(const SourceString('void'), ElementKind.VOID, enclosing); |
| 1260 DartType computeType(compiler) => compiler.types.voidType; | 1177 DartType computeType(compiler) => compiler.types.voidType; |
| 1261 Node parseNode(_) { | 1178 Node parseNode(_) { |
| 1262 throw 'internal error: parseNode on void'; | 1179 throw 'internal error: parseNode on void'; |
| 1263 } | 1180 } |
| 1264 bool impliesType() => true; | 1181 bool impliesType() => true; |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 } | 1563 } |
| 1647 | 1564 |
| 1648 Scope buildLocalScope() { | 1565 Scope buildLocalScope() { |
| 1649 if (origin !== null) { | 1566 if (origin !== null) { |
| 1650 return new LocalPatchClassScope(origin, this); | 1567 return new LocalPatchClassScope(origin, this); |
| 1651 } else { | 1568 } else { |
| 1652 return new LocalClassScope(this); | 1569 return new LocalClassScope(this); |
| 1653 } | 1570 } |
| 1654 } | 1571 } |
| 1655 | 1572 |
| 1656 ClassElement cloneTo(Element enclosing, DiagnosticListener listener) { | |
| 1657 listener.internalErrorOnElement(this, 'unsupported operation'); | |
| 1658 } | |
| 1659 | |
| 1660 Link<DartType> get allSupertypesAndSelf { | 1573 Link<DartType> get allSupertypesAndSelf { |
| 1661 return allSupertypes.prepend(new InterfaceType(this)); | 1574 return allSupertypes.prepend(new InterfaceType(this)); |
| 1662 } | 1575 } |
| 1663 | 1576 |
| 1664 String toString() { | 1577 String toString() { |
| 1665 if (origin !== null) { | 1578 if (origin !== null) { |
| 1666 return 'patch ${super.toString()}'; | 1579 return 'patch ${super.toString()}'; |
| 1667 } else if (patch !== null) { | 1580 } else if (patch !== null) { |
| 1668 return 'origin ${super.toString()}'; | 1581 return 'origin ${super.toString()}'; |
| 1669 } else { | 1582 } else { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 [this.type, this.bound]) | 1823 [this.type, this.bound]) |
| 1911 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1824 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1912 | 1825 |
| 1913 TypeVariableType computeType(compiler) => type; | 1826 TypeVariableType computeType(compiler) => type; |
| 1914 | 1827 |
| 1915 Node parseNode(compiler) => cachedNode; | 1828 Node parseNode(compiler) => cachedNode; |
| 1916 | 1829 |
| 1917 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1830 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1918 | 1831 |
| 1919 Token position() => cachedNode.getBeginToken(); | 1832 Token position() => cachedNode.getBeginToken(); |
| 1920 | |
| 1921 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | |
| 1922 TypeVariableElement result = | |
| 1923 new TypeVariableElement(name, enclosing, cachedNode, type, bound); | |
| 1924 return result; | |
| 1925 } | |
| 1926 } | 1833 } |
| 1927 | 1834 |
| 1928 /** | 1835 /** |
| 1929 * A single metadata annotation. | 1836 * A single metadata annotation. |
| 1930 * | 1837 * |
| 1931 * For example, consider: | 1838 * For example, consider: |
| 1932 * | 1839 * |
| 1933 * [: | 1840 * [: |
| 1934 * class Data { | 1841 * class Data { |
| 1935 * const Data(); | 1842 * const Data(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1964 | 1871 |
| 1965 MetadataAnnotation ensureResolved(Compiler compiler) { | 1872 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1966 if (resolutionState == STATE_NOT_STARTED) { | 1873 if (resolutionState == STATE_NOT_STARTED) { |
| 1967 compiler.resolver.resolveMetadataAnnotation(this); | 1874 compiler.resolver.resolveMetadataAnnotation(this); |
| 1968 } | 1875 } |
| 1969 return this; | 1876 return this; |
| 1970 } | 1877 } |
| 1971 | 1878 |
| 1972 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1879 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1973 } | 1880 } |
| OLD | NEW |