| 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 'environment.dart'; | 12 import 'environment.dart'; |
| 13 import 'enqueue.dart'; | 13 import 'enqueue.dart'; |
| 14 import 'js_backend/backend.dart'; | 14 import 'js_backend/backend.dart'; |
| 15 import 'js_backend/backend_usage.dart'; | 15 import 'js_backend/backend_usage.dart'; |
| 16 import 'js_backend/custom_elements_analysis.dart'; | 16 import 'js_backend/custom_elements_analysis.dart'; |
| 17 import 'js_backend/mirrors_analysis.dart'; | 17 import 'js_backend/mirrors_analysis.dart'; |
| 18 import 'js_backend/mirrors_data.dart'; | 18 import 'js_backend/mirrors_data.dart'; |
| 19 import 'js_backend/native_data.dart'; | 19 import 'js_backend/native_data.dart'; |
| 20 import 'js_backend/no_such_method_registry.dart'; | 20 import 'js_backend/no_such_method_registry.dart'; |
| 21 import 'library_loader.dart'; | 21 import 'library_loader.dart'; |
| 22 import 'native/resolver.dart'; | 22 import 'native/resolver.dart'; |
| 23 import 'serialization/task.dart'; | 23 import 'serialization/task.dart'; |
| 24 import 'patch_parser.dart'; | 24 import 'patch_parser.dart'; |
| 25 import 'resolved_uri_translator.dart'; | 25 import 'resolved_uri_translator.dart'; |
| 26 import 'universe/world_builder.dart'; | 26 import 'universe/world_builder.dart'; |
| 27 import 'universe/world_impact.dart'; |
| 27 | 28 |
| 28 /// Strategy pattern that defines the connection between the input format and | 29 /// Strategy pattern that defines the connection between the input format and |
| 29 /// the resolved element model. | 30 /// the resolved element model. |
| 30 abstract class FrontEndStrategy { | 31 abstract class FrontEndStrategy { |
| 31 /// Creates library loader task for this strategy. | 32 /// Creates library loader task for this strategy. |
| 32 LibraryLoaderTask createLibraryLoader( | 33 LibraryLoaderTask createLibraryLoader( |
| 33 ResolvedUriTranslator uriTranslator, | 34 ResolvedUriTranslator uriTranslator, |
| 34 ScriptLoader scriptLoader, | 35 ScriptLoader scriptLoader, |
| 35 ElementScanner scriptScanner, | 36 ElementScanner scriptScanner, |
| 36 LibraryDeserializer deserializer, | 37 LibraryDeserializer deserializer, |
| 37 PatchResolverFunction patchResolverFunc, | 38 PatchResolverFunction patchResolverFunc, |
| 38 PatchParserTask patchParser, | 39 PatchParserTask patchParser, |
| 39 Environment environment, | 40 Environment environment, |
| 40 DiagnosticReporter reporter, | 41 DiagnosticReporter reporter, |
| 41 Measurer measurer); | 42 Measurer measurer); |
| 42 | 43 |
| 43 /// Returns the [ElementEnvironment] for the element model used in this | 44 /// Returns the [ElementEnvironment] for the element model used in this |
| 44 /// strategy. | 45 /// strategy. |
| 45 ElementEnvironment get elementEnvironment; | 46 ElementEnvironment get elementEnvironment; |
| 46 | 47 |
| 47 /// Returns the [AnnotationProcessor] for this strategy. | 48 /// Returns the [AnnotationProcessor] for this strategy. |
| 48 AnnotationProcessor get annotationProcesser; | 49 AnnotationProcessor get annotationProcesser; |
| 49 | 50 |
| 50 /// Creates the [NativeClassFinder] for this strategy. | 51 /// Creates the [NativeClassFinder] for this strategy. |
| 51 NativeClassFinder createNativeClassResolver(NativeBasicData nativeBasicData); | 52 NativeClassFinder createNativeClassFinder(NativeBasicData nativeBasicData); |
| 52 | 53 |
| 53 /// Creates the [NoSuchMethodResolver] corresponding the resolved model of | 54 /// Creates the [NoSuchMethodResolver] corresponding the resolved model of |
| 54 /// this strategy. | 55 /// this strategy. |
| 55 NoSuchMethodResolver createNoSuchMethodResolver(); | 56 NoSuchMethodResolver createNoSuchMethodResolver(); |
| 56 | 57 |
| 57 /// Creates the [ResolutionWorldBuilder] corresponding to the element model | 58 /// Creates the [ResolutionWorldBuilder] corresponding to the element model |
| 58 /// used in this strategy. | 59 /// used in this strategy. |
| 59 ResolutionWorldBuilder createResolutionWorldBuilder( | 60 ResolutionWorldBuilder createResolutionWorldBuilder( |
| 60 NativeBasicData nativeBasicData, | 61 NativeBasicData nativeBasicData, |
| 61 SelectorConstraintsStrategy selectorConstraintsStrategy); | 62 SelectorConstraintsStrategy selectorConstraintsStrategy); |
| 62 | 63 |
| 63 /// Creates the [WorkItemBuilder] corresponding to how a resolved model for | 64 /// Creates the [WorkItemBuilder] corresponding to how a resolved model for |
| 64 /// a single member is obtained in this strategy. | 65 /// a single member is obtained in this strategy. |
| 65 WorkItemBuilder createResolutionWorkItemBuilder( | 66 WorkItemBuilder createResolutionWorkItemBuilder( |
| 66 ImpactTransformer impactTransformer); | 67 ImpactTransformer impactTransformer); |
| 67 | 68 |
| 69 /// Computes the main function from [mainLibrary] adding additional world |
| 70 /// impact to [impactBuilder]. |
| 71 FunctionEntity computeMain( |
| 72 LibraryEntity mainLibrary, WorldImpactBuilder impactBuilder); |
| 73 |
| 68 // TODO(johnniwinther): Reuse the following classes between strategies: | 74 // TODO(johnniwinther): Reuse the following classes between strategies: |
| 69 | 75 |
| 70 /// Creates the [CustomElementsResolutionAnalysis] for this strategy. | 76 /// Creates the [CustomElementsResolutionAnalysis] for this strategy. |
| 71 CustomElementsResolutionAnalysis createCustomElementsResolutionAnalysis( | 77 CustomElementsResolutionAnalysis createCustomElementsResolutionAnalysis( |
| 72 NativeBasicData nativeBasicData, BackendUsageBuilder backendUsageBuilder); | 78 NativeBasicData nativeBasicData, BackendUsageBuilder backendUsageBuilder); |
| 73 | 79 |
| 74 /// Creates the [MirrorsDataBuilder] for this strategy. | 80 /// Creates the [MirrorsDataBuilder] for this strategy. |
| 75 MirrorsDataBuilder createMirrorsDataBuilder(); | 81 MirrorsDataBuilder createMirrorsDataBuilder(); |
| 76 | 82 |
| 77 /// Creates the [MirrorsResolutionAnalysis] for this strategy. | 83 /// Creates the [MirrorsResolutionAnalysis] for this strategy. |
| 78 // TODO(johnniwinther): Avoid passing [JavaScriptBackend]. | 84 // TODO(johnniwinther): Avoid passing [JavaScriptBackend]. |
| 79 MirrorsResolutionAnalysis createMirrorsResolutionAnalysis( | 85 MirrorsResolutionAnalysis createMirrorsResolutionAnalysis( |
| 80 JavaScriptBackend backend); | 86 JavaScriptBackend backend); |
| 81 | 87 |
| 82 /// Creates the [RuntimeTypesNeedBuilder] for this strategy. | 88 /// Creates the [RuntimeTypesNeedBuilder] for this strategy. |
| 83 RuntimeTypesNeedBuilder createRuntimeTypesNeedBuilder(); | 89 RuntimeTypesNeedBuilder createRuntimeTypesNeedBuilder(); |
| 84 } | 90 } |
| 85 | 91 |
| 86 /// Class that performs the mechanics to investigate annotations in the code. | 92 /// Class that performs the mechanics to investigate annotations in the code. |
| 87 abstract class AnnotationProcessor { | 93 abstract class AnnotationProcessor { |
| 88 void extractNativeAnnotations( | 94 void extractNativeAnnotations( |
| 89 LibraryEntity library, NativeBasicDataBuilder nativeBasicDataBuilder); | 95 LibraryEntity library, NativeBasicDataBuilder nativeBasicDataBuilder); |
| 90 | 96 |
| 91 void extractJsInteropAnnotations( | 97 void extractJsInteropAnnotations( |
| 92 LibraryEntity library, NativeBasicDataBuilder nativeBasicDataBuilder); | 98 LibraryEntity library, NativeBasicDataBuilder nativeBasicDataBuilder); |
| 93 } | 99 } |
| OLD | NEW |