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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 17262003: Fix type variables in closures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert some changes and support as. Created 7 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 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 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 3228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 * Helper to create an instruction that gets the value of a type variable. 3239 * Helper to create an instruction that gets the value of a type variable.
3240 */ 3240 */
3241 HInstruction addTypeVariableReference(TypeVariableType type) { 3241 HInstruction addTypeVariableReference(TypeVariableType type) {
3242 Element member = currentElement; 3242 Element member = currentElement;
3243 bool isClosure = member.enclosingElement.isClosure(); 3243 bool isClosure = member.enclosingElement.isClosure();
3244 if (isClosure) { 3244 if (isClosure) {
3245 ClosureClassElement closureClass = member.enclosingElement; 3245 ClosureClassElement closureClass = member.enclosingElement;
3246 member = closureClass.methodElement; 3246 member = closureClass.methodElement;
3247 member = member.getOutermostEnclosingMemberOrTopLevel(); 3247 member = member.getOutermostEnclosingMemberOrTopLevel();
3248 } 3248 }
3249 if (isClosure && member.isFactoryConstructor()) { 3249 bool isConstructor =
ngeoffray 2013/06/19 20:03:57 Didn't you say you changed this to isInConstructor
karlklose 2013/06/20 10:18:00 Perhaps I did not stage or save the change. Done.
3250 // The type variable is used from a closure in a factory constructor. The 3250 member.isConstructor() || member.isGenerativeConstructorBody();
3251 // value of the type argument is stored as a local on the closure itself. 3251 if (isClosure) {
3252 return localsHandler.readLocal(type.element); 3252 if (member.isFactoryConstructor()) {
3253 } else if (member.isConstructor() || 3253 // The type variable is used from a closure in a factory constructor.
3254 member.isGenerativeConstructorBody() || 3254 // The value of the type argument is stored as a local on the closure
3255 member.isField()) { 3255 // itself.
3256 return localsHandler.readLocal(type.element);
3257 } else if (!member.isField()) {
3258 // The type variable is stored on the "enclosing object" and needs to be
3259 // accessed using the this-reference in the closure.
3260 return readTypeVariable(member.getEnclosingClass(), type.element);
3261 } else {
3262 // The type variable is stored in a parameter of the method.
3263 return localsHandler.readLocal(type.element);
3264 }
3265 } else if (isConstructor || member.isField()) {
3256 // The type variable is stored in a parameter of the method. 3266 // The type variable is stored in a parameter of the method.
3257 return localsHandler.readLocal(type.element); 3267 return localsHandler.readLocal(type.element);
3258 } else if (member.isInstanceMember()) { 3268 } else if (member.isInstanceMember()) {
3259 // The type variable is stored on the object. 3269 // The type variable is stored on the object.
3260 return readTypeVariable(member.getEnclosingClass(), 3270 return readTypeVariable(member.getEnclosingClass(),
3261 type.element); 3271 type.element);
3262 } else { 3272 } else {
3263 // TODO(ngeoffray): Match the VM behavior and throw an 3273 // TODO(ngeoffray): Match the VM behavior and throw an
3264 // exception at runtime. 3274 // exception at runtime.
3265 compiler.cancel('Unimplemented unresolved type variable', 3275 compiler.cancel('Unimplemented unresolved type variable',
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 new HSubGraphBlockInformation(elseBranch.graph)); 5398 new HSubGraphBlockInformation(elseBranch.graph));
5389 5399
5390 HBasicBlock conditionStartBlock = conditionBranch.block; 5400 HBasicBlock conditionStartBlock = conditionBranch.block;
5391 conditionStartBlock.setBlockFlow(info, joinBlock); 5401 conditionStartBlock.setBlockFlow(info, joinBlock);
5392 SubGraph conditionGraph = conditionBranch.graph; 5402 SubGraph conditionGraph = conditionBranch.graph;
5393 HIf branch = conditionGraph.end.last; 5403 HIf branch = conditionGraph.end.last;
5394 assert(branch is HIf); 5404 assert(branch is HIf);
5395 branch.blockInformation = conditionStartBlock.blockFlow; 5405 branch.blockInformation = conditionStartBlock.blockFlow;
5396 } 5406 }
5397 } 5407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698