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 '../inferrer/type_graph_inferrer.dart' | 12 import '../inferrer/type_graph_inferrer.dart' |
13 show TypeGraphInferrer, TypeInformationSystem; | 13 show TypeGraphInferrer, TypeInformationSystem; |
14 import '../tree/tree.dart'; | 14 import '../tree/tree.dart'; |
15 import '../universe/selector.dart' show Selector; | 15 import '../universe/selector.dart' show Selector; |
16 import '../util/util.dart' show Maplet; | 16 import '../util/util.dart' show Maplet; |
| 17 import '../world.dart' show ClosedWorld, ClosedWorldRefiner; |
17 | 18 |
18 import 'masks.dart'; | 19 import 'masks.dart'; |
19 export 'masks.dart'; | 20 export 'masks.dart'; |
20 | 21 |
21 /// Results about a single element (e.g. a method, parameter, or field) | 22 /// Results about a single element (e.g. a method, parameter, or field) |
22 /// produced by the global type-inference algorithm. | 23 /// produced by the global type-inference algorithm. |
23 /// | 24 /// |
24 /// All queries in this class may contain results that assume whole-program | 25 /// All queries in this class may contain results that assume whole-program |
25 /// closed-world semantics. Any [TypeMask] for an element or node that we return | 26 /// closed-world semantics. Any [TypeMask] for an element or node that we return |
26 /// was inferred to be a "guaranteed type", that means, it is a type that we | 27 /// was inferred to be a "guaranteed type", that means, it is a type that we |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 /// accessed from outside this class for testing only. | 239 /// accessed from outside this class for testing only. |
239 TypeGraphInferrer typesInferrerInternal; | 240 TypeGraphInferrer typesInferrerInternal; |
240 | 241 |
241 GlobalTypeInferenceResults results; | 242 GlobalTypeInferenceResults results; |
242 | 243 |
243 GlobalTypeInferenceTask(Compiler compiler) | 244 GlobalTypeInferenceTask(Compiler compiler) |
244 : compiler = compiler, | 245 : compiler = compiler, |
245 super(compiler.measurer); | 246 super(compiler.measurer); |
246 | 247 |
247 /// Runs the global type-inference algorithm once. | 248 /// Runs the global type-inference algorithm once. |
248 void runGlobalTypeInference(Element mainElement) { | 249 void runGlobalTypeInference(Element mainElement, ClosedWorld closedWorld, |
| 250 ClosedWorldRefiner closedWorldRefiner) { |
249 measure(() { | 251 measure(() { |
250 CommonMasks masks = compiler.closedWorld.commonMasks; | 252 typesInferrerInternal ??= |
251 typesInferrerInternal ??= new TypeGraphInferrer(compiler, masks); | 253 new TypeGraphInferrer(compiler, closedWorld, closedWorldRefiner); |
252 typesInferrerInternal.analyzeMain(mainElement); | 254 typesInferrerInternal.analyzeMain(mainElement); |
253 typesInferrerInternal.clear(); | 255 typesInferrerInternal.clear(); |
254 results = new GlobalTypeInferenceResults(typesInferrerInternal, compiler, | 256 results = new GlobalTypeInferenceResults(typesInferrerInternal, compiler, |
255 masks, typesInferrerInternal.inferrer.types); | 257 closedWorld.commonMasks, typesInferrerInternal.inferrer.types); |
256 }); | 258 }); |
257 } | 259 } |
258 } | 260 } |
OLD | NEW |