Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLMethodReference.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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_METHODREFERENCE
9#define SKSL_METHODREFERENCE
10
14
15namespace SkSL {
16
17class FunctionDeclaration;
18
19/**
20 * An identifier referring to a method name, along with an instance for the call.
21 * This is an intermediate value: MethodReferences are always eventually replaced by FunctionCalls
22 * in valid programs.
23 *
24 * Method calls are only supported on effect-child types, and they all resolve to intrinsics
25 * prefixed with '$', and taking the 'self' object as the last parameter. For example:
26 *
27 * uniform shader child;
28 * ...
29 * child.eval(xy) --> $eval(xy, child)
30 */
31class MethodReference final : public Expression {
32public:
33 inline static constexpr Kind kIRNodeKind = Kind::kMethodReference;
34
35 MethodReference(const Context& context,
37 std::unique_ptr<Expression> self,
39 : INHERITED(pos, kIRNodeKind, context.fTypes.fInvalid.get())
40 , fSelf(std::move(self))
41 , fOverloadChain(overloadChain) {}
42
43 std::unique_ptr<Expression>& self() { return fSelf; }
44 const std::unique_ptr<Expression>& self() const { return fSelf; }
45
46 const FunctionDeclaration* overloadChain() const { return fOverloadChain; }
47
48 std::unique_ptr<Expression> clone(Position pos) const override {
49 return std::unique_ptr<Expression>(new MethodReference(
50 pos, this->self()->clone(), this->overloadChain(), &this->type()));
51 }
52
53 std::string description(OperatorPrecedence) const override {
54 return "<method>";
55 }
56
57private:
59 std::unique_ptr<Expression> self,
61 const Type* type)
62 : INHERITED(pos, kIRNodeKind, type)
63 , fSelf(std::move(self))
64 , fOverloadChain(overloadChain) {}
65
66 std::unique_ptr<Expression> fSelf;
67 const FunctionDeclaration* fOverloadChain;
68
69 using INHERITED = Expression;
70};
71
72} // namespace SkSL
73
74#endif
SkPoint pos
virtual const Type & type() const
std::unique_ptr< Expression > clone() const
const FunctionDeclaration * overloadChain() const
std::string description(OperatorPrecedence) const override
const std::unique_ptr< Expression > & self() const
std::unique_ptr< Expression > & self()
std::unique_ptr< Expression > clone(Position pos) const override
MethodReference(const Context &context, Position pos, std::unique_ptr< Expression > self, const FunctionDeclaration *overloadChain)
static constexpr Kind kIRNodeKind
OperatorPrecedence
ExpressionKind
Definition SkSLIRNode.h:62
Definition ref_ptr.h:256