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 struct ASTNode; 18 19 /** 20 * A function prototype (a function declaration as a top-level program element) 21 */ 22 class FunctionPrototype final : public ProgramElement { 23 public: 24 inline static constexpr Kind kProgramElementKind = Kind::kFunctionPrototype; 25 FunctionPrototype(int line,const FunctionDeclaration * declaration,bool builtin)26 FunctionPrototype(int line, const FunctionDeclaration* declaration, bool builtin) 27 : INHERITED(line, kProgramElementKind) 28 , fDeclaration(declaration) 29 , fBuiltin(builtin) {} 30 declaration()31 const FunctionDeclaration& declaration() const { 32 return *fDeclaration; 33 } 34 isBuiltin()35 bool isBuiltin() const { 36 return fBuiltin; 37 } 38 clone()39 std::unique_ptr<ProgramElement> clone() const override { 40 return std::make_unique<FunctionPrototype>(fLine, &this->declaration(), /*builtin=*/false); 41 } 42 description()43 String description() const override { 44 return this->declaration().description() + ";"; 45 } 46 47 private: 48 const FunctionDeclaration* fDeclaration; 49 bool fBuiltin; 50 51 using INHERITED = ProgramElement; 52 }; 53 54 } // namespace SkSL 55 56 #endif 57