Index: pkg/compiler/lib/src/js_backend/backend_serialization.dart |
diff --git a/pkg/compiler/lib/src/js_backend/backend_serialization.dart b/pkg/compiler/lib/src/js_backend/backend_serialization.dart |
index 97da2f5a2d2a8cf30bfbbe5acaca1a35511243f3..019152f280d94b83a567d9ffc90c65edb42d2bb4 100644 |
--- a/pkg/compiler/lib/src/js_backend/backend_serialization.dart |
+++ b/pkg/compiler/lib/src/js_backend/backend_serialization.dart |
@@ -18,8 +18,10 @@ import 'js_backend.dart'; |
const String _BACKEND_DATA_TAG = 'jsBackendData'; |
const Key DART_TYPES_RETURNED = const Key('dartTypesReturned'); |
+const Key THIS_TYPES_RETURNED = const Key('thisTypesReturned'); |
const Key SPECIAL_TYPES_RETURNED = const Key('specialTypesReturned'); |
const Key DART_TYPES_INSTANTIATED = const Key('dartTypesInstantiated'); |
+const Key THIS_TYPES_INSTANTIATED = const Key('thisTypesInstantiated'); |
const Key SPECIAL_TYPES_INSTANTIATED = const Key('specialTypesInstantiated'); |
const Key CODE_TEMPLATE = const Key('codeTemplate'); |
const Key SIDE_EFFECTS = const Key('sideEffects'); |
@@ -150,9 +152,39 @@ class JavaScriptBackendDeserializer implements DeserializerPlugin { |
} |
class NativeBehaviorSerialization { |
- /// Returns a list of the [DartType]s in [types]. |
+ /// Returns a list of the non-this-type [DartType]s in [types]. |
static List<DartType> filterDartTypes(List types) { |
- return types.where((type) => type is DartType).toList(); |
+ return types.where((type) { |
+ if (type is DartType) { |
+ // TODO(johnniwinther): Remove this when annotation are no longer resolved |
Harry Terkelsen
2016/07/15 16:03:10
nit: long line
Johnni Winther
2016/07/18 10:44:17
Done.
|
+ // to this-types. |
+ if (type is GenericType && |
+ type.isGeneric && |
+ type == type.element.thisType) { |
+ return false; |
+ } |
+ return true; |
+ } |
+ return false; |
+ }).toList(); |
+ } |
+ |
+ // TODO(johnniwinther): Remove this when annotation are no longer resolved |
+ // to this-types. |
+ /// Returns a list of the classes of this-types in [types]. |
+ static List<Element> filterThisTypes(List types) { |
+ return types.where((type) { |
Harry Terkelsen
2016/07/15 16:03:10
maybe move this filter function to it's own local
Johnni Winther
2016/07/18 10:44:17
Done.
|
+ if (type is DartType) { |
+ if (type is GenericType && |
+ type.isGeneric && |
+ type == type.element.thisType) { |
+ return true; |
+ } |
+ } |
+ return false; |
+ }).map((type) { |
+ return type.element; |
+ }).toList(); |
} |
/// Returns a list of the names of the [SpecialType]s in [types]. |
@@ -167,11 +199,15 @@ class NativeBehaviorSerialization { |
NativeBehavior behavior, ObjectEncoder encoder) { |
encoder.setTypes( |
DART_TYPES_RETURNED, filterDartTypes(behavior.typesReturned)); |
+ encoder.setElements( |
+ THIS_TYPES_RETURNED, filterThisTypes(behavior.typesReturned)); |
encoder.setStrings( |
SPECIAL_TYPES_RETURNED, filterSpecialTypes(behavior.typesReturned)); |
encoder.setTypes( |
DART_TYPES_INSTANTIATED, filterDartTypes(behavior.typesInstantiated)); |
+ encoder.setElements( |
+ THIS_TYPES_INSTANTIATED, filterThisTypes(behavior.typesInstantiated)); |
encoder.setStrings(SPECIAL_TYPES_INSTANTIATED, |
filterSpecialTypes(behavior.typesInstantiated)); |
@@ -193,12 +229,20 @@ class NativeBehaviorSerialization { |
behavior.typesReturned |
.addAll(decoder.getTypes(DART_TYPES_RETURNED, isOptional: true)); |
behavior.typesReturned.addAll(decoder |
+ .getElements(THIS_TYPES_RETURNED, isOptional: true) |
+ .map((element) => element.thisType) |
+ .toList()); |
+ behavior.typesReturned.addAll(decoder |
.getStrings(SPECIAL_TYPES_RETURNED, isOptional: true) |
.map(SpecialType.fromName)); |
behavior.typesInstantiated |
.addAll(decoder.getTypes(DART_TYPES_INSTANTIATED, isOptional: true)); |
behavior.typesInstantiated.addAll(decoder |
+ .getElements(THIS_TYPES_INSTANTIATED, isOptional: true) |
+ .map((element) => element.thisType) |
+ .toList()); |
+ behavior.typesInstantiated.addAll(decoder |
.getStrings(SPECIAL_TYPES_INSTANTIATED, isOptional: true) |
.map(SpecialType.fromName)); |