Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: pkg/compiler/lib/src/js_backend/element_strategy.dart

Issue 2897273002: Add FunctionEntity.asyncMarker and refactor SourceInformationStrategy to avoid ResolvedAst (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/multi_information.dart' show MultiSourceInformationStrategy;
15 import '../io/position_information.dart' show PositionSourceInformationStrategy;
14 import '../io/source_information.dart'; 16 import '../io/source_information.dart';
17 import '../io/start_end_information.dart'
18 show StartEndSourceInformationStrategy;
19 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy;
15 import '../js_backend/backend.dart'; 20 import '../js_backend/backend.dart';
16 import '../js_backend/native_data.dart'; 21 import '../js_backend/native_data.dart';
17 import '../js_emitter/sorter.dart'; 22 import '../js_emitter/sorter.dart';
18 import '../ssa/builder.dart'; 23 import '../ssa/builder.dart';
19 import '../ssa/rasta_ssa_builder_task.dart'; 24 import '../ssa/rasta_ssa_builder_task.dart';
20 import '../ssa/ssa.dart'; 25 import '../ssa/ssa.dart';
21 import '../options.dart'; 26 import '../options.dart';
22 import '../universe/world_builder.dart'; 27 import '../universe/world_builder.dart';
23 import '../universe/world_impact.dart'; 28 import '../universe/world_impact.dart';
24 import '../world.dart'; 29 import '../world.dart';
25 30
26 /// Strategy for using the [Element] model from the resolver as the backend 31 /// Strategy for using the [Element] model from the resolver as the backend
27 /// model. 32 /// model.
28 class ElementBackendStrategy implements BackendStrategy { 33 class ElementBackendStrategy implements BackendStrategy {
29 final Compiler _compiler; 34 final Compiler _compiler;
35 SourceInformationStrategy _sourceInformationStrategy;
30 36
31 ElementBackendStrategy(this._compiler); 37 ElementBackendStrategy(this._compiler);
32 38
33 ClosedWorldRefiner createClosedWorldRefiner(ClosedWorldImpl closedWorld) => 39 ClosedWorldRefiner createClosedWorldRefiner(ClosedWorldImpl closedWorld) =>
34 closedWorld; 40 closedWorld;
35 41
36 Sorter get sorter => const ElementSorter(); 42 Sorter get sorter => const ElementSorter();
37 43
38 void convertClosures(ClosedWorldRefiner closedWorldRefiner) { 44 void convertClosures(ClosedWorldRefiner closedWorldRefiner) {
39 _compiler.closureToClassMapper.createClosureClasses(closedWorldRefiner); 45 _compiler.closureToClassMapper.createClosureClasses(closedWorldRefiner);
(...skipping 18 matching lines...) Expand all
58 _compiler.backend, closedWorld, _compiler.options); 64 _compiler.backend, closedWorld, _compiler.options);
59 } 65 }
60 66
61 @override 67 @override
62 SsaBuilderTask createSsaBuilderTask(JavaScriptBackend backend, 68 SsaBuilderTask createSsaBuilderTask(JavaScriptBackend backend,
63 SourceInformationStrategy sourceInformationStrategy) { 69 SourceInformationStrategy sourceInformationStrategy) {
64 return _compiler.options.useKernel 70 return _compiler.options.useKernel
65 ? new RastaSsaBuilderTask(backend, sourceInformationStrategy) 71 ? new RastaSsaBuilderTask(backend, sourceInformationStrategy)
66 : new SsaAstBuilderTask(backend, sourceInformationStrategy); 72 : new SsaAstBuilderTask(backend, sourceInformationStrategy);
67 } 73 }
74
75 SourceInformationStrategy get sourceInformationStrategy {
76 return _sourceInformationStrategy ??= createSourceInformationStrategy(
77 generateSourceMap: _compiler.options.generateSourceMap,
78 useMultiSourceInfo: _compiler.options.useMultiSourceInfo,
79 useNewSourceInfo: _compiler.options.useNewSourceInfo);
80 }
81
82 static SourceInformationStrategy createSourceInformationStrategy(
83 {bool generateSourceMap: false,
84 bool useMultiSourceInfo: false,
85 bool useNewSourceInfo: false}) {
86 if (!generateSourceMap) return const JavaScriptSourceInformationStrategy();
87 if (useMultiSourceInfo) {
88 if (useNewSourceInfo) {
89 return const MultiSourceInformationStrategy(const [
90 const PositionSourceInformationStrategy(),
91 const StartEndSourceInformationStrategy()
92 ]);
93 } else {
94 return const MultiSourceInformationStrategy(const [
95 const StartEndSourceInformationStrategy(),
96 const PositionSourceInformationStrategy()
97 ]);
98 }
99 } else if (useNewSourceInfo) {
100 return const PositionSourceInformationStrategy();
101 } else {
102 return const StartEndSourceInformationStrategy();
103 }
104 }
68 } 105 }
69 106
70 /// Builder that creates the work item necessary for the code generation of a 107 /// Builder that creates the work item necessary for the code generation of a
71 /// [MemberElement]. 108 /// [MemberElement].
72 class ElementCodegenWorkItemBuilder extends WorkItemBuilder { 109 class ElementCodegenWorkItemBuilder extends WorkItemBuilder {
73 final JavaScriptBackend _backend; 110 final JavaScriptBackend _backend;
74 final ClosedWorld _closedWorld; 111 final ClosedWorld _closedWorld;
75 final CompilerOptions _options; 112 final CompilerOptions _options;
76 113
77 ElementCodegenWorkItemBuilder( 114 ElementCodegenWorkItemBuilder(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 157
121 MemberElement get element => resolvedAst.element; 158 MemberElement get element => resolvedAst.element;
122 159
123 WorldImpact run() { 160 WorldImpact run() {
124 registry = new CodegenRegistry(element); 161 registry = new CodegenRegistry(element);
125 return _backend.codegen(this, _closedWorld); 162 return _backend.codegen(this, _closedWorld);
126 } 163 }
127 164
128 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; 165 String toString() => 'CodegenWorkItem(${resolvedAst.element})';
129 } 166 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/impact_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698