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

Unified Diff: lib/compiler/implementation/ssa/builder.dart

Issue 10834243: Reduce usage of .enclosingElement to get enclosing class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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: lib/compiler/implementation/ssa/builder.dart
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
index 7aba3c44accefc88a226b09e8344a2dba8bc4830..ca7c6f2b3dc0816f83dae501ac6956a952cd9cfe 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -173,9 +173,8 @@ class SsaBuilderTask extends CompilerTask {
graph.calledInLoop = inLoop;
if (compiler.tracer.enabled) {
String name;
- if (element.enclosingElement !== null &&
- element.enclosingElement.kind == ElementKind.CLASS) {
- String className = element.enclosingElement.name.slowToString();
+ if (element.isMember()) {
+ String className = element.getEnclosingClass().name.slowToString();
String memberName = element.name.slowToString();
name = "$className.$memberName";
if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) {
@@ -193,7 +192,7 @@ class SsaBuilderTask extends CompilerTask {
HGraph compileConstructor(SsaBuilder builder, WorkItem work) {
// The body of the constructor will be generated in a separate function.
- final ClassElement classElement = work.element.enclosingElement;
+ final ClassElement classElement = work.element.getEnclosingClass();
return builder.buildFactory(classElement, work.element);
}
}
@@ -339,7 +338,7 @@ class LocalsHandler {
// Once closures have been mapped to classes their instance members might
// not have any thisElement if the closure was created inside a static
// context.
- ClassElement cls = function.enclosingElement;
+ ClassElement cls = function.getEnclosingClass();
Type type = cls.computeType(builder.compiler);
HInstruction thisInstruction = new HThis(new HBoundedType.nonNull(type));
builder.add(thisInstruction);
@@ -368,7 +367,7 @@ class LocalsHandler {
if (isAccessedDirectly(element)) return false;
Element redirectTarget = redirectionMapping[element];
if (redirectTarget == null) return false;
- if (redirectTarget.enclosingElement.kind == ElementKind.CLASS) {
+ if (redirectTarget.isMember()) {
assert(redirectTarget is ClosureFieldElement);
return true;
}
@@ -432,7 +431,7 @@ class LocalsHandler {
if (cachedTypeOfThis === null) {
assert(closureData.isClosure());
Element element = closureData.thisElement;
- ClassElement cls = element.enclosingElement.enclosingElement;
+ ClassElement cls = element.enclosingElement.getEnclosingClass();
Type type = cls.computeType(builder.compiler);
cachedTypeOfThis = new HBoundedType.nonNull(type);
}
@@ -861,7 +860,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
NodeList statements = node.body.asBlock().statements;
if (statements.isEmpty()) return null;
}
- ClassElement classElement = constructor.enclosingElement;
+ ClassElement classElement = constructor.getEnclosingClass();
ConstructorBodyElement bodyElement;
for (Link<Element> backendMembers = classElement.backendMembers;
!backendMembers.isEmpty();
@@ -969,7 +968,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
if (!foundSuperOrRedirect) {
// No super initializer found. Try to find the default constructor if
// the class is not Object.
- ClassElement enclosingClass = constructor.enclosingElement;
+ ClassElement enclosingClass = constructor.getEnclosingClass();
ClassElement superClass = enclosingClass.superclass;
if (enclosingClass != compiler.objectClass) {
assert(superClass !== null);
@@ -2263,14 +2262,14 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
visitNewSend(Send node) {
computeType(element) {
Element originalElement = elements[node];
- if (originalElement.enclosingElement === compiler.listClass) {
+ if (originalElement.getEnclosingClass() === compiler.listClass) {
if (node.arguments.isEmpty()) {
return HType.EXTENDABLE_ARRAY;
} else {
return HType.MUTABLE_ARRAY;
}
} else if (element.isGenerativeConstructor()) {
- ClassElement cls = element.enclosingElement;
+ ClassElement cls = element.getEnclosingClass();
return new HBoundedType.exact(cls.type);
} else {
return HType.UNKNOWN;

Powered by Google App Engine
This is Rietveld 408576698