Flutter Engine
The Flutter Engine
SkSLEmptyExpression.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 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#ifndef SkSLEmptyExpression_DEFINED
8#define SkSLEmptyExpression_DEFINED
9
14
15namespace SkSL {
16
17/**
18 * The EmptyExpression is a void-typed expression with nothing inside. EmptyExpressions can exist
19 * inside an ExpressionStatement; this construct is functionally equivalent to a Nop.
20 */
22public:
23 inline static constexpr Kind kIRNodeKind = Kind::kEmpty;
24
25 static std::unique_ptr<Expression> Make(Position pos, const Context& context) {
26 return std::make_unique<EmptyExpression>(pos, context.fTypes.fVoid.get());
27 }
28
32 }
33
34 std::unique_ptr<Expression> clone(Position pos) const override {
35 return std::make_unique<EmptyExpression>(pos, &this->type());
36 }
37
38 std::string description(OperatorPrecedence) const override {
39 // There's no way in GLSL to directly emit a void-typed expression.
40 // `false` is used here as a placeholder expression; the value of a void-typed expression is
41 // never meaningful, so this should be a decent substitute.
42 return "false";
43 }
44
45private:
46 using INHERITED = Expression;
47};
48
49} // namespace SkSL
50
51#endif // SkSLEmptyExpression_DEFINED
SkPoint pos
#define SkASSERT(cond)
Definition: SkAssert.h:116
const std::unique_ptr< Type > fVoid
const BuiltinTypes & fTypes
Definition: SkSLContext.h:30
std::unique_ptr< Expression > clone(Position pos) const override
static constexpr Kind kIRNodeKind
EmptyExpression(Position pos, const Type *type)
static std::unique_ptr< Expression > Make(Position pos, const Context &context)
std::string description(OperatorPrecedence) const override
Expression(Position pos, Kind kind, const Type *type)
const Type & type() const
bool isVoid() const
Definition: SkSLType.h:496
OperatorPrecedence
Definition: SkSLOperator.h:57
ExpressionKind
Definition: SkSLIRNode.h:62