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

Unified Diff: pkg/compiler/lib/src/cps_ir/type_mask_system.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/constants/values.dart ('k') | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/type_mask_system.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
index 232914493d66747a2b22da72def3c5b8dd6a168a..25fb1c9e8c20394e22760ebd427f3cf34b1c17eb 100644
--- a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
@@ -579,4 +579,19 @@ class TypeMaskSystem implements AbstractValueDomain {
return null;
}
}
+
+ /// Returns the type of the entry at a given index, `null` if unknown.
+ TypeMask indexWithConstant(TypeMask container, ConstantValue indexValue) {
+ if (container is DictionaryTypeMask) {
+ if (indexValue is StringConstantValue) {
+ String key = indexValue.primitiveValue.slowToString();
+ TypeMask result = container.typeMap[key];
+ if (result != null) return result;
+ }
+ }
+ if (container is ContainerTypeMask) {
+ return container.elementType;
+ }
+ return null;
+ }
}
« no previous file with comments | « pkg/compiler/lib/src/constants/values.dart ('k') | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698