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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/serialization/serialization.dart
diff --git a/pkg/compiler/lib/src/serialization/serialization.dart b/pkg/compiler/lib/src/serialization/serialization.dart
index a336321494e46733287dfdb4ff64ae77aa67ae9f..6f046d4d28d0359fb5af51c423ad7390f2443493 100644
--- a/pkg/compiler/lib/src/serialization/serialization.dart
+++ b/pkg/compiler/lib/src/serialization/serialization.dart
@@ -7,6 +7,7 @@ library dart2js.serialization;
import '../elements/elements.dart';
import '../constants/expressions.dart';
import '../dart_types.dart';
+import '../util/enumset.dart';
import 'constant_serialization.dart';
import 'element_serialization.dart';
@@ -103,6 +104,17 @@ abstract class AbstractEncoder<K> {
_map[key] = new EnumValue(value);
}
+ /// Maps the [key] entry to the set of enum [values] in the encoded object.
+ void setEnums(K key, Iterable values) {
+ setEnumSet(key, new EnumSet.fromValues(values));
+ }
+
+ /// Maps the [key] entry to the enum [set] in the encoded object.
+ void setEnumSet(K key, EnumSet set) {
+ _checkKey(key);
+ _map[key] = new IntValue(set.value);
+ }
+
/// Maps the [key] entry to the [element] in the encoded object.
void setElement(K key, Element element) {
_checkKey(key);
@@ -321,6 +333,22 @@ abstract class AbstractDecoder<K> {
return enumValues[value];
}
+ /// Returns the set of enum values associated with [key] in the decoded
+ /// object.
+ ///
+ /// If no value is associated with [key], then if [isOptional] is `true`,
+ /// [defaultValue] is returned, otherwise an exception is thrown.
+ EnumSet getEnums(K key, {bool isOptional: false}) {
+ int value = _map[_getKeyValue(key)];
+ if (value == null) {
+ if (isOptional) {
+ return const EnumSet.fixed(0);
+ }
+ throw new StateError("enum values '$key' not found in $_map.");
+ }
+ return new EnumSet.fixed(value);
+ }
+
/// Returns the [Element] value associated with [key] in the decoded object.
///
/// If no value is associated with [key], then if [isOptional] is `true`,
« 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