| 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_FUNCTIONREFERENCE |
| 9 | #define SKSL_FUNCTIONREFERENCE |
| 10 | |
| 11 | #include "src/sksl/SkSLContext.h" |
| 12 | #include "src/sksl/ir/SkSLExpression.h" |
| 13 | #include "src/sksl/ir/SkSLFunctionDeclaration.h" |
| 14 | |
| 15 | namespace SkSL { |
| 16 | |
| 17 | /** |
| 18 | * An identifier referring to a function name. This is an intermediate value: FunctionReferences are |
| 19 | * always eventually replaced by FunctionCalls in valid programs. |
| 20 | */ |
| 21 | struct FunctionReference : public Expression { |
| 22 | FunctionReference(const Context& context, int offset, |
| 23 | std::vector<const FunctionDeclaration*> function) |
| 24 | : INHERITED(offset, kFunctionReference_Kind, *context.fInvalid_Type) |
| 25 | , fFunctions(function) {} |
| 26 | |
| 27 | bool hasProperty(Property property) const override { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | std::unique_ptr<Expression> clone() const override { |
| 32 | return std::unique_ptr<Expression>(new FunctionReference(fOffset, fFunctions, &fType)); |
| 33 | } |
| 34 | |
| 35 | String description() const override { |
| 36 | return String("<function>" ); |
| 37 | } |
| 38 | |
| 39 | const std::vector<const FunctionDeclaration*> fFunctions; |
| 40 | |
| 41 | typedef Expression INHERITED; |
| 42 | |
| 43 | private: |
| 44 | FunctionReference(int offset, std::vector<const FunctionDeclaration*> function, |
| 45 | const Type* type) |
| 46 | : INHERITED(offset, kFunctionReference_Kind, *type) |
| 47 | , fFunctions(function) {}}; |
| 48 | |
| 49 | } // namespace SkSL |
| 50 | |
| 51 | #endif |
| 52 | |