aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ast/SkSLASTSuffix.h
blob: 64178c7682595f5646653d5598e973c84bcab045 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * 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_ASTSUFFIX
#define SKSL_ASTSUFFIX

#include "SkSLASTPositionNode.h"
#include "SkSLASTExpression.h"

namespace SkSL {

/**
 * This and its subclasses represents expression suffixes, such as '[0]' or '.rgb'. Suffixes are not
 * expressions in and of themselves; they are attached to expressions to modify them.
 */
struct ASTSuffix : public ASTPositionNode {
    enum Kind {
        kIndex_Kind,
        kCall_Kind,
        kField_Kind,
        kPostIncrement_Kind,
        kPostDecrement_Kind
    };

    ASTSuffix(Position position, Kind kind)
    : INHERITED(position)
    , fKind(kind) {}

    SkString description() const override {
        switch (fKind) {
            case kPostIncrement_Kind:
                return SkString("++");
            case kPostDecrement_Kind:
                return SkString("--");
            default:
                ABORT("unsupported suffix operator");
        }        
    }

    Kind fKind;

    typedef ASTPositionNode INHERITED;
};

} // namespace

#endif