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" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 12 | |
| 13 | namespace SkSL { |
| 14 | |
| 15 | /** |
| 16 | * Abstract superclass of all code generators, which take a Program as input and produce code as |
| 17 | * output. |
| 18 | */ |
| 19 | class CodeGenerator { |
| 20 | public: |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 21 | CodeGenerator(const Program* program, ErrorReporter* errors, OutputStream* out) |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 22 | : fProgram(*program) |
| 23 | , fErrors(*errors) |
| 24 | , fOut(out) {} |
| 25 | |
ethannicholas | f789b38 | 2016-08-03 12:43:36 -0700 | [diff] [blame] | 26 | virtual ~CodeGenerator() {} |
Ethan Nicholas | 1967177 | 2016-11-28 16:30:17 -0500 | [diff] [blame] | 27 | |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 28 | virtual bool generateCode() = 0; |
| 29 | |
| 30 | protected: |
| 31 | |
| 32 | const Program& fProgram; |
| 33 | ErrorReporter& fErrors; |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 34 | OutputStream* fOut; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | } // namespace |
| 38 | |
| 39 | #endif |