OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 types; | 5 library types; |
6 | 6 |
7 import '../closure.dart' show SynthesizedCallMethodElementX; | 7 import '../closure.dart' show SynthesizedCallMethodElementX; |
8 import '../common.dart' show invariant; | 8 import '../common.dart' show invariant; |
9 import '../common/tasks.dart' show CompilerTask; | 9 import '../common/tasks.dart' show CompilerTask; |
10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
11 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
| 12 import '../elements/entities.dart'; |
12 import '../inferrer/type_graph_inferrer.dart' show TypeGraphInferrer; | 13 import '../inferrer/type_graph_inferrer.dart' show TypeGraphInferrer; |
13 import '../inferrer/type_system.dart'; | 14 import '../inferrer/type_system.dart'; |
14 import '../tree/tree.dart'; | 15 import '../tree/tree.dart'; |
15 import '../universe/selector.dart' show Selector; | 16 import '../universe/selector.dart' show Selector; |
16 import '../util/util.dart' show Maplet; | 17 import '../util/util.dart' show Maplet; |
17 import '../world.dart' show ClosedWorld, ClosedWorldRefiner; | 18 import '../world.dart' show ClosedWorld, ClosedWorldRefiner; |
18 | 19 |
19 import 'masks.dart'; | 20 import 'masks.dart'; |
20 export 'masks.dart'; | 21 export 'masks.dart'; |
21 | 22 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 _set(node.forToken, mask); | 165 _set(node.forToken, mask); |
165 } | 166 } |
166 | 167 |
167 void setCurrentTypeMask(ForIn node, TypeMask mask) { | 168 void setCurrentTypeMask(ForIn node, TypeMask mask) { |
168 _set(node.inToken, mask); | 169 _set(node.inToken, mask); |
169 } | 170 } |
170 } | 171 } |
171 | 172 |
172 /// API to interact with the global type-inference engine. | 173 /// API to interact with the global type-inference engine. |
173 abstract class TypesInferrer { | 174 abstract class TypesInferrer { |
174 void analyzeMain(Element element); | 175 void analyzeMain(FunctionEntity element); |
175 TypeMask getReturnTypeOfElement(Element element); | 176 TypeMask getReturnTypeOfElement(Element element); |
176 TypeMask getTypeOfElement(Element element); | 177 TypeMask getTypeOfElement(Element element); |
177 TypeMask getTypeForNewList(Element owner, Node node); | 178 TypeMask getTypeForNewList(Element owner, Node node); |
178 TypeMask getTypeOfSelector(Selector selector, TypeMask mask); | 179 TypeMask getTypeOfSelector(Selector selector, TypeMask mask); |
179 void clear(); | 180 void clear(); |
180 bool isCalledOnce(Element element); | 181 bool isCalledOnce(Element element); |
181 bool isFixedArrayCheckedForGrowable(Node node); | 182 bool isFixedArrayCheckedForGrowable(Node node); |
182 } | 183 } |
183 | 184 |
184 /// Results produced by the global type-inference algorithm. | 185 /// Results produced by the global type-inference algorithm. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 /// accessed from outside this class for testing only. | 265 /// accessed from outside this class for testing only. |
265 TypeGraphInferrer typesInferrerInternal; | 266 TypeGraphInferrer typesInferrerInternal; |
266 | 267 |
267 GlobalTypeInferenceResults results; | 268 GlobalTypeInferenceResults results; |
268 | 269 |
269 GlobalTypeInferenceTask(Compiler compiler) | 270 GlobalTypeInferenceTask(Compiler compiler) |
270 : compiler = compiler, | 271 : compiler = compiler, |
271 super(compiler.measurer); | 272 super(compiler.measurer); |
272 | 273 |
273 /// Runs the global type-inference algorithm once. | 274 /// Runs the global type-inference algorithm once. |
274 void runGlobalTypeInference(MethodElement mainElement, | 275 void runGlobalTypeInference(FunctionEntity mainElement, |
275 ClosedWorld closedWorld, ClosedWorldRefiner closedWorldRefiner) { | 276 ClosedWorld closedWorld, ClosedWorldRefiner closedWorldRefiner) { |
276 measure(() { | 277 measure(() { |
277 typesInferrerInternal ??= | 278 typesInferrerInternal ??= |
278 new TypeGraphInferrer(compiler, closedWorld, closedWorldRefiner); | 279 new TypeGraphInferrer(compiler, closedWorld, closedWorldRefiner); |
279 typesInferrerInternal.analyzeMain(mainElement); | 280 typesInferrerInternal.analyzeMain(mainElement); |
280 typesInferrerInternal.clear(); | 281 typesInferrerInternal.clear(); |
281 results = new GlobalTypeInferenceResults(typesInferrerInternal, | 282 results = new GlobalTypeInferenceResults(typesInferrerInternal, |
282 closedWorld, typesInferrerInternal.inferrer.types); | 283 closedWorld, typesInferrerInternal.inferrer.types); |
283 }); | 284 }); |
284 } | 285 } |
285 } | 286 } |
OLD | NEW |