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); |
+ } |
+} |