2 * Copyright 2016 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
11 #include "include/private/SkSLModifiers.h"
12 #include "include/private/SkSLSymbol.h"
13 #include "src/sksl/ir/SkSLType.h"
14 #include "src/sksl/ir/SkSLVariable.h"
19 * A symbol which should be interpreted as a field access. Fields are added to the symboltable
20 * whenever a bare reference to an identifier should refer to a struct field; in GLSL, this is the
21 * result of declaring anonymous interface blocks.
23 class Field final : public Symbol {
25 inline static constexpr Kind kSymbolKind = Kind::kField;
27 Field(Position pos, const Variable* owner, int fieldIndex)
28 : INHERITED(pos, kSymbolKind, owner->type().fields()[fieldIndex].fName,
29 owner->type().fields()[fieldIndex].fType)
31 , fFieldIndex(fieldIndex) {}
33 int fieldIndex() const {
37 const Variable& owner() const {
41 std::string description() const override {
42 return this->owner().description() + "." + std::string(this->name());
46 const Variable* fOwner;
49 using INHERITED = Symbol;