| 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('../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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 : super(const SourceString('void'), ElementKind.VOID, enclosing); | 806 : super(const SourceString('void'), ElementKind.VOID, enclosing); |
| 807 Type computeType(compiler) => compiler.types.voidType; | 807 Type computeType(compiler) => compiler.types.voidType; |
| 808 Node parseNode(_) { | 808 Node parseNode(_) { |
| 809 throw 'internal error: parseNode on void'; | 809 throw 'internal error: parseNode on void'; |
| 810 } | 810 } |
| 811 bool impliesType() => true; | 811 bool impliesType() => true; |
| 812 } | 812 } |
| 813 | 813 |
| 814 class ClassElement extends ContainerElement { | 814 class ClassElement extends ContainerElement { |
| 815 final int id; | 815 final int id; |
| 816 Type type; | 816 InterfaceType type; |
| 817 Type supertype; | 817 InterfaceType supertype; |
| 818 Type defaultClass; | 818 InterfaceType defaultClass; |
| 819 Link<Element> members = const EmptyLink<Element>(); | 819 Link<Element> members = const EmptyLink<Element>(); |
| 820 Map<SourceString, Element> localMembers; | 820 Map<SourceString, Element> localMembers; |
| 821 Map<SourceString, Element> constructors; | 821 Map<SourceString, Element> constructors; |
| 822 Link<Type> interfaces = const EmptyLink<Type>(); | 822 Link<InterfaceType> interfaces = const EmptyLink<InterfaceType>(); |
| 823 LinkedHashMap<SourceString, TypeVariableElement> typeParameters; | 823 LinkedHashMap<SourceString, TypeVariableElement> typeParameters; |
| 824 bool isResolved = false; | 824 bool isResolved = false; |
| 825 bool isBeingResolved = false; | 825 bool isBeingResolved = false; |
| 826 // backendMembers are members that have been added by the backend to simplify | 826 // backendMembers are members that have been added by the backend to simplify |
| 827 // compilation. They don't have any user-side counter-part. | 827 // compilation. They don't have any user-side counter-part. |
| 828 Link<Element> backendMembers = const EmptyLink<Element>(); | 828 Link<Element> backendMembers = const EmptyLink<Element>(); |
| 829 | 829 |
| 830 Link<Type> allSupertypes; | 830 Link<InterfaceType> allSupertypes; |
| 831 ClassElement patch = null; | 831 ClassElement patch = null; |
| 832 Node defaultClause; // Only for interfaces. | 832 Node defaultClause; // Only for interfaces. |
| 833 | 833 |
| 834 ClassElement(SourceString name, CompilationUnitElement enclosing, this.id) | 834 ClassElement(SourceString name, CompilationUnitElement enclosing, this.id) |
| 835 : localMembers = new Map<SourceString, Element>(), | 835 : localMembers = new Map<SourceString, Element>(), |
| 836 constructors = new Map<SourceString, Element>(), | 836 constructors = new Map<SourceString, Element>(), |
| 837 typeParameters = new LinkedHashMap<SourceString, TypeVariableElement>(), | 837 typeParameters = new LinkedHashMap<SourceString, TypeVariableElement>(), |
| 838 super(name, ElementKind.CLASS, enclosing); | 838 super(name, ElementKind.CLASS, enclosing); |
| 839 | 839 |
| 840 void addMember(Element element, DiagnosticListener listener) { | 840 void addMember(Element element, DiagnosticListener listener) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 TypeVariableElement variableElement = | 874 TypeVariableElement variableElement = |
| 875 new TypeVariableElement(variableName, this, node, | 875 new TypeVariableElement(variableName, this, node, |
| 876 variableType); | 876 variableType); |
| 877 variableType.element = variableElement; | 877 variableType.element = variableElement; |
| 878 typeParameters[variableName] = variableElement; | 878 typeParameters[variableName] = variableElement; |
| 879 } | 879 } |
| 880 type = new InterfaceType(this, arguments.toLink()); | 880 type = new InterfaceType(this, arguments.toLink()); |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 | 883 |
| 884 Type computeType(compiler) { | 884 InterfaceType computeType(compiler) { |
| 885 ensureParametersAndType(compiler); | 885 ensureParametersAndType(compiler); |
| 886 return type; | 886 return type; |
| 887 } | 887 } |
| 888 | 888 |
| 889 ClassElement ensureResolved(Compiler compiler) { | 889 ClassElement ensureResolved(Compiler compiler) { |
| 890 compiler.resolveClass(this); | 890 compiler.resolveClass(this); |
| 891 return this; | 891 return this; |
| 892 } | 892 } |
| 893 | 893 |
| 894 Element lookupTypeParameter(SourceString parameterName) { | 894 Element lookupTypeParameter(SourceString parameterName) { |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 | 1204 |
| 1205 bool get isSwitch() => statement is SwitchStatement; | 1205 bool get isSwitch() => statement is SwitchStatement; |
| 1206 | 1206 |
| 1207 Token position() => statement.getBeginToken(); | 1207 Token position() => statement.getBeginToken(); |
| 1208 String toString() => statement.toString(); | 1208 String toString() => statement.toString(); |
| 1209 } | 1209 } |
| 1210 | 1210 |
| 1211 class TypeVariableElement extends Element { | 1211 class TypeVariableElement extends Element { |
| 1212 final Node node; | 1212 final Node node; |
| 1213 Type bound; | 1213 Type bound; |
| 1214 Type type; | 1214 TypeVariableType type; |
| 1215 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1215 TypeVariableElement(name, Element enclosing, this.node, this.type, |
| 1216 [this.bound]) | 1216 [this.bound]) |
| 1217 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1217 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1218 Type computeType(compiler) => type; | 1218 TypeVariableType computeType(compiler) => type; |
| 1219 Node parseNode(compiler) => node; | 1219 Node parseNode(compiler) => node; |
| 1220 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1220 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1221 } | 1221 } |
| OLD | NEW |