| 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 dart2js.serialization_system; | 5 library dart2js.serialization_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/resolution.dart'; | 10 import '../common/resolution.dart'; |
| 11 import '../compiler.dart'; | 11 import '../compiler.dart'; |
| 12 import '../dart_types.dart'; | |
| 13 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
| 14 import '../scanner/scanner.dart'; | 13 import '../scanner/scanner.dart'; |
| 15 import '../script.dart'; | 14 import '../script.dart'; |
| 16 import '../serialization/impact_serialization.dart'; | 15 import '../serialization/impact_serialization.dart'; |
| 17 import '../tokens/token.dart'; | 16 import '../tokens/token.dart'; |
| 18 import '../universe/call_structure.dart'; | 17 import '../universe/call_structure.dart'; |
| 19 import '../universe/use.dart'; | 18 import '../universe/use.dart'; |
| 20 import '../universe/world_impact.dart'; | 19 import '../universe/world_impact.dart'; |
| 21 import 'modelz.dart'; | 20 import 'modelz.dart'; |
| 22 import 'resolved_ast_serialization.dart'; | 21 import 'resolved_ast_serialization.dart'; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 element.enclosingClass.isUnnamedMixinApplication) { | 149 element.enclosingClass.isUnnamedMixinApplication) { |
| 151 return true; | 150 return true; |
| 152 } | 151 } |
| 153 return _resolutionImpactDeserializer.hasResolutionImpact(element); | 152 return _resolutionImpactDeserializer.hasResolutionImpact(element); |
| 154 } | 153 } |
| 155 | 154 |
| 156 @override | 155 @override |
| 157 ResolutionImpact getResolutionImpact(Element element) { | 156 ResolutionImpact getResolutionImpact(Element element) { |
| 158 if (element.isConstructor && | 157 if (element.isConstructor && |
| 159 element.enclosingClass.isUnnamedMixinApplication) { | 158 element.enclosingClass.isUnnamedMixinApplication) { |
| 160 ConstructorElement constructor = element; | 159 ClassElement superclass = element.enclosingClass.superclass; |
| 161 ClassElement superclass = constructor.enclosingClass.superclass; | |
| 162 ConstructorElement superclassConstructor = | 160 ConstructorElement superclassConstructor = |
| 163 superclass.lookupConstructor(constructor.name); | 161 superclass.lookupConstructor(element.name); |
| 164 assert(invariant(element, superclassConstructor != null, | 162 assert(invariant(element, superclassConstructor != null, |
| 165 message: "Superclass constructor '${constructor.name}' called from " | 163 message: "Superclass constructor '${element.name}' called from " |
| 166 "${element} not found in ${superclass}.")); | 164 "${element} not found in ${superclass}.")); |
| 167 // TODO(johnniwinther): Compute callStructure. Currently not used. | 165 // TODO(johnniwinther): Compute callStructure. Currently not used. |
| 168 CallStructure callStructure; | 166 CallStructure callStructure; |
| 169 return _resolutionImpactDeserializer.registerResolutionImpact(constructor, | 167 return _resolutionImpactDeserializer.registerResolutionImpact(element, |
| 170 () { | 168 () { |
| 171 List<TypeUse> typeUses = <TypeUse>[]; | |
| 172 void addCheckedModeCheck(DartType type) { | |
| 173 if (!type.isDynamic) { | |
| 174 typeUses.add(new TypeUse.checkedModeCheck(type)); | |
| 175 } | |
| 176 } | |
| 177 | |
| 178 FunctionType type = constructor.type; | |
| 179 // TODO(johnniwinther): Remove this substitution when synthesized | |
| 180 // constructors handle type variables correctly. | |
| 181 type = type.substByContext(constructor.enclosingClass | |
| 182 .asInstanceOf(constructor.enclosingClass)); | |
| 183 type.parameterTypes.forEach(addCheckedModeCheck); | |
| 184 type.optionalParameterTypes.forEach(addCheckedModeCheck); | |
| 185 type.namedParameterTypes.forEach(addCheckedModeCheck); | |
| 186 return new DeserializedResolutionImpact(staticUses: <StaticUse>[ | 169 return new DeserializedResolutionImpact(staticUses: <StaticUse>[ |
| 187 new StaticUse.superConstructorInvoke( | 170 new StaticUse.superConstructorInvoke( |
| 188 superclassConstructor, callStructure) | 171 superclassConstructor, callStructure) |
| 189 ], typeUses: typeUses); | 172 ]); |
| 190 }); | 173 }); |
| 191 } | 174 } |
| 192 return _resolutionImpactDeserializer.getResolutionImpact(element); | 175 return _resolutionImpactDeserializer.getResolutionImpact(element); |
| 193 } | 176 } |
| 194 } | 177 } |
| 195 | 178 |
| 196 const String WORLD_IMPACT_TAG = 'worldImpact'; | 179 const String WORLD_IMPACT_TAG = 'worldImpact'; |
| 197 | 180 |
| 198 class ResolutionImpactSerializer extends SerializerPlugin { | 181 class ResolutionImpactSerializer extends SerializerPlugin { |
| 199 final Resolution resolution; | 182 final Resolution resolution; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 } | 305 } |
| 323 | 306 |
| 324 @override | 307 @override |
| 325 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { | 308 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { |
| 326 ObjectDecoder decoder = getDecoder(RESOLVED_AST_TAG); | 309 ObjectDecoder decoder = getDecoder(RESOLVED_AST_TAG); |
| 327 if (decoder != null) { | 310 if (decoder != null) { |
| 328 _decoderMap[element] = decoder; | 311 _decoderMap[element] = decoder; |
| 329 } | 312 } |
| 330 } | 313 } |
| 331 } | 314 } |
| OLD | NEW |