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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 bool isMember() => | 116 bool isMember() => |
117 enclosingElement !== null && enclosingElement.kind === ElementKind.CLASS; | 117 enclosingElement !== null && enclosingElement.kind === ElementKind.CLASS; |
118 bool isInstanceMember() => false; | 118 bool isInstanceMember() => false; |
119 bool isFactoryConstructor() => modifiers !== null && modifiers.isFactory(); | 119 bool isFactoryConstructor() => modifiers !== null && modifiers.isFactory(); |
120 bool isGenerativeConstructor() => kind === ElementKind.GENERATIVE_CONSTRUCTOR; | 120 bool isGenerativeConstructor() => kind === ElementKind.GENERATIVE_CONSTRUCTOR; |
121 bool isCompilationUnit() { | 121 bool isCompilationUnit() { |
122 return kind === ElementKind.COMPILATION_UNIT || | 122 return kind === ElementKind.COMPILATION_UNIT || |
123 kind === ElementKind.LIBRARY; | 123 kind === ElementKind.LIBRARY; |
124 } | 124 } |
125 bool isClass() => kind === ElementKind.CLASS; | 125 bool isClass() => kind === ElementKind.CLASS; |
126 bool isPrefix() => kind === ElementKind.PREFIX; | |
126 bool isVariable() => kind === ElementKind.VARIABLE; | 127 bool isVariable() => kind === ElementKind.VARIABLE; |
127 bool isParameter() => kind === ElementKind.PARAMETER; | 128 bool isParameter() => kind === ElementKind.PARAMETER; |
128 bool isStatement() => kind === ElementKind.STATEMENT; | 129 bool isStatement() => kind === ElementKind.STATEMENT; |
129 bool isTypedef() => kind === ElementKind.TYPEDEF; | 130 bool isTypedef() => kind === ElementKind.TYPEDEF; |
130 bool isTypeVariable() => kind === ElementKind.TYPE_VARIABLE; | 131 bool isTypeVariable() => kind === ElementKind.TYPE_VARIABLE; |
131 bool isField() => kind === ElementKind.FIELD; | 132 bool isField() => kind === ElementKind.FIELD; |
132 bool isGetter() => kind === ElementKind.GETTER; | 133 bool isGetter() => kind === ElementKind.GETTER; |
133 bool isSetter() => kind === ElementKind.SETTER; | 134 bool isSetter() => kind === ElementKind.SETTER; |
135 bool isAccessor() => isGetter() || isSetter(); | |
136 bool isForeign() => kind === ElementKind.FOREIGN; | |
134 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; | 137 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; |
135 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; | 138 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; |
136 | 139 |
140 bool isTopLevel() => enclosingElement.isCompilationUnit(); | |
141 | |
137 bool isAssignable() { | 142 bool isAssignable() { |
138 if (modifiers != null && modifiers.isFinal()) return false; | 143 if (modifiers != null && modifiers.isFinal()) return false; |
139 if (isFunction() || isGenerativeConstructor()) return false; | 144 if (isFunction() || isGenerativeConstructor()) return false; |
140 return true; | 145 return true; |
141 } | 146 } |
142 | 147 |
143 Token position() => null; | 148 Token position() => null; |
144 | 149 |
145 Token findMyName(Token token) { | 150 Token findMyName(Token token) { |
146 for (Token t = token; t.kind !== EOF_TOKEN; t = t.next) { | 151 for (Token t = token; t.kind !== EOF_TOKEN; t = t.next) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 return null; | 186 return null; |
182 } | 187 } |
183 | 188 |
184 Element getEnclosingMember() { | 189 Element getEnclosingMember() { |
185 for (Element e = this; e !== null; e = e.enclosingElement) { | 190 for (Element e = this; e !== null; e = e.enclosingElement) { |
186 if (e.isMember()) return e; | 191 if (e.isMember()) return e; |
187 } | 192 } |
188 return null; | 193 return null; |
189 } | 194 } |
190 | 195 |
191 toString() => '$kind(${name.slowToString()})'; | 196 Element getOutermostEnclosingMemberOrTopLevel() { |
197 for (Element e = this; e !== null; e = e.enclosingElement) { | |
198 if (e.isMember() || e.isTopLevel()) { | |
199 return e; | |
200 } | |
201 } | |
202 return null; | |
203 } | |
204 | |
205 toString() { | |
206 if (isMember()) { | |
ahe
2012/06/12 06:22:49
!isTopLevel()
ahe
2012/06/12 10:56:11
Done.
| |
207 String holderName = enclosingElement.name.slowToString(); | |
208 return '$kind($holderName#${name.slowToString()})'; | |
209 } else { | |
210 return '$kind(${name.slowToString()})'; | |
211 } | |
212 } | |
192 | 213 |
193 bool _isNative = false; | 214 bool _isNative = false; |
194 void setNative() { _isNative = true; } | 215 void setNative() { _isNative = true; } |
195 bool isNative() => _isNative; | 216 bool isNative() => _isNative; |
196 } | 217 } |
197 | 218 |
198 class ContainerElement extends Element { | 219 class ContainerElement extends Element { |
199 ContainerElement(name, kind, enclosingElement) : | 220 ContainerElement(name, kind, enclosingElement) : |
200 super(name, kind, enclosingElement); | 221 super(name, kind, enclosingElement); |
201 | 222 |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1035 final Node node; | 1056 final Node node; |
1036 Type bound; | 1057 Type bound; |
1037 Type type; | 1058 Type type; |
1038 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1059 TypeVariableElement(name, Element enclosing, this.node, this.type, |
1039 [this.bound]) | 1060 [this.bound]) |
1040 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1061 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
1041 Type computeType(compiler) => type; | 1062 Type computeType(compiler) => type; |
1042 Node parseNode(compiler) => node; | 1063 Node parseNode(compiler) => node; |
1043 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1064 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
1044 } | 1065 } |
OLD | NEW |