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,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 description()37 std::string description() const override { 38 return this->declaration().description() + ";"; 39 } 40 41 private: 42 const FunctionDeclaration* fDeclaration; 43 bool fBuiltin; 44 45 using INHERITED = ProgramElement; 46 }; 47 48 } // namespace SkSL 49 50 #endif 51