| 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.impact; | 5 library dart2js.serialization.impact; |
| 6 | 6 |
| 7 import '../common/resolution.dart'; | 7 import '../common/resolution.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../elements/resolution_types.dart'; | 9 import '../elements/resolution_types.dart'; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 /// Deserializes a [WorldImpact] from [objectDecoder]. | 130 /// Deserializes a [WorldImpact] from [objectDecoder]. |
| 131 static ResolutionImpact deserializeImpact(Element element, | 131 static ResolutionImpact deserializeImpact(Element element, |
| 132 ObjectDecoder objectDecoder, DeserializerPlugin nativeDataDeserializer) { | 132 ObjectDecoder objectDecoder, DeserializerPlugin nativeDataDeserializer) { |
| 133 ListDecoder staticUseDecoder = objectDecoder.getList(Key.STATIC_USES); | 133 ListDecoder staticUseDecoder = objectDecoder.getList(Key.STATIC_USES); |
| 134 List<StaticUse> staticUses = <StaticUse>[]; | 134 List<StaticUse> staticUses = <StaticUse>[]; |
| 135 for (int index = 0; index < staticUseDecoder.length; index++) { | 135 for (int index = 0; index < staticUseDecoder.length; index++) { |
| 136 ObjectDecoder object = staticUseDecoder.getObject(index); | 136 ObjectDecoder object = staticUseDecoder.getObject(index); |
| 137 StaticUseKind kind = object.getEnum(Key.KIND, StaticUseKind.values); | 137 StaticUseKind kind = object.getEnum(Key.KIND, StaticUseKind.values); |
| 138 Element usedElement = | 138 Element usedElement = |
| 139 deserializeElementReference(element, Key.ELEMENT, Key.NAME, object); | 139 deserializeElementReference(element, Key.ELEMENT, Key.NAME, object); |
| 140 DartType type = object.getType(Key.TYPE, isOptional: true); | 140 ResolutionDartType type = object.getType(Key.TYPE, isOptional: true); |
| 141 staticUses.add(new StaticUse.internal(usedElement, kind, type)); | 141 staticUses.add(new StaticUse.internal(usedElement, kind, type)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 ListDecoder dynamicUseDecoder = objectDecoder.getList(Key.DYNAMIC_USES); | 144 ListDecoder dynamicUseDecoder = objectDecoder.getList(Key.DYNAMIC_USES); |
| 145 List<DynamicUse> dynamicUses = <DynamicUse>[]; | 145 List<DynamicUse> dynamicUses = <DynamicUse>[]; |
| 146 for (int index = 0; index < dynamicUseDecoder.length; index++) { | 146 for (int index = 0; index < dynamicUseDecoder.length; index++) { |
| 147 ObjectDecoder object = dynamicUseDecoder.getObject(index); | 147 ObjectDecoder object = dynamicUseDecoder.getObject(index); |
| 148 Selector selector = deserializeSelector(object); | 148 Selector selector = deserializeSelector(object); |
| 149 dynamicUses.add(new DynamicUse(selector, null)); | 149 dynamicUses.add(new DynamicUse(selector, null)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 ListDecoder typeUseDecoder = objectDecoder.getList(Key.TYPE_USES); | 152 ListDecoder typeUseDecoder = objectDecoder.getList(Key.TYPE_USES); |
| 153 List<TypeUse> typeUses = <TypeUse>[]; | 153 List<TypeUse> typeUses = <TypeUse>[]; |
| 154 for (int index = 0; index < typeUseDecoder.length; index++) { | 154 for (int index = 0; index < typeUseDecoder.length; index++) { |
| 155 ObjectDecoder object = typeUseDecoder.getObject(index); | 155 ObjectDecoder object = typeUseDecoder.getObject(index); |
| 156 TypeUseKind kind = object.getEnum(Key.KIND, TypeUseKind.values); | 156 TypeUseKind kind = object.getEnum(Key.KIND, TypeUseKind.values); |
| 157 DartType type = object.getType(Key.TYPE); | 157 ResolutionDartType type = object.getType(Key.TYPE); |
| 158 typeUses.add(new TypeUse.internal(type, kind)); | 158 typeUses.add(new TypeUse.internal(type, kind)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 List<String> constSymbolNames = | 161 List<String> constSymbolNames = |
| 162 objectDecoder.getStrings(Key.SYMBOLS, isOptional: true); | 162 objectDecoder.getStrings(Key.SYMBOLS, isOptional: true); |
| 163 | 163 |
| 164 List<ConstantExpression> constantLiterals = | 164 List<ConstantExpression> constantLiterals = |
| 165 objectDecoder.getConstants(Key.CONSTANTS, isOptional: true); | 165 objectDecoder.getConstants(Key.CONSTANTS, isOptional: true); |
| 166 | 166 |
| 167 EnumSet<Feature> features = | 167 EnumSet<Feature> features = |
| 168 objectDecoder.getEnums(Key.FEATURES, isOptional: true); | 168 objectDecoder.getEnums(Key.FEATURES, isOptional: true); |
| 169 | 169 |
| 170 ListDecoder listLiteralDecoder = | 170 ListDecoder listLiteralDecoder = |
| 171 objectDecoder.getList(Key.LISTS, isOptional: true); | 171 objectDecoder.getList(Key.LISTS, isOptional: true); |
| 172 List<ListLiteralUse> listLiterals = const <ListLiteralUse>[]; | 172 List<ListLiteralUse> listLiterals = const <ListLiteralUse>[]; |
| 173 if (listLiteralDecoder != null) { | 173 if (listLiteralDecoder != null) { |
| 174 listLiterals = <ListLiteralUse>[]; | 174 listLiterals = <ListLiteralUse>[]; |
| 175 for (int i = 0; i < listLiteralDecoder.length; i++) { | 175 for (int i = 0; i < listLiteralDecoder.length; i++) { |
| 176 ObjectDecoder useDecoder = listLiteralDecoder.getObject(i); | 176 ObjectDecoder useDecoder = listLiteralDecoder.getObject(i); |
| 177 DartType type = useDecoder.getType(Key.TYPE); | 177 ResolutionDartType type = useDecoder.getType(Key.TYPE); |
| 178 bool isConstant = useDecoder.getBool(Key.IS_CONST); | 178 bool isConstant = useDecoder.getBool(Key.IS_CONST); |
| 179 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); | 179 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); |
| 180 listLiterals.add( | 180 listLiterals.add( |
| 181 new ListLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); | 181 new ListLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 ListDecoder mapLiteralDecoder = | 185 ListDecoder mapLiteralDecoder = |
| 186 objectDecoder.getList(Key.MAPS, isOptional: true); | 186 objectDecoder.getList(Key.MAPS, isOptional: true); |
| 187 List<MapLiteralUse> mapLiterals = const <MapLiteralUse>[]; | 187 List<MapLiteralUse> mapLiterals = const <MapLiteralUse>[]; |
| 188 if (mapLiteralDecoder != null) { | 188 if (mapLiteralDecoder != null) { |
| 189 mapLiterals = <MapLiteralUse>[]; | 189 mapLiterals = <MapLiteralUse>[]; |
| 190 for (int i = 0; i < mapLiteralDecoder.length; i++) { | 190 for (int i = 0; i < mapLiteralDecoder.length; i++) { |
| 191 ObjectDecoder useDecoder = mapLiteralDecoder.getObject(i); | 191 ObjectDecoder useDecoder = mapLiteralDecoder.getObject(i); |
| 192 DartType type = useDecoder.getType(Key.TYPE); | 192 ResolutionDartType type = useDecoder.getType(Key.TYPE); |
| 193 bool isConstant = useDecoder.getBool(Key.IS_CONST); | 193 bool isConstant = useDecoder.getBool(Key.IS_CONST); |
| 194 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); | 194 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); |
| 195 mapLiterals.add( | 195 mapLiterals.add( |
| 196 new MapLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); | 196 new MapLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 ListDecoder nativeDataDecoder = | 200 ListDecoder nativeDataDecoder = |
| 201 objectDecoder.getList(Key.NATIVE, isOptional: true); | 201 objectDecoder.getList(Key.NATIVE, isOptional: true); |
| 202 List<dynamic> nativeData = const <dynamic>[]; | 202 List<dynamic> nativeData = const <dynamic>[]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 216 constantLiterals: constantLiterals, | 216 constantLiterals: constantLiterals, |
| 217 dynamicUses: dynamicUses, | 217 dynamicUses: dynamicUses, |
| 218 features: features, | 218 features: features, |
| 219 listLiterals: listLiterals, | 219 listLiterals: listLiterals, |
| 220 mapLiterals: mapLiterals, | 220 mapLiterals: mapLiterals, |
| 221 staticUses: staticUses, | 221 staticUses: staticUses, |
| 222 typeUses: typeUses, | 222 typeUses: typeUses, |
| 223 nativeData: nativeData); | 223 nativeData: nativeData); |
| 224 } | 224 } |
| 225 } | 225 } |
| OLD | NEW |