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.frontend_strategy; | 5 library dart2js.frontend_strategy; |
6 | 6 |
7 import 'common.dart'; | 7 import 'common.dart'; |
8 import 'common_elements.dart'; | 8 import 'common_elements.dart'; |
9 import 'common/backend_api.dart'; | 9 import 'common/backend_api.dart'; |
10 import 'common/tasks.dart'; | 10 import 'common/tasks.dart'; |
11 import 'elements/entities.dart'; | 11 import 'elements/entities.dart'; |
12 import 'elements/types.dart'; | 12 import 'elements/types.dart'; |
13 import 'environment.dart'; | 13 import 'environment.dart'; |
14 import 'enqueue.dart'; | 14 import 'enqueue.dart'; |
15 import 'js_backend/backend.dart'; | 15 import 'js_backend/backend.dart'; |
16 import 'js_backend/backend_usage.dart'; | 16 import 'js_backend/backend_usage.dart'; |
17 import 'js_backend/interceptor_data.dart'; | 17 import 'js_backend/interceptor_data.dart'; |
18 import 'js_backend/mirrors_analysis.dart'; | 18 import 'js_backend/mirrors_analysis.dart'; |
19 import 'js_backend/mirrors_data.dart'; | 19 import 'js_backend/mirrors_data.dart'; |
20 import 'js_backend/native_data.dart'; | 20 import 'js_backend/native_data.dart'; |
21 import 'js_backend/no_such_method_registry.dart'; | 21 import 'js_backend/no_such_method_registry.dart'; |
22 import 'js_backend/runtime_types.dart'; | 22 import 'js_backend/runtime_types.dart'; |
23 import 'library_loader.dart'; | 23 import 'library_loader.dart'; |
| 24 import 'native/enqueue.dart' show NativeResolutionEnqueuer; |
24 import 'native/resolver.dart'; | 25 import 'native/resolver.dart'; |
25 import 'serialization/task.dart'; | 26 import 'serialization/task.dart'; |
26 import 'patch_parser.dart'; | 27 import 'patch_parser.dart'; |
27 import 'resolved_uri_translator.dart'; | 28 import 'resolved_uri_translator.dart'; |
28 import 'universe/world_builder.dart'; | 29 import 'universe/world_builder.dart'; |
29 import 'universe/world_impact.dart'; | 30 import 'universe/world_impact.dart'; |
30 | 31 |
31 /// Strategy pattern that defines the connection between the input format and | 32 /// Strategy pattern that defines the connection between the input format and |
32 /// the resolved element model. | 33 /// the resolved element model. |
33 abstract class FrontendStrategy { | 34 abstract class FrontendStrategy { |
(...skipping 16 matching lines...) Expand all Loading... |
50 /// Returns the [CommonElements] for the element model used in this | 51 /// Returns the [CommonElements] for the element model used in this |
51 /// strategy. | 52 /// strategy. |
52 CommonElements get commonElements; | 53 CommonElements get commonElements; |
53 | 54 |
54 /// Returns the [DartTypes] for the element model used in this strategy. | 55 /// Returns the [DartTypes] for the element model used in this strategy. |
55 DartTypes get dartTypes; | 56 DartTypes get dartTypes; |
56 | 57 |
57 /// Returns the [AnnotationProcessor] for this strategy. | 58 /// Returns the [AnnotationProcessor] for this strategy. |
58 AnnotationProcessor get annotationProcesser; | 59 AnnotationProcessor get annotationProcesser; |
59 | 60 |
| 61 NativeBasicData get nativeBasicData; |
| 62 |
60 /// Creates the [NativeClassFinder] for this strategy. | 63 /// Creates the [NativeClassFinder] for this strategy. |
61 NativeClassFinder createNativeClassFinder(NativeBasicData nativeBasicData); | 64 NativeClassFinder createNativeClassFinder(NativeBasicData nativeBasicData); |
62 | 65 |
63 /// Creates the [NoSuchMethodResolver] corresponding the resolved model of | 66 /// Creates the [NoSuchMethodResolver] corresponding the resolved model of |
64 /// this strategy. | 67 /// this strategy. |
65 NoSuchMethodResolver createNoSuchMethodResolver(); | 68 NoSuchMethodResolver createNoSuchMethodResolver(); |
66 | 69 |
67 /// Creates the [ResolutionWorldBuilder] corresponding to the element model | 70 /// Creates the [ResolutionWorldBuilder] corresponding to the element model |
68 /// used in this strategy. | 71 /// used in this strategy. |
69 ResolutionWorldBuilder createResolutionWorldBuilder( | 72 ResolutionWorldBuilder createResolutionWorldBuilder( |
70 NativeBasicData nativeBasicData, | 73 NativeBasicData nativeBasicData, |
71 NativeDataBuilder nativeDataBuilder, | 74 NativeDataBuilder nativeDataBuilder, |
72 InterceptorDataBuilder interceptorDataBuilder, | 75 InterceptorDataBuilder interceptorDataBuilder, |
73 BackendUsageBuilder backendUsageBuilder, | 76 BackendUsageBuilder backendUsageBuilder, |
| 77 RuntimeTypesNeedBuilder rtiNeedBuilder, |
| 78 NativeResolutionEnqueuer nativeResolutionEnqueuer, |
74 SelectorConstraintsStrategy selectorConstraintsStrategy); | 79 SelectorConstraintsStrategy selectorConstraintsStrategy); |
75 | 80 |
76 /// Creates the [WorkItemBuilder] corresponding to how a resolved model for | 81 /// Creates the [WorkItemBuilder] corresponding to how a resolved model for |
77 /// a single member is obtained in this strategy. | 82 /// a single member is obtained in this strategy. |
78 WorkItemBuilder createResolutionWorkItemBuilder( | 83 WorkItemBuilder createResolutionWorkItemBuilder( |
79 NativeBasicData nativeBasicData, | 84 NativeBasicData nativeBasicData, |
80 NativeDataBuilder nativeDataBuilder, | 85 NativeDataBuilder nativeDataBuilder, |
81 ImpactTransformer impactTransformer); | 86 ImpactTransformer impactTransformer); |
82 | 87 |
83 /// Computes the main function from [mainLibrary] adding additional world | 88 /// Computes the main function from [mainLibrary] adding additional world |
(...skipping 13 matching lines...) Expand all Loading... |
97 | 102 |
98 /// Creates the [RuntimeTypesNeedBuilder] for this strategy. | 103 /// Creates the [RuntimeTypesNeedBuilder] for this strategy. |
99 RuntimeTypesNeedBuilder createRuntimeTypesNeedBuilder(); | 104 RuntimeTypesNeedBuilder createRuntimeTypesNeedBuilder(); |
100 | 105 |
101 /// Creates a [SourceSpan] from [spannable] in context of [currentElement]. | 106 /// Creates a [SourceSpan] from [spannable] in context of [currentElement]. |
102 SourceSpan spanFromSpannable(Spannable spannable, Entity currentElement); | 107 SourceSpan spanFromSpannable(Spannable spannable, Entity currentElement); |
103 } | 108 } |
104 | 109 |
105 /// Class that performs the mechanics to investigate annotations in the code. | 110 /// Class that performs the mechanics to investigate annotations in the code. |
106 abstract class AnnotationProcessor { | 111 abstract class AnnotationProcessor { |
107 void extractNativeAnnotations( | 112 void extractNativeAnnotations(LibraryEntity library); |
108 LibraryEntity library, NativeBasicDataBuilder nativeBasicDataBuilder); | |
109 | 113 |
110 void extractJsInteropAnnotations( | 114 void extractJsInteropAnnotations(LibraryEntity library); |
111 LibraryEntity library, NativeBasicDataBuilder nativeBasicDataBuilder); | |
112 | 115 |
113 void processJsInteropAnnotations( | 116 void processJsInteropAnnotations( |
114 NativeBasicData nativeBasicData, NativeDataBuilder nativeDataBuilder); | 117 NativeBasicData nativeBasicData, NativeDataBuilder nativeDataBuilder); |
115 } | 118 } |
| 119 |
| 120 abstract class FrontendStrategyBase implements FrontendStrategy { |
| 121 final NativeBasicDataBuilderImpl nativeBasicDataBuilder = |
| 122 new NativeBasicDataBuilderImpl(); |
| 123 NativeBasicData _nativeBasicData; |
| 124 |
| 125 NativeBasicData get nativeBasicData { |
| 126 if (_nativeBasicData == null) { |
| 127 _nativeBasicData = nativeBasicDataBuilder.close(elementEnvironment); |
| 128 assert( |
| 129 _nativeBasicData != null, |
| 130 failedAt(NO_LOCATION_SPANNABLE, |
| 131 "NativeBasicData has not been computed yet.")); |
| 132 } |
| 133 return _nativeBasicData; |
| 134 } |
| 135 } |
OLD | NEW |