• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 Google Inc.
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_FUNCTIONCALL
9 #define SKSL_FUNCTIONCALL
10 
11 #include "include/private/SkTArray.h"
12 #include "src/sksl/ir/SkSLExpression.h"
13 #include "src/sksl/ir/SkSLFunctionDeclaration.h"
14 
15 namespace SkSL {
16 
17 /**
18  * A function invocation.
19  */
20 class FunctionCall final : public Expression {
21 public:
22     static constexpr Kind kExpressionKind = Kind::kFunctionCall;
23 
FunctionCall(int offset,const Type * type,const FunctionDeclaration * function,ExpressionArray arguments)24     FunctionCall(int offset, const Type* type, const FunctionDeclaration* function,
25                  ExpressionArray arguments)
26         : INHERITED(offset, kExpressionKind, type)
27         , fFunction(*function)
28         , fArguments(std::move(arguments)) {}
29 
30     // Resolves generic types, performs type conversion on arguments, determines return type, and
31     // reports errors via the ErrorReporter.
32     static std::unique_ptr<Expression> Convert(const Context& context,
33                                                int offset,
34                                                const FunctionDeclaration& function,
35                                                ExpressionArray arguments);
36 
37     // Creates the function call; reports errors via ASSERT.
38     static std::unique_ptr<Expression> Make(const Context& context,
39                                             int offset,
40                                             const Type* returnType,
41                                             const FunctionDeclaration& function,
42                                             ExpressionArray arguments);
43 
function()44     const FunctionDeclaration& function() const {
45         return fFunction;
46     }
47 
arguments()48     ExpressionArray& arguments() {
49         return fArguments;
50     }
51 
arguments()52     const ExpressionArray& arguments() const {
53         return fArguments;
54     }
55 
56     bool hasProperty(Property property) const override;
57 
58     std::unique_ptr<Expression> clone() const override;
59 
60     String description() const override;
61 
62 private:
63     const FunctionDeclaration& fFunction;
64     ExpressionArray fArguments;
65 
66     using INHERITED = Expression;
67 };
68 
69 }  // namespace SkSL
70 
71 #endif
72