| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 | 4 |
| 5 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart'; | 8 import '../common/names.dart'; |
| 9 import '../compiler.dart'; | 9 import '../compiler.dart'; |
| 10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 int overallRefineCount = 0; | 57 int overallRefineCount = 0; |
| 58 int addedInGraph = 0; | 58 int addedInGraph = 0; |
| 59 | 59 |
| 60 final Compiler compiler; | 60 final Compiler compiler; |
| 61 | 61 |
| 62 /// The [ClosedWorld] on which inference reasoning is based. | 62 /// The [ClosedWorld] on which inference reasoning is based. |
| 63 final ClosedWorld closedWorld; | 63 final ClosedWorld closedWorld; |
| 64 | 64 |
| 65 final ClosedWorldRefiner closedWorldRefiner; | 65 final ClosedWorldRefiner closedWorldRefiner; |
| 66 final TypeSystem types; | 66 final TypeSystem<ast.Node> types; |
| 67 final Map<ast.Node, TypeInformation> concreteTypes = | 67 final Map<ast.Node, TypeInformation> concreteTypes = |
| 68 new Map<ast.Node, TypeInformation>(); | 68 new Map<ast.Node, TypeInformation>(); |
| 69 | 69 |
| 70 /// Parallel structure for concreteTypes. | 70 /// Parallel structure for concreteTypes. |
| 71 // TODO(efortuna): Remove concreteTypes and/or parameterize InferrerEngine by | 71 // TODO(efortuna): Remove concreteTypes and/or parameterize InferrerEngine by |
| 72 // ir.Node or ast.Node type. Then remove this in favor of `concreteTypes`. | 72 // ir.Node or ast.Node type. Then remove this in favor of `concreteTypes`. |
| 73 final Map<ir.Node, TypeInformation> concreteKernelTypes = | 73 final Map<ir.Node, TypeInformation> concreteKernelTypes = |
| 74 new Map<ir.Node, TypeInformation>(); | 74 new Map<ir.Node, TypeInformation>(); |
| 75 final Set<ConstructorElement> generativeConstructorsExposingThis = | 75 final Set<ConstructorElement> generativeConstructorsExposingThis = |
| 76 new Set<ConstructorElement>(); | 76 new Set<ConstructorElement>(); |
| 77 | 77 |
| 78 /// Data computed internally within elements, like the type-mask of a send a | 78 /// Data computed internally within elements, like the type-mask of a send a |
| 79 /// list allocation, or a for-in loop. | 79 /// list allocation, or a for-in loop. |
| 80 final Map<MemberElement, GlobalTypeInferenceElementData> _memberData = | 80 final Map<MemberElement, GlobalTypeInferenceElementData> _memberData = |
| 81 new Map<MemberElement, GlobalTypeInferenceElementData>(); | 81 new Map<MemberElement, GlobalTypeInferenceElementData>(); |
| 82 | 82 |
| 83 InferrerEngine(this.compiler, ClosedWorld closedWorld, | 83 InferrerEngine(this.compiler, ClosedWorld closedWorld, |
| 84 this.closedWorldRefiner, this.mainElement) | 84 this.closedWorldRefiner, this.mainElement) |
| 85 : this.types = new TypeSystem(closedWorld), | 85 : this.types = new TypeSystem<ast.Node>(closedWorld), |
| 86 this.closedWorld = closedWorld; | 86 this.closedWorld = closedWorld; |
| 87 | 87 |
| 88 CommonElements get commonElements => closedWorld.commonElements; | 88 CommonElements get commonElements => closedWorld.commonElements; |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * Applies [f] to all elements in the universe that match | 91 * Applies [f] to all elements in the universe that match |
| 92 * [selector] and [mask]. If [f] returns false, aborts the iteration. | 92 * [selector] and [mask]. If [f] returns false, aborts the iteration. |
| 93 */ | 93 */ |
| 94 void forEachElementMatching( | 94 void forEachElementMatching( |
| 95 Selector selector, TypeMask mask, bool f(Element element)) { | 95 Selector selector, TypeMask mask, bool f(Element element)) { |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 types.allocatedCalls.add(info); | 940 types.allocatedCalls.add(info); |
| 941 return info; | 941 return info; |
| 942 } | 942 } |
| 943 | 943 |
| 944 /** | 944 /** |
| 945 * Registers a call to await with an expression of type [argumentType] as | 945 * Registers a call to await with an expression of type [argumentType] as |
| 946 * argument. | 946 * argument. |
| 947 */ | 947 */ |
| 948 TypeInformation registerAwait(ast.Node node, TypeInformation argument) { | 948 TypeInformation registerAwait(ast.Node node, TypeInformation argument) { |
| 949 AwaitTypeInformation info = | 949 AwaitTypeInformation info = |
| 950 new AwaitTypeInformation(types.currentMember, node); | 950 new AwaitTypeInformation<ast.Node>(types.currentMember, node); |
| 951 info.addAssignment(argument); | 951 info.addAssignment(argument); |
| 952 types.allocatedTypes.add(info); | 952 types.allocatedTypes.add(info); |
| 953 return info; | 953 return info; |
| 954 } | 954 } |
| 955 | 955 |
| 956 /** | 956 /** |
| 957 * Registers a call to yield with an expression of type [argumentType] as | 957 * Registers a call to yield with an expression of type [argumentType] as |
| 958 * argument. | 958 * argument. |
| 959 */ | 959 */ |
| 960 TypeInformation registerYield(ast.Node node, TypeInformation argument) { | 960 TypeInformation registerYield(ast.Node node, TypeInformation argument) { |
| 961 YieldTypeInformation info = | 961 YieldTypeInformation info = |
| 962 new YieldTypeInformation(types.currentMember, node); | 962 new YieldTypeInformation<ast.Node>(types.currentMember, node); |
| 963 info.addAssignment(argument); | 963 info.addAssignment(argument); |
| 964 types.allocatedTypes.add(info); | 964 types.allocatedTypes.add(info); |
| 965 return info; | 965 return info; |
| 966 } | 966 } |
| 967 | 967 |
| 968 /** | 968 /** |
| 969 * Registers that [caller] calls [closure] with [arguments]. | 969 * Registers that [caller] calls [closure] with [arguments]. |
| 970 * | 970 * |
| 971 * [sideEffects] will be updated to incorporate the potential | 971 * [sideEffects] will be updated to incorporate the potential |
| 972 * callees' side effects. | 972 * callees' side effects. |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 /** | 1116 /** |
| 1117 * Records that the captured variable [local] is read. | 1117 * Records that the captured variable [local] is read. |
| 1118 */ | 1118 */ |
| 1119 void recordCapturedLocalRead(Local local) {} | 1119 void recordCapturedLocalRead(Local local) {} |
| 1120 | 1120 |
| 1121 /** | 1121 /** |
| 1122 * Records that the variable [local] is being updated. | 1122 * Records that the variable [local] is being updated. |
| 1123 */ | 1123 */ |
| 1124 void recordLocalUpdate(Local local, TypeInformation type) {} | 1124 void recordLocalUpdate(Local local, TypeInformation type) {} |
| 1125 } | 1125 } |
| OLD | NEW |