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

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

Issue 2894893002: Add ElementCodegenWorldBuilder (Closed)
Patch Set: Updated cf. comments. 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.enqueue; 5 library dart2js.js.enqueue;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 8
9 import '../common/codegen.dart' show CodegenWorkItem;
10 import '../common/tasks.dart' show CompilerTask; 9 import '../common/tasks.dart' show CompilerTask;
11 import '../common/work.dart' show WorkItem; 10 import '../common/work.dart' show WorkItem;
12 import '../common.dart'; 11 import '../common.dart';
13 import '../common_elements.dart' show ElementEnvironment; 12 import '../common_elements.dart' show ElementEnvironment;
14 import '../elements/resolution_types.dart' 13 import '../elements/resolution_types.dart'
15 show ResolutionDartType, ResolutionInterfaceType; 14 show ResolutionDartType, ResolutionInterfaceType;
16 import '../elements/elements.dart' show MemberElement;
17 import '../elements/entities.dart'; 15 import '../elements/entities.dart';
18 import '../enqueue.dart'; 16 import '../enqueue.dart';
19 import '../js_backend/backend.dart' show JavaScriptBackend;
20 import '../options.dart'; 17 import '../options.dart';
21 import '../universe/world_builder.dart'; 18 import '../universe/world_builder.dart';
22 import '../universe/use.dart' 19 import '../universe/use.dart'
23 show 20 show
24 ConstantUse, 21 ConstantUse,
25 DynamicUse, 22 DynamicUse,
26 StaticUse, 23 StaticUse,
27 StaticUseKind, 24 StaticUseKind,
28 TypeUse, 25 TypeUse,
29 TypeUseKind; 26 TypeUseKind;
30 import '../universe/world_impact.dart' 27 import '../universe/world_impact.dart'
31 show ImpactUseCase, WorldImpact, WorldImpactVisitor; 28 show ImpactUseCase, WorldImpact, WorldImpactVisitor;
32 import '../util/enumset.dart'; 29 import '../util/enumset.dart';
33 import '../util/util.dart' show Setlet; 30 import '../util/util.dart' show Setlet;
34 import '../world.dart' show ClosedWorld;
35 31
36 /// [Enqueuer] which is specific to code generation. 32 /// [Enqueuer] which is specific to code generation.
37 class CodegenEnqueuer extends EnqueuerImpl { 33 class CodegenEnqueuer extends EnqueuerImpl {
38 final String name; 34 final String name;
39 final EnqueuerStrategy strategy; 35 final EnqueuerStrategy strategy;
40 36
41 Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>(); 37 Set<ClassEntity> _recentClasses = new Setlet<ClassEntity>();
42 bool _recentConstants = false; 38 bool _recentConstants = false;
43 final CodegenWorldBuilderImpl _worldBuilder; 39 final CodegenWorldBuilderImpl _worldBuilder;
44 final WorkItemBuilder _workItemBuilder; 40 final WorkItemBuilder _workItemBuilder;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 String toString() => 'Enqueuer($name)'; 257 String toString() => 'Enqueuer($name)';
262 258
263 ImpactUseCase get impactUse => IMPACT_USE; 259 ImpactUseCase get impactUse => IMPACT_USE;
264 260
265 @override 261 @override
266 Iterable<MemberEntity> get processedEntities => _processedEntities; 262 Iterable<MemberEntity> get processedEntities => _processedEntities;
267 263
268 @override 264 @override
269 Iterable<ClassEntity> get processedClasses => _worldBuilder.processedClasses; 265 Iterable<ClassEntity> get processedClasses => _worldBuilder.processedClasses;
270 } 266 }
271
272 /// Builder that creates the work item necessary for the code generation of a
273 /// [MemberElement].
274 class CodegenWorkItemBuilder extends WorkItemBuilder {
275 final JavaScriptBackend _backend;
276 final ClosedWorld _closedWorld;
277 final CompilerOptions _options;
278
279 CodegenWorkItemBuilder(this._backend, this._closedWorld, this._options);
280
281 @override
282 WorkItem createWorkItem(MemberElement element) {
283 assert(invariant(element, element.isDeclaration));
284 // Don't generate code for foreign elements.
285 if (_backend.isForeign(element)) return null;
286 if (element.isAbstract) return null;
287
288 // Codegen inlines field initializers. It only needs to generate
289 // code for checked setters.
290 if (element.isField && element.isInstanceMember) {
291 if (!_options.enableTypeAssertions ||
292 element.enclosingElement.isClosure) {
293 return null;
294 }
295 }
296 return new CodegenWorkItem(_backend, _closedWorld, element);
297 }
298 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/element_strategy.dart ('k') | pkg/compiler/lib/src/js_backend/resolution_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698