Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: dart/lib/compiler/implementation/elements/elements.dart

Issue 10542073: RFC: Resolution based tree-shaking. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Minor tweaks for the unit tests Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/lib/compiler/implementation/elements/elements.dart
diff --git a/dart/lib/compiler/implementation/elements/elements.dart b/dart/lib/compiler/implementation/elements/elements.dart
index 7651855f6ffeedc1a4aaa394eed1ce8f2451412f..a598263618ccca1b64bb36faab2f996170745d69 100644
--- a/dart/lib/compiler/implementation/elements/elements.dart
+++ b/dart/lib/compiler/implementation/elements/elements.dart
@@ -123,6 +123,7 @@ class Element implements Hashable {
kind === ElementKind.LIBRARY;
}
bool isClass() => kind === ElementKind.CLASS;
+ bool isPrefix() => kind === ElementKind.PREFIX;
bool isVariable() => kind === ElementKind.VARIABLE;
bool isParameter() => kind === ElementKind.PARAMETER;
bool isStatement() => kind === ElementKind.STATEMENT;
@@ -131,9 +132,13 @@ class Element implements Hashable {
bool isField() => kind === ElementKind.FIELD;
bool isGetter() => kind === ElementKind.GETTER;
bool isSetter() => kind === ElementKind.SETTER;
+ bool isAccessor() => isGetter() || isSetter();
+ bool isForeign() => kind === ElementKind.FOREIGN;
bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0;
bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0;
+ bool isTopLevel() => enclosingElement.isCompilationUnit();
+
bool isAssignable() {
if (modifiers != null && modifiers.isFinal()) return false;
if (isFunction() || isGenerativeConstructor()) return false;
@@ -188,7 +193,23 @@ class Element implements Hashable {
return null;
}
- toString() => '$kind(${name.slowToString()})';
+ Element getOutermostEnclosingMemberOrTopLevel() {
+ for (Element e = this; e !== null; e = e.enclosingElement) {
+ if (e.isMember() || e.isTopLevel()) {
+ return e;
+ }
+ }
+ return null;
+ }
+
+ toString() {
+ if (!isTopLevel()) {
+ String holderName = enclosingElement.name.slowToString();
+ return '$kind($holderName#${name.slowToString()})';
+ } else {
+ return '$kind(${name.slowToString()})';
+ }
+ }
bool _isNative = false;
void setNative() { _isNative = true; }
@@ -792,8 +813,11 @@ class ClassElement extends ContainerElement {
void forEachMember([void f(ClassElement enclosingClass, Element member),
includeBackendMembers = false,
includeSuperMembers = false]) {
+ Set<ClassElement> seen = new Set<ClassElement>();
ClassElement classElement = this;
do {
+ if (seen.contains(classElement)) return;
+ seen.add(classElement);
for (Element element in classElement.members) {
f(classElement, element);
}

Powered by Google App Engine
This is Rietveld 408576698