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 #include "SkSLOutputStream.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: CodeGenerator(const Program * program,ErrorReporter * errors,OutputStream * out)22 CodeGenerator(const Program* program, ErrorReporter* errors, OutputStream* out) 23 : fProgram(*program) 24 , fErrors(*errors) 25 , fOut(out) {} 26 ~CodeGenerator()27 virtual ~CodeGenerator() {} 28 29 virtual bool generateCode() = 0; 30 31 protected: 32 33 const Program& fProgram; 34 ErrorReporter& fErrors; 35 OutputStream* fOut; 36 }; 37 38 } // namespace 39 40 #endif 41