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_model.strategy; | 5 library dart2js.js_model.strategy; |
6 | 6 |
7 import '../closure.dart' show ClosureConversionTask; | 7 import '../closure.dart' show ClosureConversionTask; |
8 import '../common/tasks.dart'; | 8 import '../common/tasks.dart'; |
9 import '../common_elements.dart'; | 9 import '../common_elements.dart'; |
10 import '../compiler.dart'; | 10 import '../compiler.dart'; |
(...skipping 16 matching lines...) Expand all Loading... |
27 import '../universe/class_set.dart'; | 27 import '../universe/class_set.dart'; |
28 import '../universe/world_builder.dart'; | 28 import '../universe/world_builder.dart'; |
29 import '../util/emptyset.dart'; | 29 import '../util/emptyset.dart'; |
30 import '../world.dart'; | 30 import '../world.dart'; |
31 import 'closure.dart'; | 31 import 'closure.dart'; |
32 import 'elements.dart'; | 32 import 'elements.dart'; |
33 import 'locals.dart'; | 33 import 'locals.dart'; |
34 | 34 |
35 class JsBackendStrategy implements KernelBackendStrategy { | 35 class JsBackendStrategy implements KernelBackendStrategy { |
36 final Compiler _compiler; | 36 final Compiler _compiler; |
37 final JsToFrontendMap _map = new JsToFrontendMapImpl(); | |
38 ElementEnvironment _elementEnvironment; | 37 ElementEnvironment _elementEnvironment; |
39 CommonElements _commonElements; | 38 CommonElements _commonElements; |
40 KernelToElementMapForBuilding _elementMap; | 39 JsKernelToElementMap _elementMap; |
41 ClosureConversionTask _closureDataLookup; | 40 ClosureConversionTask _closureDataLookup; |
42 final GlobalLocalsMap _globalLocalsMap = new GlobalLocalsMap(); | 41 final GlobalLocalsMap _globalLocalsMap = new GlobalLocalsMap(); |
43 Sorter _sorter; | 42 Sorter _sorter; |
44 | 43 |
45 JsBackendStrategy(this._compiler); | 44 JsBackendStrategy(this._compiler); |
46 | 45 |
47 KernelToElementMapForBuilding get elementMap { | 46 KernelToElementMapForBuilding get elementMap { |
48 if (_elementMap == null) { | 47 assert(_elementMap != null, |
49 KernelFrontEndStrategy strategy = _compiler.frontendStrategy; | 48 "JsBackendStrategy.elementMap has not been created yet."); |
50 KernelToElementMapForImpact elementMap = strategy.elementMap; | |
51 _elementMap = new JsKernelToElementMap( | |
52 _compiler.reporter, | |
53 _compiler.environment, | |
54 _map, | |
55 _elementEnvironment, | |
56 _commonElements, | |
57 elementMap); | |
58 } | |
59 return _elementMap; | 49 return _elementMap; |
60 } | 50 } |
61 | 51 |
62 GlobalLocalsMap get globalLocalsMapForTesting => _globalLocalsMap; | 52 GlobalLocalsMap get globalLocalsMapForTesting => _globalLocalsMap; |
63 | 53 |
64 @override | 54 @override |
65 ClosedWorldRefiner createClosedWorldRefiner(ClosedWorld closedWorld) { | 55 ClosedWorldRefiner createClosedWorldRefiner(ClosedWorld closedWorld) { |
66 _elementEnvironment = | 56 KernelFrontEndStrategy strategy = _compiler.frontendStrategy; |
67 new JsElementEnvironment(_map, closedWorld.elementEnvironment); | 57 KernelToElementMapForImpact elementMap = strategy.elementMap; |
68 _commonElements = new JsCommonElements(_map, closedWorld.commonElements); | 58 _elementMap = new JsKernelToElementMap( |
| 59 _compiler.reporter, _compiler.environment, elementMap); |
| 60 _elementEnvironment = _elementMap.elementEnvironment; |
| 61 _commonElements = _elementMap.commonElements; |
| 62 JsToFrontendMap _map = _elementMap.jsToFrontendMap; |
69 BackendUsage backendUsage = | 63 BackendUsage backendUsage = |
70 new JsBackendUsage(_map, closedWorld.backendUsage); | 64 new JsBackendUsage(_map, closedWorld.backendUsage); |
71 NativeData nativeData = new JsNativeData(_map, closedWorld.nativeData); | 65 NativeData nativeData = new JsNativeData(_map, closedWorld.nativeData); |
72 InterceptorData interceptorData = new InterceptorDataImpl( | 66 InterceptorData interceptorData = new InterceptorDataImpl( |
73 nativeData, | 67 nativeData, |
74 _commonElements, | 68 _commonElements, |
75 // TODO(johnniwinther): Convert these. | 69 // TODO(johnniwinther): Convert these. |
76 const {}, | 70 const {}, |
77 new Set(), | 71 new Set(), |
78 new Set()); | 72 new Set()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ClosedWorld closedWorld, | 158 ClosedWorld closedWorld, |
165 SelectorConstraintsStrategy selectorConstraintsStrategy) { | 159 SelectorConstraintsStrategy selectorConstraintsStrategy) { |
166 return new KernelCodegenWorldBuilder( | 160 return new KernelCodegenWorldBuilder( |
167 elementMap, | 161 elementMap, |
168 closedWorld.elementEnvironment, | 162 closedWorld.elementEnvironment, |
169 nativeBasicData, | 163 nativeBasicData, |
170 closedWorld, | 164 closedWorld, |
171 selectorConstraintsStrategy); | 165 selectorConstraintsStrategy); |
172 } | 166 } |
173 } | 167 } |
OLD | NEW |