OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library type_graph_inferrer; | 5 library type_graph_inferrer; |
6 | 6 |
7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
8 | 8 |
9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 final ClosedWorldRefiner closedWorldRefiner; | 56 final ClosedWorldRefiner closedWorldRefiner; |
57 | 57 |
58 TypeGraphInferrer(this.compiler, this.closedWorld, this.closedWorldRefiner); | 58 TypeGraphInferrer(this.compiler, this.closedWorld, this.closedWorldRefiner); |
59 | 59 |
60 String get name => 'Graph inferrer'; | 60 String get name => 'Graph inferrer'; |
61 | 61 |
62 CommonMasks get commonMasks => closedWorld.commonMasks; | 62 CommonMasks get commonMasks => closedWorld.commonMasks; |
63 | 63 |
64 TypeMask get _dynamicType => commonMasks.dynamicType; | 64 TypeMask get _dynamicType => commonMasks.dynamicType; |
65 | 65 |
66 void analyzeMain(Element main) { | 66 void analyzeMain(FunctionEntity main) { |
67 inferrer = | 67 inferrer = |
68 new InferrerEngine(compiler, closedWorld, closedWorldRefiner, main); | 68 new InferrerEngine(compiler, closedWorld, closedWorldRefiner, main); |
69 inferrer.runOverAllElements(); | 69 inferrer.runOverAllElements(); |
70 } | 70 } |
71 | 71 |
72 TypeMask getReturnTypeOfElement(Element element) { | 72 TypeMask getReturnTypeOfElement(Element element) { |
73 if (compiler.disableTypeInference) return _dynamicType; | 73 if (compiler.disableTypeInference) return _dynamicType; |
74 // Currently, closure calls return dynamic. | 74 // Currently, closure calls return dynamic. |
75 if (element is! FunctionElement) return _dynamicType; | 75 if (element is! FunctionElement) return _dynamicType; |
76 return inferrer.types.getInferredTypeOf(element).type; | 76 return inferrer.types.getInferredTypeOf(element).type; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 bool isCalledOnce(Element element) { | 136 bool isCalledOnce(Element element) { |
137 if (compiler.disableTypeInference) return false; | 137 if (compiler.disableTypeInference) return false; |
138 MemberTypeInformation info = inferrer.types.getInferredTypeOf(element); | 138 MemberTypeInformation info = inferrer.types.getInferredTypeOf(element); |
139 return info.isCalledOnce(); | 139 return info.isCalledOnce(); |
140 } | 140 } |
141 | 141 |
142 void clear() { | 142 void clear() { |
143 inferrer.clear(); | 143 inferrer.clear(); |
144 } | 144 } |
145 } | 145 } |
OLD | NEW |