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

Unified Diff: sdk/lib/_internal/compiler/implementation/constants.dart

Issue 22909056: Support general expressions as keys in literal maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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: sdk/lib/_internal/compiler/implementation/constants.dart
diff --git a/sdk/lib/_internal/compiler/implementation/constants.dart b/sdk/lib/_internal/compiler/implementation/constants.dart
index 4ff011ccd77651823df56bc82d548abf3de51400..9350fb3b359202267164612cb36ab862d2c0a071 100644
--- a/sdk/lib/_internal/compiler/implementation/constants.dart
+++ b/sdk/lib/_internal/compiler/implementation/constants.dart
@@ -374,19 +374,26 @@ class MapConstant extends ObjectConstant {
/** The dart class implementing constant map literals. */
static const SourceString DART_CLASS = const SourceString("ConstantMap");
+ static const SourceString DART_STRING_CLASS =
+ const SourceString("ConstantStringMap");
static const SourceString DART_PROTO_CLASS =
const SourceString("ConstantProtoMap");
+ static const SourceString DART_GENERAL_CLASS =
+ const SourceString("GeneralConstantMap");
static const SourceString LENGTH_NAME = const SourceString("length");
static const SourceString JS_OBJECT_NAME = const SourceString("_jsObject");
static const SourceString KEYS_NAME = const SourceString("_keys");
static const SourceString PROTO_VALUE = const SourceString("_protoValue");
+ static const SourceString JS_DATA_NAME = const SourceString("_jsData");
final ListConstant keys;
final List<Constant> values;
final Constant protoValue;
final int hashCode;
+ final bool hasNonStringKey;
- MapConstant(DartType type, this.keys, List<Constant> values, this.protoValue)
+ MapConstant(DartType type, this.keys, List<Constant> values, this.protoValue,
+ this.hasNonStringKey)
: this.values = values,
this.hashCode = computeHash(type, values),
super(type);
@@ -415,7 +422,12 @@ class MapConstant extends ObjectConstant {
}
List<Constant> getDependencies() {
- List<Constant> result = <Constant>[keys];
+ List<Constant> result = <Constant>[];
+ if (hasNonStringKey) {
ngeoffray 2013/09/13 07:30:15 This seems fishy. Why can't you just add keys? Is
Johnni Winther 2013/09/18 12:37:21 If I just add [keys], we will create an unused con
+ result.addAll(keys.entries);
+ } else {
+ result.add(keys);
+ }
result.addAll(values);
return result;
}

Powered by Google App Engine
This is Rietveld 408576698