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

Side by Side Diff: compiler/java/com/google/dart/compiler/resolver/Resolver.java

Issue 10910176: Issue 5055. Visit field getter/setter only once. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 package com.google.dart.compiler.resolver; 5 package com.google.dart.compiler.resolver;
6 6
7 import com.google.common.annotations.VisibleForTesting; 7 import com.google.common.annotations.VisibleForTesting;
8 import com.google.common.collect.Lists; 8 import com.google.common.collect.Lists;
9 import com.google.common.collect.Sets; 9 import com.google.common.collect.Sets;
10 import com.google.dart.compiler.DartCompilationPhase; 10 import com.google.dart.compiler.DartCompilationPhase;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 private EnclosingElement currentHolder; 185 private EnclosingElement currentHolder;
186 private EnclosingElement enclosingElement; 186 private EnclosingElement enclosingElement;
187 private MethodElement currentMethod; 187 private MethodElement currentMethod;
188 private boolean inInstanceVariableInitializer; 188 private boolean inInstanceVariableInitializer;
189 private boolean inInitializer; 189 private boolean inInitializer;
190 private MethodElement innermostFunction; 190 private MethodElement innermostFunction;
191 private ResolutionContext context; 191 private ResolutionContext context;
192 private Set<LabelElement> referencedLabels = Sets.newHashSet(); 192 private Set<LabelElement> referencedLabels = Sets.newHashSet();
193 private Set<LabelElement> labelsInScopes = Sets.newHashSet(); 193 private Set<LabelElement> labelsInScopes = Sets.newHashSet();
194 private Set<FieldElement> finalsNeedingInitializing = Sets.newHashSet(); 194 private Set<FieldElement> finalsNeedingInitializing = Sets.newHashSet();
195 private Set<FieldElement> resolvedFields = Sets.newHashSet();
195 196
196 @VisibleForTesting 197 @VisibleForTesting
197 public ResolveElementsVisitor(ResolutionContext context, 198 public ResolveElementsVisitor(ResolutionContext context,
198 EnclosingElement currentHolder, 199 EnclosingElement currentHolder,
199 MethodElement currentMethod) { 200 MethodElement currentMethod) {
200 super(typeProvider); 201 super(typeProvider);
201 this.context = context; 202 this.context = context;
202 this.currentMethod = currentMethod; 203 this.currentMethod = currentMethod;
203 this.innermostFunction = currentMethod; 204 this.innermostFunction = currentMethod;
204 this.currentHolder = currentHolder; 205 this.currentHolder = currentHolder;
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } else if (isTopLevel) { 729 } else if (isTopLevel) {
729 onError(node, ResolverErrorCode.TOPLEVEL_FINAL_REQUIRES_VALUE); 730 onError(node, ResolverErrorCode.TOPLEVEL_FINAL_REQUIRES_VALUE);
730 } else { 731 } else {
731 // If a final instance field wasn't initialized at declaration, we mus t check 732 // If a final instance field wasn't initialized at declaration, we mus t check
732 // at construction time. 733 // at construction time.
733 this.finalsNeedingInitializing.add(node.getElement()); 734 this.finalsNeedingInitializing.add(node.getElement());
734 } 735 }
735 } 736 }
736 737
737 // If field is an accessor, both getter and setter need to be visited (if present). 738 // If field is an accessor, both getter and setter need to be visited (if present).
739 // We check for duplicates because top-level fields are visited twice - fo r each accessor.
738 FieldNodeElement field = node.getElement(); 740 FieldNodeElement field = node.getElement();
739 if (field.getGetter() != null) { 741 if (!resolvedFields.contains(field)) {
740 resolve(field.getGetter().getNode()); 742 resolvedFields.add(field);
741 } 743 if (field.getGetter() != null) {
742 if (field.getSetter() != null) { 744 resolve(field.getGetter().getNode());
743 resolve(field.getSetter().getNode()); 745 }
746 if (field.getSetter() != null) {
747 resolve(field.getSetter().getNode());
748 }
744 } 749 }
745 return null; 750 return null;
746 } 751 }
747 752
748 @Override 753 @Override
749 public Element visitFieldDefinition(DartFieldDefinition node) { 754 public Element visitFieldDefinition(DartFieldDefinition node) {
750 node.getMetadata().accept(this); 755 node.getMetadata().accept(this);
751 visit(node.getFields()); 756 visit(node.getFields());
752 return null; 757 return null;
753 } 758 }
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 ClassElement currentClass = (ClassElement) constructor.getEnclosingEle ment(); 2309 ClassElement currentClass = (ClassElement) constructor.getEnclosingEle ment();
2305 if (nextClass == currentClass) { 2310 if (nextClass == currentClass) {
2306 return (ConstructorNodeElement) nextConstructorElement; 2311 return (ConstructorNodeElement) nextConstructorElement;
2307 } 2312 }
2308 } 2313 }
2309 } 2314 }
2310 } 2315 }
2311 return null; 2316 return null;
2312 } 2317 }
2313 } 2318 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698