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

Unified Diff: pkg/compiler/lib/src/cps_ir/type_mask_system.dart

Issue 1486023002: Propagate types of static const variables. (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
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 ed2157241846a385c363cb7c161c306732ced791..f95bfe0deff09b373eafc495793d8a179051da55 100644
--- a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
@@ -34,6 +34,13 @@ class TypeMaskSystem {
TypeMask __indexableTypeTest;
+ // The full type of a constant (e.g. a ContainerTypeMask) is not available on
+ // the constant. Type inference flows the type to some place where it is used,
+ // e.g. a parameter. For constant values that are the value of static const
+ // fields we need to remember the association.
+ final Map<ConstantValue, TypeMask> _constantMasks =
+ <ConstantValue, TypeMask>{};
+
TypeMask get dynamicType => inferrer.dynamicType;
TypeMask get typeType => inferrer.typeType;
TypeMask get functionType => inferrer.functionType;
@@ -203,7 +210,16 @@ class TypeMaskSystem {
return a.intersection(b, classWorld);
}
+ void associateConstantValueWithElement(ConstantValue constant,
+ Element element) {
+ if (constant is ListConstantValue) {
+ _constantMasks[constant] = inferrer.getGuaranteedTypeOfElement(element);
+ }
+ }
+
TypeMask getTypeOf(ConstantValue constant) {
+ TypeMask mask = _constantMasks[constant];
+ if (mask != null) return mask;
return computeTypeMask(inferrer.compiler, constant);
}
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698