Debian Codegraph @

src/sksl/transform/SkSLProgramWriter.h

raw
1 /*
2 * Copyright 2021 Google LLC
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 SkSLProgramWriter_DEFINED
9 #define SkSLProgramWriter_DEFINED
10
11 #include "src/sksl/analysis/SkSLProgramVisitor.h"
12
13 namespace SkSL {
14
15 struct ProgramWriterTypes {
16 using Program = SkSL::Program;
17 using Expression = SkSL::Expression;
18 using Statement = SkSL::Statement;
19 using ProgramElement = SkSL::ProgramElement;
20 using UniquePtrExpression = std::unique_ptr<SkSL::Expression>;
21 using UniquePtrStatement = std::unique_ptr<SkSL::Statement>;
22 };
23
24 extern template class TProgramVisitor<ProgramWriterTypes>;
25
26 class ProgramWriter : public TProgramVisitor<ProgramWriterTypes> {
27 public:
28 // Subclass these methods if you want access to the unique_ptrs of IRNodes in a program.
29 // This will allow statements or expressions to be replaced during a visit.
30 bool visitExpressionPtr(std::unique_ptr<Expression>& e) override {
31 return this->visitExpression(*e);
32 }
33 bool visitStatementPtr(std::unique_ptr<Statement>& s) override {
34 return this->visitStatement(*s);
35 }
36 };
37
38 } // namespace SkSL
39
40 #endif