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

Unified Diff: pkg/compiler/lib/src/common/resolution.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/codegen.dart ('k') | pkg/compiler/lib/src/common/work.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/common/resolution.dart
diff --git a/pkg/compiler/lib/src/common/resolution.dart b/pkg/compiler/lib/src/common/resolution.dart
index 9012c822c421e62cda59129e175bc4a6606ce944..2adfe261e94d278396406729510bd509ce4b457e 100644
--- a/pkg/compiler/lib/src/common/resolution.dart
+++ b/pkg/compiler/lib/src/common/resolution.dart
@@ -41,18 +41,24 @@ import 'backend_api.dart';
import 'work.dart' show WorkItem;
/// [WorkItem] used exclusively by the [ResolutionEnqueuer].
-class ResolutionWorkItem extends WorkItem {
+abstract class ResolutionWorkItem implements WorkItem {
+ factory ResolutionWorkItem(Resolution resolution, AstElement element) =
+ _ResolutionWorkItem;
+}
+
+class _ResolutionWorkItem extends WorkItem implements ResolutionWorkItem {
bool _isAnalyzed = false;
+ final Resolution resolution;
- ResolutionWorkItem(AstElement element) : super(element);
+ _ResolutionWorkItem(this.resolution, AstElement element) : super(element);
- WorldImpact run(Compiler compiler, ResolutionEnqueuer world) {
- WorldImpact impact = compiler.analyze(this, world);
+ WorldImpact run() {
+ assert(invariant(element, !_isAnalyzed,
+ message: 'Element ${element} has already been analyzed'));
+ WorldImpact impact = resolution.computeWorldImpact(element);
_isAnalyzed = true;
return impact;
}
-
- bool get isAnalyzed => _isAnalyzed;
}
class ResolutionImpact extends WorldImpact {
@@ -210,11 +216,8 @@ abstract class Resolution implements Frontend {
/// A container of commonly used dependencies for tasks that involve parsing.
abstract class ParsingContext {
- factory ParsingContext(
- DiagnosticReporter reporter,
- ParserTask parser,
- PatchParserTask patchParser,
- Backend backend) = _ParsingContext;
+ factory ParsingContext(DiagnosticReporter reporter, ParserTask parser,
+ PatchParserTask patchParser, Backend backend) = _ParsingContext;
DiagnosticReporter get reporter;
ParserTask get parser;
@@ -238,8 +241,7 @@ class _ParsingContext implements ParsingContext {
final PatchParserTask patchParser;
final Backend backend;
- _ParsingContext(this.reporter, this.parser,
- this.patchParser, this.backend);
+ _ParsingContext(this.reporter, this.parser, this.patchParser, this.backend);
@override
measure(f()) => parser.measure(f);
« no previous file with comments | « pkg/compiler/lib/src/common/codegen.dart ('k') | pkg/compiler/lib/src/common/work.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698