summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/sksl/ir/SkSLFunctionCall.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/skia/skia/src/sksl/ir/SkSLFunctionCall.h')
-rw-r--r--gfx/skia/skia/src/sksl/ir/SkSLFunctionCall.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/sksl/ir/SkSLFunctionCall.h b/gfx/skia/skia/src/sksl/ir/SkSLFunctionCall.h
new file mode 100644
index 0000000000..9f31a52772
--- /dev/null
+++ b/gfx/skia/skia/src/sksl/ir/SkSLFunctionCall.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SKSL_FUNCTIONCALL
+#define SKSL_FUNCTIONCALL
+
+#include "include/private/SkSLDefines.h"
+#include "include/private/SkSLIRNode.h"
+#include "include/sksl/SkSLPosition.h"
+#include "src/sksl/ir/SkSLExpression.h"
+
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <utility>
+
+namespace SkSL {
+
+class Context;
+class FunctionDeclaration;
+class Type;
+enum class OperatorPrecedence : uint8_t;
+
+/**
+ * A function invocation.
+ */
+class FunctionCall final : public Expression {
+public:
+ inline static constexpr Kind kIRNodeKind = Kind::kFunctionCall;
+
+ FunctionCall(Position pos, const Type* type, const FunctionDeclaration* function,
+ ExpressionArray arguments)
+ : INHERITED(pos, kIRNodeKind, type)
+ , fFunction(*function)
+ , fArguments(std::move(arguments)) {}
+
+ // Resolves generic types, performs type conversion on arguments, determines return type, and
+ // reports errors via the ErrorReporter.
+ static std::unique_ptr<Expression> Convert(const Context& context,
+ Position pos,
+ const FunctionDeclaration& function,
+ ExpressionArray arguments);
+
+ static std::unique_ptr<Expression> Convert(const Context& context,
+ Position pos,
+ std::unique_ptr<Expression> functionValue,
+ ExpressionArray arguments);
+
+ // Creates the function call; reports errors via ASSERT.
+ static std::unique_ptr<Expression> Make(const Context& context,
+ Position pos,
+ const Type* returnType,
+ const FunctionDeclaration& function,
+ ExpressionArray arguments);
+
+ static const FunctionDeclaration* FindBestFunctionForCall(const Context& context,
+ const FunctionDeclaration* overloads,
+ const ExpressionArray& arguments);
+
+ const FunctionDeclaration& function() const {
+ return fFunction;
+ }
+
+ ExpressionArray& arguments() {
+ return fArguments;
+ }
+
+ const ExpressionArray& arguments() const {
+ return fArguments;
+ }
+
+ std::unique_ptr<Expression> clone(Position pos) const override;
+
+ std::string description(OperatorPrecedence) const override;
+
+private:
+ const FunctionDeclaration& fFunction;
+ ExpressionArray fArguments;
+
+ using INHERITED = Expression;
+};
+
+} // namespace SkSL
+
+#endif