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 library dart2js.backend_strategy; | 5 library dart2js.backend_strategy; |
6 | 6 |
7 import 'compiler.dart'; | 7 import 'enqueue.dart'; |
| 8 import 'js_backend/native_data.dart'; |
8 import 'js_emitter/sorter.dart'; | 9 import 'js_emitter/sorter.dart'; |
| 10 import 'universe/world_builder.dart'; |
9 import 'world.dart'; | 11 import 'world.dart'; |
10 | 12 |
11 /// Strategy pattern that defines the element model used in type inference | 13 /// Strategy pattern that defines the element model used in type inference |
12 /// and code generation. | 14 /// and code generation. |
13 abstract class BackendStrategy { | 15 abstract class BackendStrategy { |
14 /// Create the [ClosedWorldRefiner] for [closedWorld]. | 16 /// Create the [ClosedWorldRefiner] for [closedWorld]. |
15 ClosedWorldRefiner createClosedWorldRefiner(ClosedWorld closedWorld); | 17 ClosedWorldRefiner createClosedWorldRefiner(ClosedWorld closedWorld); |
16 | 18 |
17 /// Create closure classes for local functions. | 19 /// Create closure classes for local functions. |
18 void convertClosures(ClosedWorldRefiner closedWorldRefiner); | 20 void convertClosures(ClosedWorldRefiner closedWorldRefiner); |
19 | 21 |
20 /// The [Sorter] used for sorting elements in the generated code. | 22 /// The [Sorter] used for sorting elements in the generated code. |
21 Sorter get sorter; | 23 Sorter get sorter; |
| 24 |
| 25 /// Creates the [CodegenWorldBuilder] used by the codegen enqueuer. |
| 26 CodegenWorldBuilder createCodegenWorldBuilder( |
| 27 NativeBasicData nativeBasicData, |
| 28 ClosedWorld closedWorld, |
| 29 SelectorConstraintsStrategy selectorConstraintsStrategy); |
| 30 |
| 31 /// Creates the [WorkItemBuilder] used by the codegen enqueuer. |
| 32 WorkItemBuilder createCodegenWorkItemBuilder(ClosedWorld closedWorld); |
22 } | 33 } |
23 | |
24 /// Strategy for using the [Element] model from the resolver as the backend | |
25 /// model. | |
26 class ElementBackendStrategy implements BackendStrategy { | |
27 final Compiler _compiler; | |
28 | |
29 ElementBackendStrategy(this._compiler); | |
30 | |
31 ClosedWorldRefiner createClosedWorldRefiner(ClosedWorldImpl closedWorld) => | |
32 closedWorld; | |
33 | |
34 Sorter get sorter => const ElementSorter(); | |
35 | |
36 void convertClosures(ClosedWorldRefiner closedWorldRefiner) { | |
37 _compiler.closureToClassMapper.createClosureClasses(closedWorldRefiner); | |
38 } | |
39 } | |
OLD | NEW |