• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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_APPENDSTAGE
9 #define SKSL_APPENDSTAGE
10 
11 #ifndef SKSL_STANDALONE
12 
13 #include "SkRasterPipeline.h"
14 #include "SkSLContext.h"
15 #include "SkSLExpression.h"
16 
17 namespace SkSL {
18 
19 struct AppendStage : public Expression {
AppendStageAppendStage20     AppendStage(const Context& context, int offset, SkRasterPipeline::StockStage stage,
21                 std::vector<std::unique_ptr<Expression>> arguments)
22     : INHERITED(offset, kAppendStage_Kind, *context.fVoid_Type)
23     , fStage(stage)
24     , fArguments(std::move(arguments)) {}
25 
cloneAppendStage26     std::unique_ptr<Expression> clone() const override {
27         std::vector<std::unique_ptr<Expression>> cloned;
28         for (const auto& arg : fArguments) {
29             cloned.push_back(arg->clone());
30         }
31         return std::unique_ptr<Expression>(new AppendStage(fOffset, fStage, std::move(cloned),
32                                                            &fType));
33     }
34 
descriptionAppendStage35     String description() const override {
36         String result = "append(";
37         const char* separator = "";
38         for (const auto& a : fArguments) {
39             result += separator;
40             result += a->description();
41             separator = ", ";
42         }
43         result += ")";
44         return result;
45     }
46 
hasSideEffectsAppendStage47     bool hasSideEffects() const override {
48         return true;
49     }
50 
51     SkRasterPipeline::StockStage fStage;
52 
53     std::vector<std::unique_ptr<Expression>> fArguments;
54 
55     typedef Expression INHERITED;
56 
57 private:
AppendStageAppendStage58     AppendStage(int offset, SkRasterPipeline::StockStage stage,
59                 std::vector<std::unique_ptr<Expression>> arguments, const Type* type)
60     : INHERITED(offset, kAppendStage_Kind, *type)
61     , fStage(stage)
62     , fArguments(std::move(arguments)) {}
63 
64 };
65 
66 } // namespace
67 
68 #endif // SKSL_STANDALONE
69 
70 #endif // SKSL_APPENDSTAGE
71