Chromium Code Reviews| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 | 268 |
| 269 bool _isNative = false; | 269 bool _isNative = false; |
| 270 void setNative() { _isNative = true; } | 270 void setNative() { _isNative = true; } |
| 271 bool isNative() => _isNative; | 271 bool isNative() => _isNative; |
| 272 | 272 |
| 273 FunctionElement asFunctionElement() => null; | 273 FunctionElement asFunctionElement() => null; |
| 274 | 274 |
| 275 Element cloneTo(Element enclosing, DiagnosticListener listener) { | 275 Element cloneTo(Element enclosing, DiagnosticListener listener) { |
| 276 listener.cancel("Unimplemented cloneTo", element: this); | 276 listener.cancel("Unimplemented cloneTo", element: this); |
| 277 } | 277 } |
| 278 | |
| 279 Link<Type> get allSupertypesAndSelf() { | |
| 280 return allSupertypes.prepend(new InterfaceType(this)); | |
| 281 } | |
| 278 } | 282 } |
| 279 | 283 |
| 280 class ContainerElement extends Element { | 284 class ContainerElement extends Element { |
| 281 ContainerElement(name, kind, enclosingElement) : | 285 ContainerElement(name, kind, enclosingElement) : |
| 282 super(name, kind, enclosingElement); | 286 super(name, kind, enclosingElement); |
| 283 | 287 |
| 284 abstract void addMember(Element element, DiagnosticListener listener); | 288 abstract void addMember(Element element, DiagnosticListener listener); |
| 285 | 289 |
| 286 void addGetterOrSetter(Element element, | 290 void addGetterOrSetter(Element element, |
| 287 Element existing, | 291 Element existing, |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1068 bool isPrivate = memberName.isPrivate(); | 1072 bool isPrivate = memberName.isPrivate(); |
| 1069 for (ClassElement s = superclass; s != null; s = s.superclass) { | 1073 for (ClassElement s = superclass; s != null; s = s.superclass) { |
| 1070 // Private members from a different library are not visible. | 1074 // Private members from a different library are not visible. |
| 1071 if (isPrivate && getLibrary() !== s.getLibrary()) continue; | 1075 if (isPrivate && getLibrary() !== s.getLibrary()) continue; |
| 1072 Element e = s.lookupLocalMember(memberName); | 1076 Element e = s.lookupLocalMember(memberName); |
| 1073 if (e === null) continue; | 1077 if (e === null) continue; |
| 1074 // Static members are not inherited. | 1078 // Static members are not inherited. |
| 1075 if (e.modifiers.isStatic()) continue; | 1079 if (e.modifiers.isStatic()) continue; |
| 1076 return e; | 1080 return e; |
| 1077 } | 1081 } |
| 1082 if (isInterface()) { | |
| 1083 return lookupSuperInterfaceMember(memberName, getLibrary()); | |
| 1084 } | |
| 1078 return null; | 1085 return null; |
| 1079 } | 1086 } |
| 1080 | 1087 |
| 1088 Element lookupSuperInterfaceMember(SourceString memberName, | |
| 1089 LibraryElement fromLibrary) { | |
| 1090 for (Type t in interfaces) { | |
| 1091 Element e = t.element.lookupLocalMember(memberName); | |
| 1092 if (e === null) continue; | |
| 1093 // Private members from a different library are not visible. | |
| 1094 if (memberName.isPrivate() && fromLibrary !== e.getLibrary()) continue; | |
|
karlklose
2012/08/14 11:06:51
You could store the result of memberName.isPrivate
ahe
2012/08/14 18:20:34
Done.
| |
| 1095 // Static members are not inherited. | |
| 1096 if (e.modifiers.isStatic()) continue; | |
| 1097 return e; | |
| 1098 } | |
| 1099 } | |
|
karlklose
2012/08/14 11:06:51
I would prefer an explicit 'return null' here.
ahe
2012/08/14 18:20:34
Done.
| |
| 1100 | |
| 1081 /** | 1101 /** |
| 1082 * Find the first member in the class chain with the given | 1102 * Find the first member in the class chain with the given |
| 1083 * [memberName]. This method is NOT to be used for resolving | 1103 * [memberName]. This method is NOT to be used for resolving |
| 1084 * unqualified sends because it does not implement the scoping | 1104 * unqualified sends because it does not implement the scoping |
| 1085 * rules, where library scope comes before superclass scope. | 1105 * rules, where library scope comes before superclass scope. |
| 1086 */ | 1106 */ |
| 1087 Element lookupMember(SourceString memberName) { | 1107 Element lookupMember(SourceString memberName) { |
| 1088 Element localMember = localMembers[memberName]; | 1108 Element localMember = localMembers[memberName]; |
| 1089 return localMember === null ? lookupSuperMember(memberName) : localMember; | 1109 return localMember === null ? lookupSuperMember(memberName) : localMember; |
| 1090 } | 1110 } |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1419 Node parseNode(compiler) => cachedNode; | 1439 Node parseNode(compiler) => cachedNode; |
| 1420 | 1440 |
| 1421 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1441 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1422 | 1442 |
| 1423 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | 1443 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 1424 TypeVariableElement result = | 1444 TypeVariableElement result = |
| 1425 new TypeVariableElement(name, enclosing, node, type, bound); | 1445 new TypeVariableElement(name, enclosing, node, type, bound); |
| 1426 return result; | 1446 return result; |
| 1427 } | 1447 } |
| 1428 } | 1448 } |
| OLD | NEW |