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 8 #ifndef SKSL_FUNCTIONCALL 9 #define SKSL_FUNCTIONCALL 10 11 #include "SkSLExpression.h" 12 #include "SkSLFunctionDeclaration.h" 13 14 namespace SkSL { 15 16 /** 17 * A function invocation. 18 */ 19 struct FunctionCall : public Expression { 20 FunctionCall(int offset, const Type& type, const FunctionDeclaration& function, 21 std::vector<std::unique_ptr<Expression>> arguments) 22 : INHERITED(offset, kFunctionCall_Kind, type) 23 , fFunction(std::move(function)) 24 , fArguments(std::move(arguments)) {} 25 26 bool hasSideEffects() const override { 27 for (const auto& arg : fArguments) { 28 if (arg->hasSideEffects()) { 29 return true; 30 } 31 } 32 return fFunction.fModifiers.fFlags & Modifiers::kHasSideEffects_Flag; 33 } 34 35 String description() const override { 36 String result = String(fFunction.fName) + "("; 37 String separator; 38 for (size_t i = 0; i < fArguments.size(); i++) { 39 result += separator; 40 result += fArguments[i]->description(); 41 separator = ", "; 42 } 43 result += ")"; 44 return result; 45 } 46 47 const FunctionDeclaration& fFunction; 48 std::vector<std::unique_ptr<Expression>> fArguments; 49 50 typedef Expression INHERITED; 51 }; 52 53 } // namespace 54 55 #endif 56