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

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

Issue 1892183002: Refactor Parsing to remove compiler dependency (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/closure.dart ('k') | pkg/compiler/lib/src/compiler.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 0286376b53d82f6797180edddca9889a74fcf509..aa726614f869b994496dda554cbef841abee8283 100644
--- a/pkg/compiler/lib/src/common/resolution.dart
+++ b/pkg/compiler/lib/src/common/resolution.dart
@@ -22,8 +22,11 @@ import '../elements/elements.dart'
import '../enqueue.dart' show ResolutionEnqueuer;
import '../options.dart' show ParserOptions;
import '../parser/element_listener.dart' show ScannerOptions;
+import '../parser/parser_task.dart';
+import '../patch_parser.dart';
import '../tree/tree.dart' show TypeAnnotation;
import '../universe/world_impact.dart' show WorldImpact;
+import 'backend_api.dart';
import 'work.dart' show ItemCompilationContext, WorkItem;
/// [WorkItem] used exclusively by the [ResolutionEnqueuer].
@@ -184,7 +187,7 @@ class ListLiteralUse {
// TODO(johnniwinther): Rename to `Resolver` or `ResolverContext`.
abstract class Resolution {
- Parsing get parsing;
+ ParsingContext get parsingContext;
DiagnosticReporter get reporter;
CoreTypes get coreTypes;
@@ -232,11 +235,55 @@ abstract class Resolution {
void emptyCache();
}
-// TODO(johnniwinther): Rename to `Parser` or `ParsingContext`.
-abstract class Parsing {
+/// A container of commonly used dependencies for tasks that involve parsing.
+abstract class ParsingContext {
+ factory ParsingContext(
+ DiagnosticReporter reporter,
+ ParserOptions parserOptions,
+ ParserTask parser,
+ PatchParserTask patchParser,
+ Backend backend) = _ParsingContext;
+
DiagnosticReporter get reporter;
+ ParserOptions get parserOptions;
+ ParserTask get parser;
+ PatchParserTask get patchParser;
+
+ /// Use [patchParser] directly instead.
+ @deprecated
void parsePatchClass(ClassElement cls);
+
+ /// Use [parser] and measure directly instead.
+ @deprecated
measure(f());
+
+ /// Get the [ScannerOptions] to scan the given [element].
ScannerOptions getScannerOptionsFor(Element element);
- ParserOptions get parserOptions;
+}
+
+class _ParsingContext implements ParsingContext {
+ final DiagnosticReporter reporter;
+ final ParserOptions parserOptions;
+ final ParserTask parser;
+ final PatchParserTask patchParser;
+ final Backend backend;
+
+ _ParsingContext(this.reporter, this.parserOptions, this.parser,
+ this.patchParser, this.backend);
+
+ @override
+ measure(f()) => parser.measure(f);
+
+ @override
+ void parsePatchClass(ClassElement cls) {
+ patchParser.measure(() {
+ if (cls.isPatch) {
+ patchParser.parsePatchClassNode(cls);
+ }
+ });
+ }
+
+ @override
+ ScannerOptions getScannerOptionsFor(Element element) => new ScannerOptions(
+ canUseNative: backend.canLibraryUseNative(element.library));
}
« no previous file with comments | « pkg/compiler/lib/src/closure.dart ('k') | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698