SkSLCodeGenerator.h 830 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #ifndef SKSL_CODEGENERATOR
  8. #define SKSL_CODEGENERATOR
  9. #include "src/sksl/SkSLOutputStream.h"
  10. #include "src/sksl/ir/SkSLProgram.h"
  11. namespace SkSL {
  12. /**
  13. * Abstract superclass of all code generators, which take a Program as input and produce code as
  14. * output.
  15. */
  16. class CodeGenerator {
  17. public:
  18. CodeGenerator(const Program* program, ErrorReporter* errors, OutputStream* out)
  19. : fProgram(*program)
  20. , fErrors(*errors)
  21. , fOut(out) {
  22. SkASSERT(program->fIsOptimized);
  23. }
  24. virtual ~CodeGenerator() {}
  25. virtual bool generateCode() = 0;
  26. protected:
  27. const Program& fProgram;
  28. ErrorReporter& fErrors;
  29. OutputStream* fOut;
  30. };
  31. } // namespace
  32. #endif