OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 library kernel.type_propagation; | 4 library kernel.type_propagation; |
5 | 5 |
6 import '../ast.dart'; | 6 import '../ast.dart'; |
7 import '../class_hierarchy.dart'; | 7 import '../class_hierarchy.dart'; |
8 import '../core_types.dart'; | 8 import '../core_types.dart'; |
9 import 'builder.dart'; | 9 import 'builder.dart'; |
10 import 'solver.dart'; | 10 import 'solver.dart'; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return solver.getValueInferredForVariable(variable); | 44 return solver.getValueInferredForVariable(variable); |
45 } | 45 } |
46 | 46 |
47 InferredValue getParameterValue(VariableDeclaration node) { | 47 InferredValue getParameterValue(VariableDeclaration node) { |
48 int variable = builder.global.parameters[node]; | 48 int variable = builder.global.parameters[node]; |
49 if (variable == null) return null; | 49 if (variable == null) return null; |
50 return solver.getValueInferredForVariable(variable); | 50 return solver.getValueInferredForVariable(variable); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 enum BaseClassKind { None, Exact, Subclass, Subtype, } | 54 enum BaseClassKind { |
| 55 None, |
| 56 Exact, |
| 57 Subclass, |
| 58 Subtype, |
| 59 } |
55 | 60 |
56 /// An abstract value inferred by type propagation. | 61 /// An abstract value inferred by type propagation. |
57 /// | 62 /// |
58 /// Inferred values consist of two parts that each represent a set of values: | 63 /// Inferred values consist of two parts that each represent a set of values: |
59 /// its base class and its bitmask. The InferredValue object represents the | 64 /// its base class and its bitmask. The InferredValue object represents the |
60 /// intersection of these two value sets. | 65 /// intersection of these two value sets. |
61 class InferredValue extends Node { | 66 class InferredValue extends Node { |
62 final Class baseClass; | 67 final Class baseClass; |
63 final BaseClassKind baseClassKind; | 68 final BaseClassKind baseClassKind; |
64 | 69 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 if (bitmask == all) return '{*}'; | 153 if (bitmask == all) return '{*}'; |
149 List<String> list = <String>[]; | 154 List<String> list = <String>[]; |
150 for (int i = 0; i < numberOfBits; ++i) { | 155 for (int i = 0; i < numberOfBits; ++i) { |
151 if (bitmask & (1 << i) != 0) { | 156 if (bitmask & (1 << i) != 0) { |
152 list.add(names[1 << i] ?? '?'); | 157 list.add(names[1 << i] ?? '?'); |
153 } | 158 } |
154 } | 159 } |
155 return '{${list.join(",")}}'; | 160 return '{${list.join(",")}}'; |
156 } | 161 } |
157 } | 162 } |
OLD | NEW |