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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file.
4
5 library fletchc.fletch_backend;
6
7 import 'package:compiler/src/dart2jslib.dart' show
8 Backend,
9 BackendConstantEnvironment,
10 CodegenWorkItem,
11 ConstantCompilerTask,
12 ConstantSystem,
13 MessageKind,
14 Registry,
15 ResolutionEnqueuer;
16
17 import '../bytecodes.dart' show Bytecode;
18
19 import 'fletch_context.dart';
20
21 class FletchBackend extends Backend {
22 final FletchContext context;
23
24 FletchBackend(FletchCompiler compiler)
25 : this.context = compiler.context,
26 super(compiler) {
27 context.resolutionCallbacks = new FletchResolutionCallbacks(context);
28 }
29
30 FletchResolutionCallbacks get resolutionCallbacks {
31 return context.resolutionCallbacks;
32 }
33
34 List<CompilerTask> get tasks => <CompilerTask>[];
35
36 ConstantSystem get constantSystem {
37 throw new UnsupportedError("get constantSystem");
38 }
39
40 BackendConstantEnvironment get constants {
41 throw new UnsupportedError("get constants");
42 }
43
44 ConstantCompilerTask get constantCompilerTask {
45 throw new UnsupportedError("get constantCompilerTask");
46 }
47
48 void enqueueHelpers(
49 ResolutionEnqueuer world,
50 Registry registry) {
51 }
52
53 void codegen(CodegenWorkItem work) {
54 }
55
56 bool get canHandleCompilationFailed => true;
57
58 int assembleProgram() {
59 compiler.reportHint(
60 compiler.mainFunction,
61 MessageKind.GENERIC,
62 {'text': 'Compiling ${compiler.mainFunction.name}'});
63
64 BytecodeBuilder builder =
65 new BytecodeBuilder(context, compiler.mainFunction);
66 compiler.mainFunction.node.accept(builder);
67 print("Constants");
68 builder.constants.forEach((constant, int index) {
69 print(" #$index: $constant");
70 });
71
72 print("Bytecodes:");
73 int offset = 0;
74 for (Bytecode bytecode in builder.bytecodes) {
75 print(" $offset: $bytecode");
76 offset += bytecode.size;
77 }
78 }
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698