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..eabc1d1a8c61e0dd1631522a4459587d5d0f773a 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,45 @@ class ClassEmitter extends CodeEmitterHelper { |
| builder.addProperty('+$reflectionName', reflectable); |
| } |
| } |
| + |
| + void emitTypeVariableReaders(ClassElement cls, ClassBuilder builder) { |
| + List typeVariables = []; |
| + ClassElement superclass = cls; |
|
ngeoffray
2013/12/09 09:48:52
superclass -> currentClass ? I find it confusing t
ahe
2013/12/09 15:30:06
Done.
|
| + while (superclass != null) { |
| + for (TypeVariableType parameter in superclass.typeVariables) { |
| + 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']( |
| + ['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))])); |
| + } |
| } |