ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 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 | */ |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 7 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 8 | #ifndef SKSL_CODEGENERATOR |
| 9 | #define SKSL_CODEGENERATOR |
| 10 | |
| 11 | #include "ir/SkSLProgram.h" |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 12 | #include "SkSLOutputStream.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 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: |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 22 | CodeGenerator(const Program* program, ErrorReporter* errors, OutputStream* out) |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 23 | : fProgram(*program) |
| 24 | , fErrors(*errors) |
| 25 | , fOut(out) {} |
| 26 | |
ethannicholas | f789b38 | 2016-08-03 12:43:36 -0700 | [diff] [blame] | 27 | virtual ~CodeGenerator() {} |
Ethan Nicholas | 1967177 | 2016-11-28 16:30:17 -0500 | [diff] [blame] | 28 | |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 29 | virtual bool generateCode() = 0; |
| 30 | |
| 31 | protected: |
| 32 | |
| 33 | const Program& fProgram; |
| 34 | ErrorReporter& fErrors; |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 35 | OutputStream* fOut; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | } // namespace |
| 39 | |
| 40 | #endif |