blob: 4e1e05077811e19260eb6ca03dd25a189eb397de [file] [log] [blame]
ethannicholasb3058bd2016-07-01 08:22:01 -07001/*
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 */
Ethan Nicholasf3333c82017-03-31 09:33:41 -04007
ethannicholasb3058bd2016-07-01 08:22:01 -07008#ifndef SKSL_BOOLLITERAL
9#define SKSL_BOOLLITERAL
10
ethannicholasd598f792016-07-25 10:08:54 -070011#include "SkSLContext.h"
ethannicholasb3058bd2016-07-01 08:22:01 -070012#include "SkSLExpression.h"
13
14namespace SkSL {
15
16/**
17 * Represents 'true' or 'false'.
18 */
19struct BoolLiteral : public Expression {
ethannicholasd598f792016-07-25 10:08:54 -070020 BoolLiteral(const Context& context, Position position, bool value)
21 : INHERITED(position, kBoolLiteral_Kind, *context.fBool_Type)
ethannicholasb3058bd2016-07-01 08:22:01 -070022 , fValue(value) {}
23
Ethan Nicholasf3333c82017-03-31 09:33:41 -040024 String description() const override {
25 return String(fValue ? "true" : "false");
ethannicholasb3058bd2016-07-01 08:22:01 -070026 }
27
28 bool isConstant() const override {
ethannicholasf789b382016-08-03 12:43:36 -070029 return true;
ethannicholasb3058bd2016-07-01 08:22:01 -070030 }
31
32 const bool fValue;
33
34 typedef Expression INHERITED;
35};
36
37} // namespace
38
39#endif