• 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 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     static constexpr Kind kProgramElementKind = Kind::kFunctionPrototype;
25 
FunctionPrototype(int offset,const FunctionDeclaration * declaration,bool builtin)26     FunctionPrototype(int offset, const FunctionDeclaration* declaration, bool builtin)
27             : INHERITED(offset, 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>(fOffset, &this->declaration(),
41                                                    /*builtin=*/false);
42     }
43 
description()44     String description() const override {
45         return this->declaration().description() + ";";
46     }
47 
48 private:
49     const FunctionDeclaration* fDeclaration;
50     bool fBuiltin;
51 
52     using INHERITED = ProgramElement;
53 };
54 
55 }  // namespace SkSL
56 
57 #endif
58