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 "src/sksl/ir/SkSLBlock.h" 12 #include "src/sksl/ir/SkSLFunctionDeclaration.h" 13 #include "src/sksl/ir/SkSLProgramElement.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)24 FunctionPrototype(Position pos, const FunctionDeclaration* declaration) 25 : INHERITED(pos, kIRNodeKind) 26 , fDeclaration(declaration) {} 27 declaration()28 const FunctionDeclaration& declaration() const { 29 return *fDeclaration; 30 } 31 description()32 std::string description() const override { 33 return this->declaration().description() + ";"; 34 } 35 36 private: 37 const FunctionDeclaration* fDeclaration; 38 39 using INHERITED = ProgramElement; 40 }; 41 42 } // namespace SkSL 43 44 #endif 45