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 "include/private/SkTArray.h" 12 #include "src/sksl/ir/SkSLExpression.h" 13 #include "src/sksl/ir/SkSLVariable.h" 14 15 namespace SkSL { 16 17 /** 18 * A call to a child effect object (shader, color filter, or blender). 19 */ 20 class ChildCall final : public Expression { 21 public: 22 inline static constexpr Kind kExpressionKind = Kind::kChildCall; 23 ChildCall(int line,const Type * type,const Variable * child,ExpressionArray arguments)24 ChildCall(int line, const Type* type, const Variable* child, ExpressionArray arguments) 25 : INHERITED(line, kExpressionKind, type) 26 , fChild(*child) 27 , fArguments(std::move(arguments)) {} 28 29 // Creates the child call; reports errors via ASSERT. 30 static std::unique_ptr<Expression> Make(const Context& context, 31 int line, 32 const Type* returnType, 33 const Variable& child, 34 ExpressionArray arguments); 35 child()36 const Variable& child() const { 37 return fChild; 38 } 39 arguments()40 ExpressionArray& arguments() { 41 return fArguments; 42 } 43 arguments()44 const ExpressionArray& arguments() const { 45 return fArguments; 46 } 47 48 bool hasProperty(Property property) const override; 49 50 std::unique_ptr<Expression> clone() const override; 51 52 String description() const override; 53 54 private: 55 const Variable& fChild; 56 ExpressionArray fArguments; 57 58 using INHERITED = Expression; 59 }; 60 61 } // namespace SkSL 62 63 #endif 64