| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library js_backend.serialization; | 5 library js_backend.serialization; |
| 6 | 6 |
| 7 import '../common/backend_api.dart' show BackendSerialization; | 7 import '../common/backend_api.dart' show BackendSerialization; |
| 8 import '../elements/resolution_types.dart'; | 8 import '../elements/resolution_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../js/js.dart' as js; | 10 import '../js/js.dart' as js; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 return NativeBehaviorSerialization.deserializeNativeBehavior(decoder); | 149 return NativeBehaviorSerialization.deserializeNativeBehavior(decoder); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 class NativeBehaviorSerialization { | 153 class NativeBehaviorSerialization { |
| 154 static const int NORMAL_TYPE = 0; | 154 static const int NORMAL_TYPE = 0; |
| 155 static const int THIS_TYPE = 1; | 155 static const int THIS_TYPE = 1; |
| 156 static const int SPECIAL_TYPE = 2; | 156 static const int SPECIAL_TYPE = 2; |
| 157 | 157 |
| 158 static int getTypeKind(var type) { | 158 static int getTypeKind(var type) { |
| 159 if (type is DartType) { | 159 if (type is ResolutionDartType) { |
| 160 // TODO(johnniwinther): Remove this when annotation are no longer resolved | 160 // TODO(johnniwinther): Remove this when annotation are no longer resolved |
| 161 // to this-types. | 161 // to this-types. |
| 162 if (type is GenericType && | 162 if (type is GenericType && |
| 163 type.isGeneric && | 163 type.isGeneric && |
| 164 type == type.element.thisType) { | 164 type == type.element.thisType) { |
| 165 return THIS_TYPE; | 165 return THIS_TYPE; |
| 166 } | 166 } |
| 167 return NORMAL_TYPE; | 167 return NORMAL_TYPE; |
| 168 } | 168 } |
| 169 return SPECIAL_TYPE; | 169 return SPECIAL_TYPE; |
| 170 } | 170 } |
| 171 | 171 |
| 172 /// Returns a list of the non-this-type [DartType]s in [types]. | 172 /// Returns a list of the non-this-type [ResolutionDartType]s in [types]. |
| 173 static List<DartType> filterDartTypes(List types) { | 173 static List<ResolutionDartType> filterDartTypes(List types) { |
| 174 return types.where((type) => getTypeKind(type) == NORMAL_TYPE).toList(); | 174 return types.where((type) => getTypeKind(type) == NORMAL_TYPE).toList(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 // TODO(johnniwinther): Remove this when annotation are no longer resolved | 177 // TODO(johnniwinther): Remove this when annotation are no longer resolved |
| 178 // to this-types. | 178 // to this-types. |
| 179 /// Returns a list of the classes of this-types in [types]. | 179 /// Returns a list of the classes of this-types in [types]. |
| 180 static List<Element> filterThisTypes(List types) { | 180 static List<Element> filterThisTypes(List types) { |
| 181 return types | 181 return types |
| 182 .where((type) => getTypeKind(type) == THIS_TYPE) | 182 .where((type) => getTypeKind(type) == THIS_TYPE) |
| 183 .map((type) => type.element) | 183 .map((type) => type.element) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText); | 249 behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText); |
| 250 } | 250 } |
| 251 | 251 |
| 252 behavior.throwBehavior = | 252 behavior.throwBehavior = |
| 253 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values); | 253 decoder.getEnum(THROW_BEHAVIOR, NativeThrowBehavior.values); |
| 254 behavior.isAllocation = decoder.getBool(IS_ALLOCATION); | 254 behavior.isAllocation = decoder.getBool(IS_ALLOCATION); |
| 255 behavior.useGvn = decoder.getBool(USE_GVN); | 255 behavior.useGvn = decoder.getBool(USE_GVN); |
| 256 return behavior; | 256 return behavior; |
| 257 } | 257 } |
| 258 } | 258 } |
| OLD | NEW |