aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ir/SkSLVariable.h
blob: 39b8482a7b06ca1101d8a4f50ca861b907cbeb4f (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
52
53
54
55
/*
 * 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_VARIABLE
#define SKSL_VARIABLE

#include "SkSLModifiers.h"
#include "SkSLPosition.h"
#include "SkSLSymbol.h"
#include "SkSLType.h"

namespace SkSL {

/**
 * Represents a variable, whether local, global, or a function parameter. This represents the
 * variable itself (the storage location), which is shared between all VariableReferences which
 * read or write that storage location.
 */
struct Variable : public Symbol {
    enum Storage {
        kGlobal_Storage,
        kLocal_Storage,
        kParameter_Storage
    };

    Variable(Position position, Modifiers modifiers, SkString name, const Type& type,
             Storage storage)
    : INHERITED(position, kVariable_Kind, std::move(name))
    , fModifiers(modifiers)
    , fType(type)
    , fStorage(storage)
    , fIsReadFrom(false)
    , fIsWrittenTo(false) {}

    virtual SkString description() const override {
        return fModifiers.description() + fType.fName + " " + fName;
    }

    mutable Modifiers fModifiers;
    const Type& fType;
    const Storage fStorage;

    mutable bool fIsReadFrom;
    mutable bool fIsWrittenTo;

    typedef Symbol INHERITED;
};

} // namespace SkSL

#endif