| 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`,
|
|
|