Debian Codegraph @

src/sksl/ir/SkSLChildCall.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 SKSL_CHILDCALL
9 #define SKSL_CHILDCALL
10
11 #include "src/sksl/SkSLDefines.h"
12 #include "src/sksl/SkSLPosition.h"
13 #include "src/sksl/ir/SkSLExpression.h"
14 #include "src/sksl/ir/SkSLIRNode.h"
15
16 #include <cstdint>
17 #include <memory>
18 #include <string>
19 #include <utility>
20
21 namespace SkSL {
22
23 class Context;
24 class Type;
25 class Variable;
26 enum class OperatorPrecedence : uint8_t;
27
28 /**
29 * A call to a child effect object (shader, color filter, or blender).
30 */
31 class ChildCall final : public Expression {
32 public:
33 inline static constexpr Kind kIRNodeKind = Kind::kChildCall;
34
35 ChildCall(Position pos, const Type* type, const Variable* child, ExpressionArray arguments)
36 : INHERITED(pos, kIRNodeKind, type)
37 , fChild(*child)
38 , fArguments(std::move(arguments)) {}
39
40 // Creates the child call; reports errors via ASSERT.
41 static std::unique_ptr<Expression> Make(const Context& context,
42 Position pos,
43 const Type* returnType,
44 const Variable& child,
45 ExpressionArray arguments);
46
47 const Variable& child() const {
48 return fChild;
49 }
50
51 ExpressionArray& arguments() {
52 return fArguments;
53 }
54
55 const ExpressionArray& arguments() const {
56 return fArguments;
57 }
58
59 std::unique_ptr<Expression> clone(Position pos) const override;
60
61 std::string description(OperatorPrecedence) const override;
62
63 private:
64 const Variable& fChild;
65 ExpressionArray fArguments;
66
67 using INHERITED = Expression;
68 };
69
70 } // namespace SkSL
71
72 #endif