2016-07-01 15:22:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2017-03-31 16:04:34 +00:00
|
|
|
|
2016-07-01 15:22:01 +00:00
|
|
|
#ifndef SKSL_CODEGENERATOR
|
|
|
|
#define SKSL_CODEGENERATOR
|
|
|
|
|
|
|
|
#include "ir/SkSLProgram.h"
|
|
|
|
|
|
|
|
namespace SkSL {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract superclass of all code generators, which take a Program as input and produce code as
|
|
|
|
* output.
|
|
|
|
*/
|
|
|
|
class CodeGenerator {
|
|
|
|
public:
|
2017-03-31 16:04:34 +00:00
|
|
|
CodeGenerator(const Program* program, ErrorReporter* errors, SkWStream* out)
|
2016-12-12 20:33:30 +00:00
|
|
|
: fProgram(*program)
|
|
|
|
, fErrors(*errors)
|
|
|
|
, fOut(out) {}
|
|
|
|
|
2016-08-03 19:43:36 +00:00
|
|
|
virtual ~CodeGenerator() {}
|
2016-11-28 21:30:17 +00:00
|
|
|
|
2016-12-12 20:33:30 +00:00
|
|
|
virtual bool generateCode() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
const Program& fProgram;
|
|
|
|
ErrorReporter& fErrors;
|
2017-03-31 16:04:34 +00:00
|
|
|
SkWStream* fOut;
|
2016-07-01 15:22:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|