blob: 1f577b58b18660e29ef6a83edbc742655dec55f2 [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"
Ethan Nicholas762466e2017-06-29 10:03:38 -040012#include "SkSLOutputStream.h"
ethannicholasb3058bd2016-07-01 08:22:01 -070013
14namespace SkSL {
15
16/**
17 * Abstract superclass of all code generators, which take a Program as input and produce code as
18 * output.
19 */
20class CodeGenerator {
21public:
Ethan Nicholas0df1b042017-03-31 13:56:23 -040022 CodeGenerator(const Program* program, ErrorReporter* errors, OutputStream* out)
Ethan Nicholas941e7e22016-12-12 15:33:30 -050023 : fProgram(*program)
24 , fErrors(*errors)
25 , fOut(out) {}
26
ethannicholasf789b382016-08-03 12:43:36 -070027 virtual ~CodeGenerator() {}
Ethan Nicholas19671772016-11-28 16:30:17 -050028
Ethan Nicholas941e7e22016-12-12 15:33:30 -050029 virtual bool generateCode() = 0;
30
31protected:
32
33 const Program& fProgram;
34 ErrorReporter& fErrors;
Ethan Nicholas0df1b042017-03-31 13:56:23 -040035 OutputStream* fOut;
ethannicholasb3058bd2016-07-01 08:22:01 -070036};
37
38} // namespace
39
40#endif