| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 LibraryElement getLibrary() { | 166 LibraryElement getLibrary() { |
| 167 Element element = this; | 167 Element element = this; |
| 168 while (element.kind !== ElementKind.LIBRARY) { | 168 while (element.kind !== ElementKind.LIBRARY) { |
| 169 element = element.enclosingElement; | 169 element = element.enclosingElement; |
| 170 } | 170 } |
| 171 return element; | 171 return element; |
| 172 } | 172 } |
| 173 | 173 |
| 174 ClassElement getEnclosingClass() { |
| 175 for (Element e = this; e !== null; e = e.enclosingElement) { |
| 176 if (e.kind === ElementKind.CLASS) return e; |
| 177 } |
| 178 return null; |
| 179 } |
| 180 |
| 174 toString() => '$kind(${name.slowToString()})'; | 181 toString() => '$kind(${name.slowToString()})'; |
| 175 | 182 |
| 176 bool _isNative = false; | 183 bool _isNative = false; |
| 177 void setNative() => _isNative = true; | 184 void setNative() => _isNative = true; |
| 178 bool isNative() => _isNative; | 185 bool isNative() => _isNative; |
| 179 } | 186 } |
| 180 | 187 |
| 181 class ContainerElement extends Element { | 188 class ContainerElement extends Element { |
| 182 ContainerElement(name, kind, enclosingElement) : | 189 ContainerElement(name, kind, enclosingElement) : |
| 183 super(name, kind, enclosingElement); | 190 super(name, kind, enclosingElement); |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 final Node node; | 939 final Node node; |
| 933 Type bound; | 940 Type bound; |
| 934 Type type; | 941 Type type; |
| 935 TypeVariableElement(name, Element enclosing, this.node, this.type, | 942 TypeVariableElement(name, Element enclosing, this.node, this.type, |
| 936 [this.bound]) | 943 [this.bound]) |
| 937 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 944 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 938 Type computeType(compiler) => type; | 945 Type computeType(compiler) => type; |
| 939 Node parseNode(compiler) => node; | 946 Node parseNode(compiler) => node; |
| 940 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 947 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 941 } | 948 } |
| OLD | NEW |