Flutter Engine
The Flutter Engine
SkSLFieldSymbol.h
Go to the documentation of this file.
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_FIELD
9#define SKSL_FIELD
10
15
16namespace SkSL {
17
18/**
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.
22 */
23class FieldSymbol final : public Symbol {
24public:
25 inline static constexpr Kind kIRNodeKind = Kind::kField;
26
29 owner->type().fields()[fieldIndex].fType)
30 , fOwner(owner)
31 , fFieldIndex(fieldIndex) {}
32
33 int fieldIndex() const {
34 return fFieldIndex;
35 }
36
37 const Variable& owner() const {
38 return *fOwner;
39 }
40
41 std::string description() const override {
42 return this->owner().name().empty()
43 ? std::string(this->name())
44 : (this->owner().description() + "." + std::string(this->name()));
45 }
46
47private:
48 const Variable* fOwner;
49 int fFieldIndex;
50
51 using INHERITED = Symbol;
52};
53
54} // namespace SkSL
55
56#endif
const char * fName
SkPoint pos
static constexpr Kind kIRNodeKind
FieldSymbol(Position pos, const Variable *owner, int fieldIndex)
std::string description() const override
const Variable & owner() const
int fieldIndex() const
std::string_view name() const
Definition: SkSLSymbol.h:51
Symbol(Position pos, Kind kind, std::string_view name, const Type *type=nullptr)
Definition: SkSLSymbol.h:31
const Type & type() const
Definition: SkSLSymbol.h:42
std::string description() const override
Definition: SkSLVariable.h:134
SymbolKind
Definition: SkSLIRNode.h:32