Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLConstructorScalarCast.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_SCALAR_CAST
9#define SKSL_CONSTRUCTOR_SCALAR_CAST
10
15
16#include <memory>
17#include <utility>
18
19namespace SkSL {
20
21class Context;
22class ExpressionArray;
23class Type;
24
25/**
26 * Represents the construction of a scalar cast, such as `float(intVariable)`.
27 *
28 * These always contain exactly 1 scalar of a differing type, and are never constant.
29 */
31public:
32 inline static constexpr Kind kIRNodeKind = Kind::kConstructorScalarCast;
33
34 ConstructorScalarCast(Position pos, const Type& type, std::unique_ptr<Expression> arg)
35 : INHERITED(pos, kIRNodeKind, &type, std::move(arg)) {}
36
37 // ConstructorScalarCast::Convert will typecheck and create scalar-constructor expressions.
38 // Reports errors via the ErrorReporter; returns null on error.
39 static std::unique_ptr<Expression> Convert(const Context& context,
41 const Type& rawType,
43
44 // ConstructorScalarCast::Make casts a scalar expression. Casts that can be evaluated at
45 // compile-time will do so (e.g. `int(4.1)` --> `Literal(int 4)`). Errors reported via SkASSERT.
46 static std::unique_ptr<Expression> Make(const Context& context,
48 const Type& type,
49 std::unique_ptr<Expression> arg);
50
51 std::unique_ptr<Expression> clone(Position pos) const override {
52 return std::make_unique<ConstructorScalarCast>(pos, this->type(), argument()->clone());
53 }
54
55private:
56 using INHERITED = SingleArgumentConstructor;
57};
58
59} // namespace SkSL
60
61#endif
SkPoint pos
ConstructorScalarCast(Position pos, const Type &type, std::unique_ptr< Expression > arg)
static std::unique_ptr< Expression > Convert(const Context &context, Position pos, const Type &rawType, ExpressionArray args)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
std::unique_ptr< Expression > clone(Position pos) const override
virtual const Type & type() const
std::unique_ptr< Expression > clone() const
std::unique_ptr< Expression > & argument()
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
ExpressionKind
Definition SkSLIRNode.h:62
Definition ref_ptr.h:256