Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: pkg/compiler/lib/src/serialization/serialization.dart

Issue 1839243003: Serialize ResolutionImpact instead of WorldImpact. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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; 5 library dart2js.serialization;
6 6
7 import '../elements/elements.dart'; 7 import '../elements/elements.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../util/enumset.dart';
10 11
11 import 'constant_serialization.dart'; 12 import 'constant_serialization.dart';
12 import 'element_serialization.dart'; 13 import 'element_serialization.dart';
13 import 'json_serializer.dart'; 14 import 'json_serializer.dart';
14 import 'keys.dart'; 15 import 'keys.dart';
15 import 'type_serialization.dart'; 16 import 'type_serialization.dart';
16 import 'values.dart'; 17 import 'values.dart';
17 18
18 export 'task.dart' show LibraryDeserializer; 19 export 'task.dart' show LibraryDeserializer;
19 20
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 _map[key] = value; 97 _map[key] = value;
97 } 98 }
98 99
99 100
100 /// Maps the [key] entry to the enum [value] in the encoded object. 101 /// Maps the [key] entry to the enum [value] in the encoded object.
101 void setEnum(K key, var value) { 102 void setEnum(K key, var value) {
102 _checkKey(key); 103 _checkKey(key);
103 _map[key] = new EnumValue(value); 104 _map[key] = new EnumValue(value);
104 } 105 }
105 106
107 /// Maps the [key] entry to the set of enum [values] in the encoded object.
108 void setEnums(K key, Iterable values) {
109 setEnumSet(key, new EnumSet.fromValues(values));
110 }
111
112 /// Maps the [key] entry to the enum [set] in the encoded object.
113 void setEnumSet(K key, EnumSet set) {
114 _checkKey(key);
115 _map[key] = new IntValue(set.value);
116 }
117
106 /// Maps the [key] entry to the [element] in the encoded object. 118 /// Maps the [key] entry to the [element] in the encoded object.
107 void setElement(K key, Element element) { 119 void setElement(K key, Element element) {
108 _checkKey(key); 120 _checkKey(key);
109 _map[key] = _serializer.createElementValue(element); 121 _map[key] = _serializer.createElementValue(element);
110 } 122 }
111 123
112 /// Maps the [key] entry to the [elements] in the encoded object. 124 /// Maps the [key] entry to the [elements] in the encoded object.
113 /// 125 ///
114 /// If [elements] is empty, it is skipped. 126 /// If [elements] is empty, it is skipped.
115 void setElements(K key, Iterable<Element> elements) { 127 void setElements(K key, Iterable<Element> elements) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 int value = _map[_getKeyValue(key)]; 326 int value = _map[_getKeyValue(key)];
315 if (value == null) { 327 if (value == null) {
316 if (isOptional || defaultValue != null) { 328 if (isOptional || defaultValue != null) {
317 return defaultValue; 329 return defaultValue;
318 } 330 }
319 throw new StateError("enum value '$key' not found in $_map."); 331 throw new StateError("enum value '$key' not found in $_map.");
320 } 332 }
321 return enumValues[value]; 333 return enumValues[value];
322 } 334 }
323 335
336 /// Returns the set of enum values associated with [key] in the decoded
337 /// object.
338 ///
339 /// If no value is associated with [key], then if [isOptional] is `true`,
340 /// [defaultValue] is returned, otherwise an exception is thrown.
341 EnumSet getEnums(K key, {bool isOptional: false}) {
342 int value = _map[_getKeyValue(key)];
343 if (value == null) {
344 if (isOptional) {
345 return const EnumSet.fixed(0);
346 }
347 throw new StateError("enum values '$key' not found in $_map.");
348 }
349 return new EnumSet.fixed(value);
350 }
351
324 /// Returns the [Element] value associated with [key] in the decoded object. 352 /// Returns the [Element] value associated with [key] in the decoded object.
325 /// 353 ///
326 /// If no value is associated with [key], then if [isOptional] is `true`, 354 /// If no value is associated with [key], then if [isOptional] is `true`,
327 /// `null` is returned, otherwise an exception is thrown. 355 /// `null` is returned, otherwise an exception is thrown.
328 Element getElement(K key, {bool isOptional: false}) { 356 Element getElement(K key, {bool isOptional: false}) {
329 int id = _map[_getKeyValue(key)]; 357 int id = _map[_getKeyValue(key)];
330 if (id == null) { 358 if (id == null) {
331 if (isOptional) { 359 if (isOptional) {
332 return null; 360 return null;
333 } 361 }
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 1035
1008 /// Returns the value used to store [key] as a property in the encoding an 1036 /// Returns the value used to store [key] as a property in the encoding an
1009 /// [ObjectValue]. 1037 /// [ObjectValue].
1010 /// 1038 ///
1011 /// Different encodings have different restrictions and capabilities as how 1039 /// Different encodings have different restrictions and capabilities as how
1012 /// to store a [Key] value. For instance: A JSON encoding needs to convert 1040 /// to store a [Key] value. For instance: A JSON encoding needs to convert
1013 /// [Key] to a [String] to store it in a JSON object; a Dart encoding can 1041 /// [Key] to a [String] to store it in a JSON object; a Dart encoding can
1014 /// choose to store a [Key] as an [int] or as the [Key] itself. 1042 /// choose to store a [Key] as an [int] or as the [Key] itself.
1015 getObjectPropertyValue(Key key); 1043 getObjectPropertyValue(Key key);
1016 } 1044 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/keys.dart ('k') | tests/compiler/dart2js/serialization_analysis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698