blob: f6f990503cff0d80300a3cc83126b1539092b1b2 [file] [log] [blame]
ethannicholasb3058bd2016-07-01 08:22:01 -07001/*
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 Nicholas0df1b042017-03-31 13:56:23 -04007
ethannicholasb3058bd2016-07-01 08:22:01 -07008#ifndef SKSL_CODEGENERATOR
9#define SKSL_CODEGENERATOR
10
11#include "ir/SkSLProgram.h"
ethannicholasb3058bd2016-07-01 08:22:01 -070012
13namespace SkSL {
14
15/**
16 * Abstract superclass of all code generators, which take a Program as input and produce code as
17 * output.
18 */
19class CodeGenerator {
20public:
Ethan Nicholas0df1b042017-03-31 13:56:23 -040021 CodeGenerator(const Program* program, ErrorReporter* errors, OutputStream* out)
Ethan Nicholas941e7e22016-12-12 15:33:30 -050022 : fProgram(*program)
23 , fErrors(*errors)
24 , fOut(out) {}
25
ethannicholasf789b382016-08-03 12:43:36 -070026 virtual ~CodeGenerator() {}
Ethan Nicholas19671772016-11-28 16:30:17 -050027
Ethan Nicholas941e7e22016-12-12 15:33:30 -050028 virtual bool generateCode() = 0;
29
30protected:
31
32 const Program& fProgram;
33 ErrorReporter& fErrors;
Ethan Nicholas0df1b042017-03-31 13:56:23 -040034 OutputStream* fOut;
ethannicholasb3058bd2016-07-01 08:22:01 -070035};
36
37} // namespace
38
39#endif