ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 1 | /* |
| 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 Nicholas | f3333c8 | 2017-03-31 09:33:41 -0400 | [diff] [blame^] | 7 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 8 | #ifndef SKSL_BOOLLITERAL |
| 9 | #define SKSL_BOOLLITERAL |
| 10 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 11 | #include "SkSLContext.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 12 | #include "SkSLExpression.h" |
| 13 | |
| 14 | namespace SkSL { |
| 15 | |
| 16 | /** |
| 17 | * Represents 'true' or 'false'. |
| 18 | */ |
| 19 | struct BoolLiteral : public Expression { |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 20 | BoolLiteral(const Context& context, Position position, bool value) |
| 21 | : INHERITED(position, kBoolLiteral_Kind, *context.fBool_Type) |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 22 | , fValue(value) {} |
| 23 | |
Ethan Nicholas | f3333c8 | 2017-03-31 09:33:41 -0400 | [diff] [blame^] | 24 | String description() const override { |
| 25 | return String(fValue ? "true" : "false"); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | bool isConstant() const override { |
ethannicholas | f789b38 | 2016-08-03 12:43:36 -0700 | [diff] [blame] | 29 | return true; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | const bool fValue; |
| 33 | |
| 34 | typedef Expression INHERITED; |
| 35 | }; |
| 36 | |
| 37 | } // namespace |
| 38 | |
| 39 | #endif |