Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLConstructorArrayCast.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_CONSTRUCTOR_ARRAY_CAST
9#define SKSL_CONSTRUCTOR_ARRAY_CAST
10
15
16#include <memory>
17#include <utility>
18
19namespace SkSL {
20
21class Context;
22class Type;
23
24/**
25 * Represents the typecasting of an array. Arrays cannot be directly casted in SkSL (or GLSL), but
26 * type narrowing can cause an array to be implicitly casted. For instance, the expression
27 * `myHalf2Array == float[2](a, b)` should be allowed when narrowing conversions are enabled; this
28 * constructor allows the necessary array-type conversion to be represented in IR.
29 *
30 * These always contain exactly 1 array of matching size, and are never constant.
31 */
33public:
34 inline static constexpr Kind kIRNodeKind = Kind::kConstructorArrayCast;
35
36 ConstructorArrayCast(Position pos, const Type& type, std::unique_ptr<Expression> arg)
37 : INHERITED(pos, kIRNodeKind, &type, std::move(arg)) {}
38
39 static std::unique_ptr<Expression> Make(const Context& context,
41 const Type& type,
42 std::unique_ptr<Expression> arg);
43
44 std::unique_ptr<Expression> clone(Position pos) const override {
45 return std::make_unique<ConstructorArrayCast>(pos, this->type(), argument()->clone());
46 }
47
48private:
49 using INHERITED = SingleArgumentConstructor;
50};
51
52} // namespace SkSL
53
54#endif
SkPoint pos
std::unique_ptr< Expression > clone(Position pos) const override
ConstructorArrayCast(Position pos, const Type &type, std::unique_ptr< Expression > arg)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
virtual const Type & type() const
std::unique_ptr< Expression > clone() const
std::unique_ptr< Expression > & argument()
ExpressionKind
Definition SkSLIRNode.h:62
Definition ref_ptr.h:256