xref: /aosp_15_r20/external/skia/src/sksl/ir/SkSLDiscardStatement.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2016 Google Inc.
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_DISCARDSTATEMENT
9 #define SKSL_DISCARDSTATEMENT
10 
11 #include "src/sksl/SkSLPosition.h"
12 #include "src/sksl/ir/SkSLIRNode.h"
13 #include "src/sksl/ir/SkSLStatement.h"
14 
15 #include <memory>
16 #include <string>
17 
18 namespace SkSL {
19 
20 class Context;
21 
22 /**
23  * A 'discard' statement.
24  */
25 class DiscardStatement final : public Statement {
26 public:
27     inline static constexpr Kind kIRNodeKind = Kind::kDiscard;
28 
DiscardStatement(Position pos)29     DiscardStatement(Position pos) : INHERITED(pos, kIRNodeKind) {}
30 
31     // Creates a discard-statement; reports errors via ErrorReporter.
32     static std::unique_ptr<Statement> Convert(const Context& context, Position pos);
33 
34     // Creates a discard-statement; reports errors via SkASSERT.
35     static std::unique_ptr<Statement> Make(const Context& context, Position pos);
36 
description()37     std::string description() const override {
38         return "discard;";
39     }
40 
41 private:
42     using INHERITED = Statement;
43 };
44 
45 }  // namespace SkSL
46 
47 #endif
48