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

Side by Side Diff: frog/leg/ssa/closure.dart

Issue 9327001: Implement super initializers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase and update test expectations. Created 8 years, 10 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
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 class ClosureFieldElement extends Element { 5 class ClosureFieldElement extends Element {
6 ClosureFieldElement(SourceString name, ClassElement enclosing) 6 ClosureFieldElement(SourceString name, ClassElement enclosing)
7 : super(name, ElementKind.FIELD, enclosing); 7 : super(name, ElementKind.FIELD, enclosing);
8 8
9 bool isInstanceMember() => true; 9 bool isInstanceMember() => true;
10 bool isAssignable() => false; 10 bool isAssignable() => false;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 new ClosureFieldElement(boxElement.name, closureElement); 136 new ClosureFieldElement(boxElement.name, closureElement);
137 closureElement.backendMembers = 137 closureElement.backendMembers =
138 closureElement.backendMembers.prepend(fieldElement); 138 closureElement.backendMembers.prepend(fieldElement);
139 data.capturedFieldMapping[fieldElement] = boxElement; 139 data.capturedFieldMapping[fieldElement] = boxElement;
140 freeVariableMapping[boxElement] = fieldElement; 140 freeVariableMapping[boxElement] = fieldElement;
141 } 141 }
142 } 142 }
143 } 143 }
144 144
145 void useLocal(Element element) { 145 void useLocal(Element element) {
146 if (element.enclosingElement != currentFunctionElement) { 146 // TODO(floitsch): replace this with a general solution.
147 Element functionElement = currentFunctionElement;
148 if (functionElement.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY) {
149 ConstructorBodyElement body = functionElement;
150 functionElement = body.constructor;
151 }
152 if (element.enclosingElement != functionElement) {
147 assert(closureData.freeVariableMapping[element] == null || 153 assert(closureData.freeVariableMapping[element] == null ||
148 closureData.freeVariableMapping[element] == element); 154 closureData.freeVariableMapping[element] == element);
149 closureData.freeVariableMapping[element] = element; 155 closureData.freeVariableMapping[element] = element;
150 } 156 }
151 } 157 }
152 158
153 void declareLocal(Element element) { 159 void declareLocal(Element element) {
154 scopeVariables.add(element); 160 scopeVariables.add(element);
155 } 161 }
156 162
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 307 }
302 308
303 // If we just visited a closure we declare it. This is not always correct 309 // If we just visited a closure we declare it. This is not always correct
304 // since some closures are used as expressions and don't introduce any 310 // since some closures are used as expressions and don't introduce any
305 // name. But in this case the added local is simply not used. 311 // name. But in this case the added local is simply not used.
306 if (savedInsideClosure) { 312 if (savedInsideClosure) {
307 declareLocal(elements[node]); 313 declareLocal(elements[node]);
308 } 314 }
309 } 315 }
310 } 316 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698