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

Unified Diff: pkg/fletchc/lib/src/fletch_backend.dart

Issue 918613002: Refactor implementation to address review comments and API design suggestions from Luke. (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 years, 10 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
Index: pkg/fletchc/lib/src/fletch_backend.dart
diff --git a/pkg/fletchc/lib/src/fletch_backend.dart b/pkg/fletchc/lib/src/fletch_backend.dart
new file mode 100644
index 0000000000000000000000000000000000000000..115ed90554fc0713b3d43888ff820d8d22ee3def
--- /dev/null
+++ b/pkg/fletchc/lib/src/fletch_backend.dart
@@ -0,0 +1,79 @@
+// Copyright (c) 2015, the Fletch 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.md file.
+
+library fletchc.fletch_backend;
+
+import 'package:compiler/src/dart2jslib.dart' show
+ Backend,
+ BackendConstantEnvironment,
+ CodegenWorkItem,
+ ConstantCompilerTask,
+ ConstantSystem,
+ MessageKind,
+ Registry,
+ ResolutionEnqueuer;
+
+import '../bytecodes.dart' show Bytecode;
+
+import 'fletch_context.dart';
+
+class FletchBackend extends Backend {
+ final FletchContext context;
+
+ FletchBackend(FletchCompiler compiler)
+ : this.context = compiler.context,
+ super(compiler) {
+ context.resolutionCallbacks = new FletchResolutionCallbacks(context);
+ }
+
+ FletchResolutionCallbacks get resolutionCallbacks {
+ return context.resolutionCallbacks;
+ }
+
+ List<CompilerTask> get tasks => <CompilerTask>[];
+
+ ConstantSystem get constantSystem {
+ throw new UnsupportedError("get constantSystem");
+ }
+
+ BackendConstantEnvironment get constants {
+ throw new UnsupportedError("get constants");
+ }
+
+ ConstantCompilerTask get constantCompilerTask {
+ throw new UnsupportedError("get constantCompilerTask");
+ }
+
+ void enqueueHelpers(
+ ResolutionEnqueuer world,
+ Registry registry) {
+ }
+
+ void codegen(CodegenWorkItem work) {
+ }
+
+ bool get canHandleCompilationFailed => true;
+
+ int assembleProgram() {
+ compiler.reportHint(
+ compiler.mainFunction,
+ MessageKind.GENERIC,
+ {'text': 'Compiling ${compiler.mainFunction.name}'});
+
+ BytecodeBuilder builder =
+ new BytecodeBuilder(context, compiler.mainFunction);
+ compiler.mainFunction.node.accept(builder);
+ print("Constants");
+ builder.constants.forEach((constant, int index) {
+ print(" #$index: $constant");
+ });
+
+ print("Bytecodes:");
+ int offset = 0;
+ for (Bytecode bytecode in builder.bytecodes) {
+ print(" $offset: $bytecode");
+ offset += bytecode.size;
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698