1 /* 2 * Copyright 2020 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_FUNCTIONPROTOTYPE 9 #define SKSL_FUNCTIONPROTOTYPE 10 11 #include "include/private/SkSLProgramElement.h" 12 #include "src/sksl/ir/SkSLBlock.h" 13 #include "src/sksl/ir/SkSLFunctionDeclaration.h" 14 15 namespace SkSL { 16 17 /** 18 * A function prototype (a function declaration as a top-level program element) 19 */ 20 class FunctionPrototype final : public ProgramElement { 21 public: 22 inline static constexpr Kind kIRNodeKind = Kind::kFunctionPrototype; 23 FunctionPrototype(Position pos,const FunctionDeclaration * declaration,bool builtin)24 FunctionPrototype(Position pos, const FunctionDeclaration* declaration, bool builtin) 25 : INHERITED(pos, kIRNodeKind) 26 , fDeclaration(declaration) 27 , fBuiltin(builtin) {} 28 declaration()29 const FunctionDeclaration& declaration() const { 30 return *fDeclaration; 31 } 32 isBuiltin()33 bool isBuiltin() const { 34 return fBuiltin; 35 } 36 clone()37 std::unique_ptr<ProgramElement> clone() const override { 38 return std::make_unique<FunctionPrototype>(fPosition, &this->declaration(), 39 /*builtin=*/false); 40 } 41 description()42 std::string description() const override { 43 return this->declaration().description() + ";"; 44 } 45 46 private: 47 const FunctionDeclaration* fDeclaration; 48 bool fBuiltin; 49 50 using INHERITED = ProgramElement; 51 }; 52 53 } // namespace SkSL 54 55 #endif 56