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

Unified Diff: pkg/compiler/lib/src/common/codegen.dart

Issue 2531303002: Decouple WorkItem from Compiler (Closed)
Patch Set: Updated cf. comments. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/common/backend_api.dart ('k') | pkg/compiler/lib/src/common/resolution.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/common/codegen.dart
diff --git a/pkg/compiler/lib/src/common/codegen.dart b/pkg/compiler/lib/src/common/codegen.dart
index 285e03290c1f6d4fe1a093ce99d2fa14bedc81a7..748f2225ddc5e4cf159686f3386357f2583dd8d9 100644
--- a/pkg/compiler/lib/src/common/codegen.dart
+++ b/pkg/compiler/lib/src/common/codegen.dart
@@ -5,7 +5,7 @@
library dart2js.common.codegen;
import '../common.dart';
-import '../compiler.dart' show Compiler;
+import '../common/backend_api.dart' show Backend;
import '../constants/values.dart' show ConstantValue;
import '../dart_types.dart' show DartType, InterfaceType;
import '../elements/elements.dart'
@@ -146,19 +146,22 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
// TODO(johnniwinther): Split this class into interface and implementation.
// TODO(johnniwinther): Move this implementation to the JS backend.
class CodegenRegistry {
- final Compiler compiler;
final Element currentElement;
final _CodegenImpact worldImpact;
- CodegenRegistry(Compiler compiler, AstElement currentElement)
- : this.compiler = compiler,
- this.currentElement = currentElement,
+ CodegenRegistry(AstElement currentElement)
+ : this.currentElement = currentElement,
this.worldImpact = new _CodegenImpact();
bool get isForResolution => false;
String toString() => 'CodegenRegistry for $currentElement';
+ /// Add the uses in [impact] to the impact of this registry.
+ void addImpact(WorldImpact impact) {
+ worldImpact.addImpact(impact);
+ }
+
@deprecated
void registerInstantiatedClass(ClassElement element) {
registerInstantiation(element.rawType);
@@ -218,8 +221,9 @@ class CodegenRegistry {
class CodegenWorkItem extends WorkItem {
CodegenRegistry registry;
final ResolvedAst resolvedAst;
+ final Backend backend;
- factory CodegenWorkItem(Compiler compiler, AstElement element) {
+ factory CodegenWorkItem(Backend backend, AstElement element) {
// If this assertion fails, the resolution callbacks of the backend may be
// missing call of form registry.registerXXX. Alternatively, the code
// generation could spuriously be adding dependencies on things we know we
@@ -227,18 +231,16 @@ class CodegenWorkItem extends WorkItem {
assert(invariant(element, element.hasResolvedAst,
message: "$element has no resolved ast."));
ResolvedAst resolvedAst = element.resolvedAst;
- return new CodegenWorkItem.internal(resolvedAst);
+ return new CodegenWorkItem.internal(resolvedAst, backend);
}
- CodegenWorkItem.internal(ResolvedAst resolvedAst)
+ CodegenWorkItem.internal(ResolvedAst resolvedAst, this.backend)
: this.resolvedAst = resolvedAst,
super(resolvedAst.element);
- WorldImpact run(Compiler compiler, Enqueuer world) {
- if (world.isProcessed(element)) return const WorldImpact();
-
- registry = new CodegenRegistry(compiler, element);
- return compiler.codegen(this, world);
+ WorldImpact run() {
+ registry = new CodegenRegistry(element);
+ return backend.codegen(this);
}
String toString() => 'CodegenWorkItem(${resolvedAst.element})';
« no previous file with comments | « pkg/compiler/lib/src/common/backend_api.dart ('k') | pkg/compiler/lib/src/common/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698