Chromium Code Reviews| Index: pkg/compiler/lib/src/js_emitter/class_stub_generator.dart |
| diff --git a/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart |
| index 01e745555f47d9618ac835f20cdda4cb918e010b..50f3fe3b97b66d548e74591d1227fa3ddd6b655f 100644 |
| --- a/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart |
| +++ b/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart |
| @@ -186,6 +186,51 @@ class ClassStubGenerator { |
| } |
| return new StubMethod(name, function); |
| } |
| + |
| + List<StubMethod> generateTypeVariableReaderStubs(ClassElement classElement) { |
|
floitsch
2015/02/10 13:19:36
An alternative location would be in the type_test_
zarah
2015/02/10 13:34:39
Done.
|
| + List<StubMethod> stubs = <StubMethod>[]; |
| + List typeVariables = []; |
| + ClassElement superclass = classElement; |
| + while (superclass != null) { |
| + for (TypeVariableType parameter in superclass.typeVariables) { |
| + if (backend.emitter.readTypeVariables.contains(parameter.element)) { |
| + stubs.add( |
|
zarah
2015/02/10 12:50:30
This method is copied from class_emitter. This lin
|
| + _generateTypeVariableReader(classElement, parameter.element)); |
| + } |
| + } |
| + superclass = superclass.superclass; |
| + } |
| + |
| + return stubs; |
| + } |
| + |
| + StubMethod _generateTypeVariableReader(ClassElement cls, |
| + TypeVariableElement element) { |
| + String name = namer.readTypeVariableName(element); |
| + int index = RuntimeTypes.getTypeVariableIndex(element); |
| + jsAst.Expression computeTypeVariable; |
| + |
| + Substitution substitution = |
| + backend.rti.computeSubstitution( |
| + cls, element.typeDeclaration, alwaysGenerateFunction: true); |
| + if (substitution != null) { |
| + computeTypeVariable = |
| + js(r'#.apply(null, this.$builtinTypeInfo)', |
| + substitution.getCodeForVariable(index, backend.rti)); |
| + } else { |
| + // TODO(ahe): These can be generated dynamically. |
| + computeTypeVariable = |
| + js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', |
| + js.number(index)); |
| + } |
| + jsAst.Expression convertRtiToRuntimeType = backend.emitter |
| + .staticFunctionAccess(backend.findHelper('convertRtiToRuntimeType')); |
| + |
| + return new StubMethod(name, |
|
zarah
2015/02/10 12:50:30
This method is copied from class_emitter. It diffe
|
| + js('function () { return #(#) }', |
| + [convertRtiToRuntimeType, computeTypeVariable])); |
| + } |
| + |
| } |
| /// Creates two JavaScript functions: `tearOffGetter` and `tearOff`. |