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
15namespace 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 */
21struct 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#ifdef SK_DEBUG
36 String description() const override {
37 return String("<function>");
38 }
39#endif
40
41 const std::vector<const FunctionDeclaration*> fFunctions;
42
43 typedef Expression INHERITED;
44
45private:
46 FunctionReference(int offset, std::vector<const FunctionDeclaration*> function,
47 const Type* type)
48 : INHERITED(offset, kFunctionReference_Kind, *type)
49 , fFunctions(function) {}};
50
51} // namespace
52
53#endif
54