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

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

Issue 26472002: Add TypeVariable object on runtime to support reflection on type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. 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: sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
index edf808f5b97b28aa514d411ba67ea39d9d6ff7ad..b29e8d5582e0ecb51d10709ca9a9d66614281f60 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
@@ -5,6 +5,7 @@
part of dart2js.js_emitter;
class ClassEmitter extends CodeEmitterHelper {
+
ahe 2013/10/15 14:56:31 Extra line.
zarah 2013/10/16 07:00:47 Done.
/**
* Documentation wanted -- johnniwinther
*
@@ -291,9 +292,9 @@ class ClassEmitter extends CodeEmitterHelper {
if (backend.isNeededForReflection(classElement)) {
Link typeVars = classElement.typeVariables;
List properties = [];
- for (TypeVariableType typeVar in typeVars) {
- properties.add(js.string(typeVar.name.slowToString()));
- properties.add(js.toExpression(task.reifyType(typeVar.element.bound)));
+ if (task.typeVariableHandler.typeVariablesOf(classElement) != null) {
+ properties = task.typeVariableHandler.typeVariablesOf(classElement)
+ .map((s) => js.toExpression(s));
ahe 2013/10/15 14:56:31 "(s) => js.toExpression(s)" is equivalent to "js.t
zarah 2013/10/16 07:00:47 Done.
}
ClassElement superclass = classElement.superclass;
@@ -340,11 +341,15 @@ class ClassEmitter extends CodeEmitterHelper {
buffer.write(jsAst.prettyPrint(builder.toObjectInitializer(), compiler));
String reflectionName = task.getReflectionName(classElement, className);
if (reflectionName != null) {
- List<int> interfaces = <int>[];
- for (DartType interface in classElement.interfaces) {
- interfaces.add(task.reifyType(interface));
+ if (!backend.isNeededForReflection(classElement)) {
+ buffer.write(',$n$n"+$reflectionName": 0');
+ } else {
+ List<int> interfaces = <int>[];
+ for (DartType interface in classElement.interfaces) {
+ interfaces.add(task.reifyType(interface));
+ }
+ buffer.write(',$n$n"+$reflectionName": $interfaces');
}
- buffer.write(',$n$n"+$reflectionName": $interfaces');
}
}

Powered by Google App Engine
This is Rietveld 408576698