| 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 26 matching lines...) Expand all Loading... |
| 37 void serialize(ResolutionImpact resolutionImpact) { | 37 void serialize(ResolutionImpact resolutionImpact) { |
| 38 resolutionImpact.apply(this); | 38 resolutionImpact.apply(this); |
| 39 objectEncoder.setStrings(Key.SYMBOLS, resolutionImpact.constSymbolNames); | 39 objectEncoder.setStrings(Key.SYMBOLS, resolutionImpact.constSymbolNames); |
| 40 objectEncoder.setConstants( | 40 objectEncoder.setConstants( |
| 41 Key.CONSTANTS, resolutionImpact.constantLiterals); | 41 Key.CONSTANTS, resolutionImpact.constantLiterals); |
| 42 objectEncoder.setEnums(Key.FEATURES, resolutionImpact.features); | 42 objectEncoder.setEnums(Key.FEATURES, resolutionImpact.features); |
| 43 if (resolutionImpact.listLiterals.isNotEmpty) { | 43 if (resolutionImpact.listLiterals.isNotEmpty) { |
| 44 ListEncoder encoder = objectEncoder.createList(Key.LISTS); | 44 ListEncoder encoder = objectEncoder.createList(Key.LISTS); |
| 45 for (ListLiteralUse use in resolutionImpact.listLiterals) { | 45 for (ListLiteralUse use in resolutionImpact.listLiterals) { |
| 46 ObjectEncoder useEncoder = encoder.createObject(); | 46 ObjectEncoder useEncoder = encoder.createObject(); |
| 47 useEncoder.setType(Key.TYPE, use.type); | 47 ResolutionInterfaceType type = use.type; |
| 48 useEncoder.setType(Key.TYPE, type); |
| 48 useEncoder.setBool(Key.IS_CONST, use.isConstant); | 49 useEncoder.setBool(Key.IS_CONST, use.isConstant); |
| 49 useEncoder.setBool(Key.IS_EMPTY, use.isEmpty); | 50 useEncoder.setBool(Key.IS_EMPTY, use.isEmpty); |
| 50 } | 51 } |
| 51 } | 52 } |
| 52 if (resolutionImpact.mapLiterals.isNotEmpty) { | 53 if (resolutionImpact.mapLiterals.isNotEmpty) { |
| 53 ListEncoder encoder = objectEncoder.createList(Key.MAPS); | 54 ListEncoder encoder = objectEncoder.createList(Key.MAPS); |
| 54 for (MapLiteralUse use in resolutionImpact.mapLiterals) { | 55 for (MapLiteralUse use in resolutionImpact.mapLiterals) { |
| 55 ObjectEncoder useEncoder = encoder.createObject(); | 56 ObjectEncoder useEncoder = encoder.createObject(); |
| 56 useEncoder.setType(Key.TYPE, use.type); | 57 ResolutionInterfaceType type = use.type; |
| 58 useEncoder.setType(Key.TYPE, type); |
| 57 useEncoder.setBool(Key.IS_CONST, use.isConstant); | 59 useEncoder.setBool(Key.IS_CONST, use.isConstant); |
| 58 useEncoder.setBool(Key.IS_EMPTY, use.isEmpty); | 60 useEncoder.setBool(Key.IS_EMPTY, use.isEmpty); |
| 59 } | 61 } |
| 60 } | 62 } |
| 61 if (resolutionImpact.nativeData.isNotEmpty) { | 63 if (resolutionImpact.nativeData.isNotEmpty) { |
| 62 ListEncoder encoder = objectEncoder.createList(Key.NATIVE); | 64 ListEncoder encoder = objectEncoder.createList(Key.NATIVE); |
| 63 for (dynamic data in resolutionImpact.nativeData) { | 65 for (dynamic data in resolutionImpact.nativeData) { |
| 64 nativeDataSerializer.onData(data, encoder.createObject()); | 66 nativeDataSerializer.onData(data, encoder.createObject()); |
| 65 } | 67 } |
| 66 } | 68 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 EnumSet<Feature> features = | 169 EnumSet<Feature> features = |
| 168 objectDecoder.getEnums(Key.FEATURES, isOptional: true); | 170 objectDecoder.getEnums(Key.FEATURES, isOptional: true); |
| 169 | 171 |
| 170 ListDecoder listLiteralDecoder = | 172 ListDecoder listLiteralDecoder = |
| 171 objectDecoder.getList(Key.LISTS, isOptional: true); | 173 objectDecoder.getList(Key.LISTS, isOptional: true); |
| 172 List<ListLiteralUse> listLiterals = const <ListLiteralUse>[]; | 174 List<ListLiteralUse> listLiterals = const <ListLiteralUse>[]; |
| 173 if (listLiteralDecoder != null) { | 175 if (listLiteralDecoder != null) { |
| 174 listLiterals = <ListLiteralUse>[]; | 176 listLiterals = <ListLiteralUse>[]; |
| 175 for (int i = 0; i < listLiteralDecoder.length; i++) { | 177 for (int i = 0; i < listLiteralDecoder.length; i++) { |
| 176 ObjectDecoder useDecoder = listLiteralDecoder.getObject(i); | 178 ObjectDecoder useDecoder = listLiteralDecoder.getObject(i); |
| 177 ResolutionDartType type = useDecoder.getType(Key.TYPE); | 179 ResolutionInterfaceType type = useDecoder.getType(Key.TYPE); |
| 178 bool isConstant = useDecoder.getBool(Key.IS_CONST); | 180 bool isConstant = useDecoder.getBool(Key.IS_CONST); |
| 179 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); | 181 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); |
| 180 listLiterals.add( | 182 listLiterals.add( |
| 181 new ListLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); | 183 new ListLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); |
| 182 } | 184 } |
| 183 } | 185 } |
| 184 | 186 |
| 185 ListDecoder mapLiteralDecoder = | 187 ListDecoder mapLiteralDecoder = |
| 186 objectDecoder.getList(Key.MAPS, isOptional: true); | 188 objectDecoder.getList(Key.MAPS, isOptional: true); |
| 187 List<MapLiteralUse> mapLiterals = const <MapLiteralUse>[]; | 189 List<MapLiteralUse> mapLiterals = const <MapLiteralUse>[]; |
| 188 if (mapLiteralDecoder != null) { | 190 if (mapLiteralDecoder != null) { |
| 189 mapLiterals = <MapLiteralUse>[]; | 191 mapLiterals = <MapLiteralUse>[]; |
| 190 for (int i = 0; i < mapLiteralDecoder.length; i++) { | 192 for (int i = 0; i < mapLiteralDecoder.length; i++) { |
| 191 ObjectDecoder useDecoder = mapLiteralDecoder.getObject(i); | 193 ObjectDecoder useDecoder = mapLiteralDecoder.getObject(i); |
| 192 ResolutionDartType type = useDecoder.getType(Key.TYPE); | 194 ResolutionInterfaceType type = useDecoder.getType(Key.TYPE); |
| 193 bool isConstant = useDecoder.getBool(Key.IS_CONST); | 195 bool isConstant = useDecoder.getBool(Key.IS_CONST); |
| 194 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); | 196 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); |
| 195 mapLiterals.add( | 197 mapLiterals.add( |
| 196 new MapLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); | 198 new MapLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); |
| 197 } | 199 } |
| 198 } | 200 } |
| 199 | 201 |
| 200 ListDecoder nativeDataDecoder = | 202 ListDecoder nativeDataDecoder = |
| 201 objectDecoder.getList(Key.NATIVE, isOptional: true); | 203 objectDecoder.getList(Key.NATIVE, isOptional: true); |
| 202 List<dynamic> nativeData = const <dynamic>[]; | 204 List<dynamic> nativeData = const <dynamic>[]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 216 constantLiterals: constantLiterals, | 218 constantLiterals: constantLiterals, |
| 217 dynamicUses: dynamicUses, | 219 dynamicUses: dynamicUses, |
| 218 features: features, | 220 features: features, |
| 219 listLiterals: listLiterals, | 221 listLiterals: listLiterals, |
| 220 mapLiterals: mapLiterals, | 222 mapLiterals: mapLiterals, |
| 221 staticUses: staticUses, | 223 staticUses: staticUses, |
| 222 typeUses: typeUses, | 224 typeUses: typeUses, |
| 223 nativeData: nativeData); | 225 nativeData: nativeData); |
| 224 } | 226 } |
| 225 } | 227 } |
| OLD | NEW |