| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 bool isAssignable() { | 135 bool isAssignable() { |
| 136 if (modifiers != null && modifiers.isFinal()) return false; | 136 if (modifiers != null && modifiers.isFinal()) return false; |
| 137 if (isFunction() || isGenerativeConstructor()) return false; | 137 if (isFunction() || isGenerativeConstructor()) return false; |
| 138 return true; | 138 return true; |
| 139 } | 139 } |
| 140 | 140 |
| 141 Token position() => null; | 141 Token position() => null; |
| 142 | 142 |
| 143 Token findMyName(Token token) { | 143 Token findMyName(Token token) { |
| 144 for (Token t = token; t !== EOF_TOKEN; t = t.next) { | 144 for (Token t = token; t.kind !== EOF_TOKEN; t = t.next) { |
| 145 if (t.value == name) return t; | 145 if (t.value == name) return t; |
| 146 } | 146 } |
| 147 return token; | 147 return token; |
| 148 } | 148 } |
| 149 | 149 |
| 150 Element(this.name, this.kind, this.enclosingElement) { | 150 Element(this.name, this.kind, this.enclosingElement) { |
| 151 assert(getLibrary() !== null); | 151 assert(getLibrary() !== null); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // TODO(kasperl): This is a very bad hash code for the element and | 154 // TODO(kasperl): This is a very bad hash code for the element and |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 do { | 792 do { |
| 793 for (Element element in classElement.members) { | 793 for (Element element in classElement.members) { |
| 794 f(classElement, element); | 794 f(classElement, element); |
| 795 } | 795 } |
| 796 if (includeBackendMembers) { | 796 if (includeBackendMembers) { |
| 797 for (Element element in classElement.backendMembers) { | 797 for (Element element in classElement.backendMembers) { |
| 798 f(classElement, element); | 798 f(classElement, element); |
| 799 } | 799 } |
| 800 } | 800 } |
| 801 classElement = includeSuperMembers ? classElement.superclass : null; | 801 classElement = includeSuperMembers ? classElement.superclass : null; |
| 802 } while(classElement !== null); | 802 } while(classElement !== null); |
| 803 } | 803 } |
| 804 | 804 |
| 805 /** | 805 /** |
| 806 * Runs through all instance-field members of this class. | 806 * Runs through all instance-field members of this class. |
| 807 * | 807 * |
| 808 * The enclosing class is passed to the callback. This is useful when | 808 * The enclosing class is passed to the callback. This is useful when |
| 809 * [includeSuperMembers] is [:true:]. | 809 * [includeSuperMembers] is [:true:]. |
| 810 * | 810 * |
| 811 * When [includeBackendMembers] and [includeSuperMembers] are both [:true:] | 811 * When [includeBackendMembers] and [includeSuperMembers] are both [:true:] |
| 812 * then the fields are visited in the same order as they need to be given | 812 * then the fields are visited in the same order as they need to be given |
| 813 * to the JavaScript constructor. | 813 * to the JavaScript constructor. |
| 814 */ | 814 */ |
| 815 void forEachInstanceField([void f(ClassElement enclosingClass, Element field), | 815 void forEachInstanceField([void f(ClassElement enclosingClass, Element field), |
| 816 includeBackendMembers = false, | 816 includeBackendMembers = false, |
| 817 includeSuperMembers = false]) { | 817 includeSuperMembers = false]) { |
| 818 // Filters so that [f] is only invoked with instance fields. | 818 // Filters so that [f] is only invoked with instance fields. |
| 819 void fieldFilter(ClassElement enclosingClass, Element member) { | 819 void fieldFilter(ClassElement enclosingClass, Element member) { |
| 820 if (member.isInstanceMember() && member.kind == ElementKind.FIELD) { | 820 if (member.isInstanceMember() && member.kind == ElementKind.FIELD) { |
| 821 f(enclosingClass, member); | 821 f(enclosingClass, member); |
| 822 } | 822 } |
| 823 } | 823 } |
| 824 | 824 |
| 825 forEachMember(fieldFilter, includeBackendMembers, includeSuperMembers); | 825 forEachMember(fieldFilter, includeBackendMembers, includeSuperMembers); |
| 826 } | 826 } |
| 827 | 827 |
| 828 bool implementsInterface(ClassElement intrface) { | 828 bool implementsInterface(ClassElement intrface) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 final Node node; | 1030 final Node node; |
| 1031 Type bound; | 1031 Type bound; |
| 1032 Type type; | 1032 Type type; |
| 1033 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1033 TypeVariableElement(name, Element enclosing, this.node, this.type, |
| 1034 [this.bound]) | 1034 [this.bound]) |
| 1035 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1035 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1036 Type computeType(compiler) => type; | 1036 Type computeType(compiler) => type; |
| 1037 Node parseNode(compiler) => node; | 1037 Node parseNode(compiler) => node; |
| 1038 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1038 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1039 } | 1039 } |
| OLD | NEW |