| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 bool _isNative = false; | 277 bool _isNative = false; |
| 278 void setNative() { _isNative = true; } | 278 void setNative() { _isNative = true; } |
| 279 bool isNative() => _isNative; | 279 bool isNative() => _isNative; |
| 280 | 280 |
| 281 FunctionElement asFunctionElement() => null; | 281 FunctionElement asFunctionElement() => null; |
| 282 | 282 |
| 283 Element cloneTo(Element enclosing, DiagnosticListener listener) { | 283 Element cloneTo(Element enclosing, DiagnosticListener listener) { |
| 284 listener.cancel("Unimplemented cloneTo", element: this); | 284 listener.cancel("Unimplemented cloneTo", element: this); |
| 285 } | 285 } |
| 286 | 286 |
| 287 Link<Type> get allSupertypesAndSelf() { | |
| 288 return allSupertypes.prepend(new InterfaceType(this)); | |
| 289 } | |
| 290 } | 287 } |
| 291 | 288 |
| 292 class ContainerElement extends Element { | 289 class ContainerElement extends Element { |
| 293 Link<Element> localMembers = const EmptyLink<Element>(); | 290 Link<Element> localMembers = const EmptyLink<Element>(); |
| 294 | 291 |
| 295 ContainerElement(name, kind, enclosingElement) | 292 ContainerElement(name, kind, enclosingElement) |
| 296 : super(name, kind, enclosingElement); | 293 : super(name, kind, enclosingElement); |
| 297 | 294 |
| 298 void addMember(Element element, DiagnosticListener listener) { | 295 void addMember(Element element, DiagnosticListener listener) { |
| 299 localMembers = localMembers.prepend(element); | 296 localMembers = localMembers.prepend(element); |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 } | 1100 } |
| 1104 if (isInterface()) { | 1101 if (isInterface()) { |
| 1105 return lookupSuperInterfaceMember(memberName, getLibrary()); | 1102 return lookupSuperInterfaceMember(memberName, getLibrary()); |
| 1106 } | 1103 } |
| 1107 return null; | 1104 return null; |
| 1108 } | 1105 } |
| 1109 | 1106 |
| 1110 Element lookupSuperInterfaceMember(SourceString memberName, | 1107 Element lookupSuperInterfaceMember(SourceString memberName, |
| 1111 LibraryElement fromLibrary) { | 1108 LibraryElement fromLibrary) { |
| 1112 bool isPrivate = memberName.isPrivate(); | 1109 bool isPrivate = memberName.isPrivate(); |
| 1113 for (Type t in interfaces) { | 1110 for (InterfaceType t in interfaces) { |
| 1114 Element e = t.element.lookupLocalMember(memberName); | 1111 ClassElement cls = t.element; |
| 1112 Element e = cls.lookupLocalMember(memberName); |
| 1115 if (e === null) continue; | 1113 if (e === null) continue; |
| 1116 // Private members from a different library are not visible. | 1114 // Private members from a different library are not visible. |
| 1117 if (isPrivate && fromLibrary !== e.getLibrary()) continue; | 1115 if (isPrivate && fromLibrary !== e.getLibrary()) continue; |
| 1118 // Static members are not inherited. | 1116 // Static members are not inherited. |
| 1119 if (e.modifiers.isStatic()) continue; | 1117 if (e.modifiers.isStatic()) continue; |
| 1120 return e; | 1118 return e; |
| 1121 } | 1119 } |
| 1122 return null; | 1120 return null; |
| 1123 } | 1121 } |
| 1124 | 1122 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 bool isInterface() => false; | 1300 bool isInterface() => false; |
| 1303 bool isNative() => nativeName != null; | 1301 bool isNative() => nativeName != null; |
| 1304 int hashCode() => id; | 1302 int hashCode() => id; |
| 1305 | 1303 |
| 1306 Scope buildScope() => | 1304 Scope buildScope() => |
| 1307 new ClassScope(enclosingElement.buildScope(), this); | 1305 new ClassScope(enclosingElement.buildScope(), this); |
| 1308 | 1306 |
| 1309 ClassElement cloneTo(Element enclosing, DiagnosticListener listener) { | 1307 ClassElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 1310 listener.internalErrorOnElement(this, 'unsupported operation'); | 1308 listener.internalErrorOnElement(this, 'unsupported operation'); |
| 1311 } | 1309 } |
| 1310 |
| 1311 Link<Type> get allSupertypesAndSelf() { |
| 1312 return allSupertypes.prepend(new InterfaceType(this)); |
| 1313 } |
| 1312 } | 1314 } |
| 1313 | 1315 |
| 1314 class Elements { | 1316 class Elements { |
| 1315 static bool isLocal(Element element) { | 1317 static bool isLocal(Element element) { |
| 1316 return ((element !== null) | 1318 return ((element !== null) |
| 1317 && !element.isInstanceMember() | 1319 && !element.isInstanceMember() |
| 1318 && !isStaticOrTopLevelField(element) | 1320 && !isStaticOrTopLevelField(element) |
| 1319 && !isStaticOrTopLevelFunction(element) | 1321 && !isStaticOrTopLevelFunction(element) |
| 1320 && (element.kind === ElementKind.VARIABLE || | 1322 && (element.kind === ElementKind.VARIABLE || |
| 1321 element.kind === ElementKind.PARAMETER || | 1323 element.kind === ElementKind.PARAMETER || |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 Node parseNode(compiler) => cachedNode; | 1508 Node parseNode(compiler) => cachedNode; |
| 1507 | 1509 |
| 1508 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1510 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1509 | 1511 |
| 1510 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | 1512 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 1511 TypeVariableElement result = | 1513 TypeVariableElement result = |
| 1512 new TypeVariableElement(name, enclosing, cachedNode, type, bound); | 1514 new TypeVariableElement(name, enclosing, cachedNode, type, bound); |
| 1513 return result; | 1515 return result; |
| 1514 } | 1516 } |
| 1515 } | 1517 } |
| OLD | NEW |