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

Unified Diff: pkg/compiler/lib/src/constants/values.dart

Issue 1492233002: Constant folding of indexers (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « pkg/compiler/lib/src/common/names.dart ('k') | pkg/compiler/lib/src/cps_ir/type_mask_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/constants/values.dart
diff --git a/pkg/compiler/lib/src/constants/values.dart b/pkg/compiler/lib/src/constants/values.dart
index 2a7c5c4d45e157f3f8896c95aa8fbf6f8cf2aec0..945aaba89e838c506dc52cca41077f467f436237 100644
--- a/pkg/compiler/lib/src/constants/values.dart
+++ b/pkg/compiler/lib/src/constants/values.dart
@@ -502,6 +502,7 @@ class MapConstantValue extends ObjectConstantValue {
final List<ConstantValue> keys;
final List<ConstantValue> values;
final int hashCode;
+ Map<ConstantValue, ConstantValue> _lookupMap;
MapConstantValue(InterfaceType type,
List<ConstantValue> keys,
@@ -539,6 +540,12 @@ class MapConstantValue extends ObjectConstantValue {
int get length => keys.length;
+ ConstantValue lookup(ConstantValue key) {
+ var lookupMap = _lookupMap ??=
+ new Map<ConstantValue, ConstantValue>.fromIterables(keys, values);
+ return lookupMap[key];
+ }
+
accept(ConstantValueVisitor visitor, arg) => visitor.visitMap(this, arg);
String unparse() {
« no previous file with comments | « pkg/compiler/lib/src/common/names.dart ('k') | pkg/compiler/lib/src/cps_ir/type_mask_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698