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 13namespace 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 */ 21class CodeStringExpression final : public Expression { 22public: 23 inline static constexpr Kind kExpressionKind = Kind::kCodeString; 24 25 CodeStringExpression(String code, const Type* type) 26 : INHERITED(/*line=*/-1, kExpressionKind, type) 27 , fCode(std::move(code)) {} 28 29 bool hasProperty(Property property) const override { 30 return false; 31 } 32 33 std::unique_ptr<Expression> clone() const override { 34 return std::make_unique<CodeStringExpression>(fCode, &this->type()); 35 } 36 37 String description() const override { 38 return fCode; 39 } 40 41private: 42 String fCode; 43 44 using INHERITED = Expression; 45}; 46 47} // namespace SkSL 48 49#endif 50