• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "ir/SkSLProgram.h"
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:
CodeGenerator(const Program * program,ErrorReporter * errors,SkWStream * out)21     CodeGenerator(const Program* program, ErrorReporter* errors, SkWStream* out)
22     : fProgram(*program)
23     , fErrors(*errors)
24     , fOut(out) {}
25 
~CodeGenerator()26     virtual ~CodeGenerator() {}
27 
28     virtual bool generateCode() = 0;
29 
30 protected:
31 
32     const Program& fProgram;
33     ErrorReporter& fErrors;
34     SkWStream* fOut;
35 };
36 
37 } // namespace
38 
39 #endif
40