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

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

Issue 12210138: Add substitution for classes that use type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 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 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 3163 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 Element member = currentElement; 3174 Element member = currentElement;
3175 if (member.enclosingElement.isClosure()) { 3175 if (member.enclosingElement.isClosure()) {
3176 ClosureClassElement closureClass = member.enclosingElement; 3176 ClosureClassElement closureClass = member.enclosingElement;
3177 member = closureClass.methodElement; 3177 member = closureClass.methodElement;
3178 member = member.getOutermostEnclosingMemberOrTopLevel(); 3178 member = member.getOutermostEnclosingMemberOrTopLevel();
3179 } 3179 }
3180 if (member.isFactoryConstructor()) { 3180 if (member.isFactoryConstructor()) {
3181 // The type variable is stored in a parameter of the method. 3181 // The type variable is stored in a parameter of the method.
3182 inputs.add(localsHandler.readLocal(type.element)); 3182 inputs.add(localsHandler.readLocal(type.element));
3183 } else if (member.isInstanceMember() || 3183 } else if (member.isInstanceMember() ||
3184 member.isGenerativeConstructor()) { 3184 member.isGenerativeConstructor()) {
3185 // The type variable is stored in [this]. 3185 // The type variable is stored on the object. Generate code to extract
3186 // the type arguments from the object, substitute them as an instance
3187 // of the type we are testing against (if necessary), and extract the
3188 // type argument by the index of the variable in the list of type
3189 // variables for that class.
3186 int index = RuntimeTypeInformation.getTypeVariableIndex(type); 3190 int index = RuntimeTypeInformation.getTypeVariableIndex(type);
3187 pushInvokeHelper2(backend.getGetRuntimeTypeArgument(), 3191 HInstruction thisObject = localsHandler.readThis();
3188 localsHandler.readThis(), 3192 String substitutionNameString =
3193 backend.namer.substitutionName(member.getEnclosingClass());
3194 HInstruction substitutionName = graph.addConstantString(
3195 new LiteralDartString(substitutionNameString), null, constantSystem) ;
ngeoffray 2013/02/12 21:56:15 line too long
3196 HInstruction substitution = createForeign('#[#]', HType.UNKNOWN,
3197 <HInstruction>[thisObject, substitutionName]);
3198 add(substitution);
3199 pushInvokeHelper3(backend.getGetRuntimeTypeArgument(),
3200 thisObject,
3201 substitution,
3189 graph.addConstantInt(index, constantSystem), 3202 graph.addConstantInt(index, constantSystem),
3190 HType.UNKNOWN); 3203 HType.UNKNOWN);
3191 inputs.add(pop()); 3204 inputs.add(pop());
3192 } else { 3205 } else {
3193 // TODO(ngeoffray): Match the VM behavior and throw an 3206 // TODO(ngeoffray): Match the VM behavior and throw an
3194 // exception at runtime. 3207 // exception at runtime.
3195 compiler.cancel('Unimplemented unresolved type variable', 3208 compiler.cancel('Unimplemented unresolved type variable',
3196 node: currentNode); 3209 node: currentNode);
3197 } 3210 }
3198 } 3211 }
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after
5049 new HSubGraphBlockInformation(elseBranch.graph)); 5062 new HSubGraphBlockInformation(elseBranch.graph));
5050 5063
5051 HBasicBlock conditionStartBlock = conditionBranch.block; 5064 HBasicBlock conditionStartBlock = conditionBranch.block;
5052 conditionStartBlock.setBlockFlow(info, joinBlock); 5065 conditionStartBlock.setBlockFlow(info, joinBlock);
5053 SubGraph conditionGraph = conditionBranch.graph; 5066 SubGraph conditionGraph = conditionBranch.graph;
5054 HIf branch = conditionGraph.end.last; 5067 HIf branch = conditionGraph.end.last;
5055 assert(branch is HIf); 5068 assert(branch is HIf);
5056 branch.blockInformation = conditionStartBlock.blockFlow; 5069 branch.blockInformation = conditionStartBlock.blockFlow;
5057 } 5070 }
5058 } 5071 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698