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 | */ |
| 7 | |
| 8 | #ifndef SKSL_ASTINDEXSUFFIX |
| 9 | #define SKSL_ASTINDEXSUFFIX |
| 10 | |
| 11 | #include "SkSLASTExpression.h" |
| 12 | #include "SkSLASTSuffix.h" |
| 13 | |
| 14 | namespace SkSL { |
| 15 | |
| 16 | /** |
fmalita | d214d6a | 2016-09-30 08:05:24 -0700 | [diff] [blame^] | 17 | * A bracketed expression, as in '[0]', indicating an array access. |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 18 | */ |
| 19 | struct ASTIndexSuffix : public ASTSuffix { |
| 20 | ASTIndexSuffix(std::unique_ptr<ASTExpression> expression) |
fmalita | d214d6a | 2016-09-30 08:05:24 -0700 | [diff] [blame^] | 21 | : INHERITED(expression->fPosition, ASTSuffix::kIndex_Kind) |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 22 | , fExpression(std::move(expression)) {} |
| 23 | |
| 24 | std::string description() const override { |
fmalita | d214d6a | 2016-09-30 08:05:24 -0700 | [diff] [blame^] | 25 | return "[" + fExpression->description() + "]"; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 26 | } |
| 27 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 28 | std::unique_ptr<ASTExpression> fExpression; |
| 29 | |
| 30 | typedef ASTSuffix INHERITED; |
| 31 | }; |
| 32 | |
| 33 | } // namespace |
| 34 | |
| 35 | #endif |