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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index 2ba5dddebc7ac0608480d7eabc9bd9ab74beb633..8b449139feb2d0afc4415c85bcbea9dc7cb6209a 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -3181,11 +3181,24 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
// The type variable is stored in a parameter of the method.
inputs.add(localsHandler.readLocal(type.element));
} else if (member.isInstanceMember() ||
- member.isGenerativeConstructor()) {
- // The type variable is stored in [this].
+ member.isGenerativeConstructor()) {
+ // The type variable is stored on the object. Generate code to extract
+ // the type arguments from the object, substitute them as an instance
+ // of the type we are testing against (if necessary), and extract the
+ // type argument by the index of the variable in the list of type
+ // variables for that class.
int index = RuntimeTypeInformation.getTypeVariableIndex(type);
- pushInvokeHelper2(backend.getGetRuntimeTypeArgument(),
- localsHandler.readThis(),
+ HInstruction thisObject = localsHandler.readThis();
+ String substitutionNameString =
+ backend.namer.substitutionName(member.getEnclosingClass());
+ HInstruction substitutionName = graph.addConstantString(
+ new LiteralDartString(substitutionNameString), null, constantSystem);
ngeoffray 2013/02/12 21:56:15 line too long
+ HInstruction substitution = createForeign('#[#]', HType.UNKNOWN,
+ <HInstruction>[thisObject, substitutionName]);
+ add(substitution);
+ pushInvokeHelper3(backend.getGetRuntimeTypeArgument(),
+ thisObject,
+ substitution,
graph.addConstantInt(index, constantSystem),
HType.UNKNOWN);
inputs.add(pop());

Powered by Google App Engine
This is Rietveld 408576698