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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart

Issue 50313007: Implement dynamic function checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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: 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 53285fd7cd97b9cf0f03e28ebc2a9063c19b34d4..7d6499f2f4a40e6fd497412dc183a44b9bd41fce 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
@@ -42,6 +42,8 @@ class ClassEmitter extends CodeEmitterHelper {
emitInstanceMembers(classElement, builder, onlyForRti: onlyForRti);
task.typeTestEmitter.emitIsTests(classElement, builder);
+ emitTypeVariableReaders(classElement, builder);
+
emitClassBuilderWithReflectionData(
className, classElement, builder, buffer);
}
@@ -601,4 +603,38 @@ 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) {
+ if (task.readTypeVariables.contains(parameter.element)) {
+ emitTypeVariableReader(cls, builder, parameter.element);
+ }
+ }
+ superclass = superclass.superclass;
Johnni Winther 2013/10/30 11:40:23 The superclass chain is not properly substuted. Fo
Johnni Winther 2013/10/30 12:02:19 Actually you will visit C<U>, B<S>, A<T> if [cls]
ahe 2013/10/30 12:04:05 I don't think that is enough. Consider this situa
+ }
+ }
+
+ void emitTypeVariableReader(ClassElement cls,
+ ClassBuilder builder,
+ TypeVariableElement element) {
+ String name = namer.readTypeVariableName(element);
+ List<jsAst.Node> body;
+ if (cls != element.enclosingElement) {
+ body = <jsAst.Node>[
+ new jsAst.Throw(js.string('Cannot read type variable ${element}'))];
ahe 2013/10/29 22:42:49 This is the only thing that causes tests to fail,
Johnni Winther 2013/10/30 11:40:23 The change above should solve this.
+ } else {
+ body = <jsAst.Node>[
+ js.return_(
+ namer.elementAccess(
+ compiler.findHelper('convertRtiToRuntimeType'))(
+ js(r'this.$builtinTypeInfo[#]',
+ js.toExpression(
+ RuntimeTypes.getTypeVariableIndex(element)))))];
+ }
+ builder.addProperty(name, js.fun([], body));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698