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

Unified Diff: pkg/compiler/lib/src/backend_strategy.dart

Issue 2858513002: Add BackendStrategy (Closed)
Patch Set: Updated cf. comments Created 3 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 | « no previous file | 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/backend_strategy.dart
diff --git a/pkg/compiler/lib/src/backend_strategy.dart b/pkg/compiler/lib/src/backend_strategy.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a95aa7aabad608ce7f5f351c1259e2529739c81a
--- /dev/null
+++ b/pkg/compiler/lib/src/backend_strategy.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart2js.backend_strategy;
+
+import 'compiler.dart';
+import 'js_emitter/sorter.dart';
+import 'world.dart';
+
+/// Strategy pattern that defines the element model used in type inference
+/// and code generation.
+abstract class BackendStrategy {
+ /// Create the [ClosedWorldRefiner] for [closedWorld].
+ ClosedWorldRefiner createClosedWorldRefiner(ClosedWorld closedWorld);
+
+ /// Create closure classes for local functions.
+ void convertClosures(ClosedWorldRefiner closedWorldRefiner);
+
+ /// The [Sorter] used for sorting elements in the generated code.
+ Sorter get sorter;
+}
+
+/// Strategy for using the [Element] model from the resolver as the backend
+/// model.
+class ElementBackendStrategy implements BackendStrategy {
+ final Compiler _compiler;
+
+ ElementBackendStrategy(this._compiler);
+
+ ClosedWorldRefiner createClosedWorldRefiner(ClosedWorldImpl closedWorld) =>
+ closedWorld;
+
+ Sorter get sorter => const ElementSorter();
+
+ void convertClosures(ClosedWorldRefiner closedWorldRefiner) {
+ _compiler.closureToClassMapper.createClosureClasses(closedWorldRefiner);
+ }
+}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698