Chromium Code Reviews| Index: dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart |
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart b/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart |
| index 97caf52b04124bd7f54d3afb0f7c03ba51af2b8e..5067c2870c58cb727a6f292edd32c7c3b180c34c 100644 |
| --- a/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart |
| +++ b/dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart |
| @@ -47,6 +47,8 @@ class ClassEmitter extends CodeEmitterHelper { |
| additionalProperties.forEach(builder.addProperty); |
| } |
| + emitTypeVariableReaders(classElement, builder); |
| + |
| emitClassBuilderWithReflectionData( |
| className, classElement, builder, properties); |
| } |
| @@ -563,4 +565,46 @@ class ClassEmitter extends CodeEmitterHelper { |
| builder.addProperty('+$reflectionName', reflectable); |
| } |
| } |
| + |
| + void emitTypeVariableReaders(ClassElement cls, ClassBuilder builder) { |
| + List typeVariables = []; |
| + ClassElement superclass = cls; |
| + while (superclass != null) { |
| + GenericType type = superclass.thisType; |
| + for (TypeVariableType parameter in type.typeArguments) { |
|
Johnni Winther
2013/12/03 10:33:16
Replace `type.typeArguments` with `superclass.type
ahe
2013/12/05 14:24:23
Done.
|
| + if (task.readTypeVariables.contains(parameter.element)) { |
| + emitTypeVariableReader(cls, builder, parameter.element); |
| + } |
| + } |
| + superclass = superclass.superclass; |
| + } |
| + } |
| + |
| + void emitTypeVariableReader(ClassElement cls, |
| + ClassBuilder builder, |
| + TypeVariableElement element) { |
| + String name = namer.readTypeVariableName(element); |
| + jsAst.Expression index = |
| + js.toExpression(RuntimeTypes.getTypeVariableIndex(element)); |
| + jsAst.Expression computeTypeVariable; |
| + |
| + Substitution substitution = |
| + backend.rti.computeSubstitution( |
| + cls, element.enclosingElement, alwaysGenerateFunction: true); |
| + if (substitution != null) { |
| + jsAst.Expression typeArguments = |
| + substitution.getCode(backend.rti, true)['apply']( |
|
Johnni Winther
2013/12/03 10:33:16
Seems the last argument to getCode should be named
ahe
2013/12/05 14:24:23
I like to avoid adding named arguments as they add
|
| + ['null', r'this.$builtinTypeInfo']); |
| + computeTypeVariable = typeArguments[index]; |
| + } else { |
| + // TODO(ahe): These can be generated dynamically. |
| + computeTypeVariable = |
| + js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', index); |
| + } |
| + jsAst.Expression convertRtiToRuntimeType = |
| + namer.elementAccess(compiler.findHelper('convertRtiToRuntimeType')); |
| + builder.addProperty( |
| + name, js.fun( |
| + [], [js.return_(convertRtiToRuntimeType(computeTypeVariable))])); |
| + } |
| } |