• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 kProgramElementKind = Kind::kFunctionPrototype;
23 
FunctionPrototype(int line,const FunctionDeclaration * declaration,bool builtin)24     FunctionPrototype(int line, const FunctionDeclaration* declaration, bool builtin)
25             : INHERITED(line, kProgramElementKind)
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>(fLine, &this->declaration(), /*builtin=*/false);
39     }
40 
description()41     std::string description() const override {
42         return this->declaration().description() + ";";
43     }
44 
45 private:
46     const FunctionDeclaration* fDeclaration;
47     bool fBuiltin;
48 
49     using INHERITED = ProgramElement;
50 };
51 
52 }  // namespace SkSL
53 
54 #endif
55