blob: 44d91fa4c4c11e4da9270bbab49130ebe9f49092 [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 */
7
8#ifndef SKSL_ASTINDEXSUFFIX
9#define SKSL_ASTINDEXSUFFIX
10
11#include "SkSLASTExpression.h"
12#include "SkSLASTSuffix.h"
13
14namespace SkSL {
15
16/**
mtklein4824cf42016-10-10 19:41:32 -070017 * A bracketed expression, as in '[0]', indicating an array access.
ethannicholasb3058bd2016-07-01 08:22:01 -070018 */
19struct ASTIndexSuffix : public ASTSuffix {
20 ASTIndexSuffix(std::unique_ptr<ASTExpression> expression)
mtklein4824cf42016-10-10 19:41:32 -070021 : INHERITED(expression->fPosition, ASTSuffix::kIndex_Kind)
ethannicholasb3058bd2016-07-01 08:22:01 -070022 , fExpression(std::move(expression)) {}
23
24 std::string description() const override {
mtklein4824cf42016-10-10 19:41:32 -070025 return "[" + fExpression->description() + "]";
ethannicholasb3058bd2016-07-01 08:22:01 -070026 }
27
ethannicholasb3058bd2016-07-01 08:22:01 -070028 std::unique_ptr<ASTExpression> fExpression;
29
30 typedef ASTSuffix INHERITED;
31};
32
33} // namespace
34
35#endif