| 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 '../closure.dart' show ClosureConversionTask, ClosureTask; | 8 import '../closure.dart' show ClosureConversionTask, ClosureTask; |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/codegen.dart'; | 10 import '../common/codegen.dart'; |
| 11 import '../common/tasks.dart'; | 11 import '../common/tasks.dart'; |
| 12 import '../common/work.dart'; | 12 import '../common/work.dart'; |
| 13 import '../compiler.dart'; | 13 import '../compiler.dart'; |
| 14 import '../elements/elements.dart'; | 14 import '../elements/elements.dart'; |
| 15 import '../enqueue.dart'; | 15 import '../enqueue.dart'; |
| 16 import '../inferrer/type_graph_inferrer.dart' show AstTypeGraphInferrer; |
| 16 import '../io/multi_information.dart' show MultiSourceInformationStrategy; | 17 import '../io/multi_information.dart' show MultiSourceInformationStrategy; |
| 17 import '../io/position_information.dart' show PositionSourceInformationStrategy; | 18 import '../io/position_information.dart' show PositionSourceInformationStrategy; |
| 18 import '../io/source_information.dart'; | 19 import '../io/source_information.dart'; |
| 19 import '../io/start_end_information.dart' | 20 import '../io/start_end_information.dart' |
| 20 show StartEndSourceInformationStrategy; | 21 show StartEndSourceInformationStrategy; |
| 21 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; | 22 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; |
| 22 import '../js_backend/backend.dart'; | 23 import '../js_backend/backend.dart'; |
| 23 import '../js_backend/native_data.dart'; | 24 import '../js_backend/native_data.dart'; |
| 24 import '../js_emitter/sorter.dart'; | 25 import '../js_emitter/sorter.dart'; |
| 25 import '../resolution/resolution_strategy.dart'; | 26 import '../resolution/resolution_strategy.dart'; |
| 26 import '../ssa/builder.dart'; | 27 import '../ssa/builder.dart'; |
| 27 import '../ssa/rasta_ssa_builder_task.dart'; | 28 import '../ssa/rasta_ssa_builder_task.dart'; |
| 28 import '../ssa/ssa.dart'; | 29 import '../ssa/ssa.dart'; |
| 30 import '../types/types.dart'; |
| 29 import '../options.dart'; | 31 import '../options.dart'; |
| 30 import '../universe/world_builder.dart'; | 32 import '../universe/world_builder.dart'; |
| 31 import '../universe/world_impact.dart'; | 33 import '../universe/world_impact.dart'; |
| 32 import '../world.dart'; | 34 import '../world.dart'; |
| 33 | 35 |
| 34 /// Strategy for using the [Element] model from the resolver as the backend | 36 /// Strategy for using the [Element] model from the resolver as the backend |
| 35 /// model. | 37 /// model. |
| 36 class ElementBackendStrategy extends ComputeSpannableMixin | 38 class ElementBackendStrategy extends ComputeSpannableMixin |
| 37 implements BackendStrategy { | 39 implements BackendStrategy { |
| 38 final Compiler _compiler; | 40 final Compiler _compiler; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 const StartEndSourceInformationStrategy(), | 100 const StartEndSourceInformationStrategy(), |
| 99 const PositionSourceInformationStrategy() | 101 const PositionSourceInformationStrategy() |
| 100 ]); | 102 ]); |
| 101 } | 103 } |
| 102 } else if (useNewSourceInfo) { | 104 } else if (useNewSourceInfo) { |
| 103 return const PositionSourceInformationStrategy(); | 105 return const PositionSourceInformationStrategy(); |
| 104 } else { | 106 } else { |
| 105 return const StartEndSourceInformationStrategy(); | 107 return const StartEndSourceInformationStrategy(); |
| 106 } | 108 } |
| 107 } | 109 } |
| 110 |
| 111 @override |
| 112 GlobalTypeInferenceResults createTypesInferrerResults( |
| 113 TypesInferrer typesInferrer, ClosedWorld closedWorld) { |
| 114 return new AstGlobalTypeInferenceResults(typesInferrer, closedWorld); |
| 115 } |
| 116 |
| 117 @override |
| 118 TypesInferrer createTypesInferrer(ClosedWorldRefiner closedWorldRefiner, |
| 119 {bool disableTypeInference: false}) { |
| 120 return new AstTypeGraphInferrer( |
| 121 _compiler, closedWorldRefiner.closedWorld, closedWorldRefiner, |
| 122 disableTypeInference: disableTypeInference); |
| 123 } |
| 108 } | 124 } |
| 109 | 125 |
| 110 /// Builder that creates the work item necessary for the code generation of a | 126 /// Builder that creates the work item necessary for the code generation of a |
| 111 /// [MemberElement]. | 127 /// [MemberElement]. |
| 112 class ElementCodegenWorkItemBuilder extends WorkItemBuilder { | 128 class ElementCodegenWorkItemBuilder extends WorkItemBuilder { |
| 113 final JavaScriptBackend _backend; | 129 final JavaScriptBackend _backend; |
| 114 final ClosedWorld _closedWorld; | 130 final ClosedWorld _closedWorld; |
| 115 final CompilerOptions _options; | 131 final CompilerOptions _options; |
| 116 | 132 |
| 117 ElementCodegenWorkItemBuilder( | 133 ElementCodegenWorkItemBuilder( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 176 |
| 161 MemberElement get element => resolvedAst.element; | 177 MemberElement get element => resolvedAst.element; |
| 162 | 178 |
| 163 WorldImpact run() { | 179 WorldImpact run() { |
| 164 registry = new CodegenRegistry(_closedWorld.elementEnvironment, element); | 180 registry = new CodegenRegistry(_closedWorld.elementEnvironment, element); |
| 165 return _backend.codegen(this, _closedWorld); | 181 return _backend.codegen(this, _closedWorld); |
| 166 } | 182 } |
| 167 | 183 |
| 168 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; | 184 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; |
| 169 } | 185 } |
| OLD | NEW |