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.js_backend.element_strategy; | 5 library dart2js.js_backend.element_strategy; |
6 | 6 |
7 import '../backend_strategy.dart'; | 7 import '../backend_strategy.dart'; |
8 import '../common.dart'; | 8 import '../common.dart'; |
9 import '../common/codegen.dart'; | 9 import '../common/codegen.dart'; |
10 import '../common/work.dart'; | 10 import '../common/work.dart'; |
11 import '../compiler.dart'; | 11 import '../compiler.dart'; |
12 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
13 import '../enqueue.dart'; | 13 import '../enqueue.dart'; |
| 14 import '../io/source_information.dart'; |
14 import '../js_backend/backend.dart'; | 15 import '../js_backend/backend.dart'; |
15 import '../js_backend/native_data.dart'; | 16 import '../js_backend/native_data.dart'; |
16 import '../js_emitter/sorter.dart'; | 17 import '../js_emitter/sorter.dart'; |
| 18 import '../ssa/builder.dart'; |
| 19 import '../ssa/builder_kernel.dart'; |
| 20 import '../ssa/ssa.dart'; |
17 import '../options.dart'; | 21 import '../options.dart'; |
18 import '../universe/world_builder.dart'; | 22 import '../universe/world_builder.dart'; |
19 import '../universe/world_impact.dart'; | 23 import '../universe/world_impact.dart'; |
20 import '../world.dart'; | 24 import '../world.dart'; |
21 | 25 |
22 /// Strategy for using the [Element] model from the resolver as the backend | 26 /// Strategy for using the [Element] model from the resolver as the backend |
23 /// model. | 27 /// model. |
24 class ElementBackendStrategy implements BackendStrategy { | 28 class ElementBackendStrategy implements BackendStrategy { |
25 final Compiler _compiler; | 29 final Compiler _compiler; |
26 | 30 |
(...skipping 19 matching lines...) Expand all Loading... |
46 closedWorld, | 50 closedWorld, |
47 _compiler.backend.constants, | 51 _compiler.backend.constants, |
48 selectorConstraintsStrategy); | 52 selectorConstraintsStrategy); |
49 } | 53 } |
50 | 54 |
51 @override | 55 @override |
52 WorkItemBuilder createCodegenWorkItemBuilder(ClosedWorld closedWorld) { | 56 WorkItemBuilder createCodegenWorkItemBuilder(ClosedWorld closedWorld) { |
53 return new ElementCodegenWorkItemBuilder( | 57 return new ElementCodegenWorkItemBuilder( |
54 _compiler.backend, closedWorld, _compiler.options); | 58 _compiler.backend, closedWorld, _compiler.options); |
55 } | 59 } |
| 60 |
| 61 @override |
| 62 SsaBuilderTask createSsaBuilderTask(JavaScriptBackend backend, |
| 63 SourceInformationStrategy sourceInformationStrategy) { |
| 64 return _compiler.options.useKernel |
| 65 ? new SsaAstKernelBuilderTask(backend, sourceInformationStrategy) |
| 66 : new SsaAstBuilderTask(backend, sourceInformationStrategy); |
| 67 } |
56 } | 68 } |
57 | 69 |
58 /// Builder that creates the work item necessary for the code generation of a | 70 /// Builder that creates the work item necessary for the code generation of a |
59 /// [MemberElement]. | 71 /// [MemberElement]. |
60 class ElementCodegenWorkItemBuilder extends WorkItemBuilder { | 72 class ElementCodegenWorkItemBuilder extends WorkItemBuilder { |
61 final JavaScriptBackend _backend; | 73 final JavaScriptBackend _backend; |
62 final ClosedWorld _closedWorld; | 74 final ClosedWorld _closedWorld; |
63 final CompilerOptions _options; | 75 final CompilerOptions _options; |
64 | 76 |
65 ElementCodegenWorkItemBuilder( | 77 ElementCodegenWorkItemBuilder( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 120 |
109 MemberElement get element => resolvedAst.element; | 121 MemberElement get element => resolvedAst.element; |
110 | 122 |
111 WorldImpact run() { | 123 WorldImpact run() { |
112 registry = new CodegenRegistry(element); | 124 registry = new CodegenRegistry(element); |
113 return _backend.codegen(this, _closedWorld); | 125 return _backend.codegen(this, _closedWorld); |
114 } | 126 } |
115 | 127 |
116 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; | 128 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; |
117 } | 129 } |
OLD | NEW |