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

Unified Diff: pkg/compiler/lib/src/js_emitter/class_stub_generator.dart

Issue 895813006: dart2js: store typeVariableReader stubs in the model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/model.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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`.
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698