1 | /* |
---|---|
2 | * Copyright 2016 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #ifndef SKSL_CODEGENERATOR |
9 | #define SKSL_CODEGENERATOR |
10 | |
11 | #include "src/sksl/SkSLOutputStream.h" |
12 | #include "src/sksl/ir/SkSLProgram.h" |
13 | |
14 | namespace SkSL { |
15 | |
16 | /** |
17 | * Abstract superclass of all code generators, which take a Program as input and produce code as |
18 | * output. |
19 | */ |
20 | class CodeGenerator { |
21 | public: |
22 | CodeGenerator(const Program* program, ErrorReporter* errors, OutputStream* out) |
23 | : fProgram(*program) |
24 | , fErrors(*errors) |
25 | , fOut(out) { |
26 | SkASSERT(program->fIsOptimized); |
27 | } |
28 | |
29 | virtual ~CodeGenerator() {} |
30 | |
31 | virtual bool generateCode() = 0; |
32 | |
33 | protected: |
34 | |
35 | const Program& fProgram; |
36 | ErrorReporter& fErrors; |
37 | OutputStream* fOut; |
38 | }; |
39 | |
40 | } // namespace |
41 | |
42 | #endif |
43 |