1 /* 2 * Copyright 2020 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_CODESTRINGEXPRESSION 9 #define SKSL_CODESTRINGEXPRESSION 10 11 #include "src/sksl/ir/SkSLExpression.h" 12 13 namespace SkSL { 14 15 /** 16 * Represents a literal string of SkSL code. This is only valid within SkSL DSL code. 17 * TODO(skia:11330): This class is intended as a temporary measure to support a couple of spots 18 * within Skia that are currently generating raw strings of code. These will eventually transition 19 * to producing Expressions, allowing this class to be deleted. 20 */ 21 class CodeStringExpression final : public Expression { 22 public: 23 static constexpr Kind kExpressionKind = Kind::kCodeString; 24 CodeStringExpression(String code,const Type * type)25 CodeStringExpression(String code, const Type* type) 26 : INHERITED(/*offset=*/-1, kExpressionKind, type) 27 , fCode(std::move(code)) {} 28 hasProperty(Property property)29 bool hasProperty(Property property) const override { 30 return false; 31 } 32 clone()33 std::unique_ptr<Expression> clone() const override { 34 return std::make_unique<CodeStringExpression>(fCode, &this->type()); 35 } 36 description()37 String description() const override { 38 return fCode; 39 } 40 41 private: 42 String fCode; 43 44 using INHERITED = Expression; 45 }; 46 47 } // namespace SkSL 48 49 #endif 50