blob: 6a0cb501638828e0ab27a7f65b2167196f78d1b6 [file] [log] [blame]
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SKSL_SETTING
#define SKSL_SETTING
#include "src/sksl/SkSLContext.h"
#include "src/sksl/ir/SkSLExpression.h"
namespace SkSL {
/**
* Represents a compile-time constant setting, such as sk_Caps.fbFetchSupport. These IRNodes should
* only exist in a dehydrated module. These nodes are replaced with the value of the setting during
* rehydration or compilation (i.e., whenever fReplaceSettings is true).
*/
class Setting final : public Expression {
public:
static constexpr Kind kExpressionKind = Kind::kSetting;
Setting(int offset, String name, const Type* type)
: INHERITED(offset, kExpressionKind, type)
, fName(std::move(name)) {}
static std::unique_ptr<Expression> Make(const Context& context, int offset, const String& name);
std::unique_ptr<Expression> clone() const override {
return std::make_unique<Setting>(fOffset, this->name(), &this->type());
}
const String& name() const {
return fName;
}
String description() const override {
return this->name();
}
bool hasProperty(Property property) const override {
return false;
}
private:
String fName;
using INHERITED = Expression;
};
} // namespace SkSL
#endif