Line data Source code
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 :
11 : #include "SkSLModifiers.h"
12 : #include "SkSLPosition.h"
13 : #include "SkSLSymbol.h"
14 : #include "SkSLType.h"
15 : #include "SkSLVariable.h"
16 :
17 : namespace SkSL {
18 :
19 : /**
20 : * A symbol which should be interpreted as a field access. Fields are added to the symboltable
21 : * whenever a bare reference to an identifier should refer to a struct field; in GLSL, this is the
22 : * result of declaring anonymous interface blocks.
23 : */
24 0 : struct Field : public Symbol {
25 0 : Field(Position position, const Variable& owner, int fieldIndex)
26 0 : : INHERITED(position, kField_Kind, owner.fType.fields()[fieldIndex].fName)
27 : , fOwner(owner)
28 0 : , fFieldIndex(fieldIndex) {}
29 :
30 0 : virtual String description() const override {
31 0 : return fOwner.description() + "." + fOwner.fType.fields()[fFieldIndex].fName;
32 : }
33 :
34 : const Variable& fOwner;
35 : const int fFieldIndex;
36 :
37 : typedef Symbol INHERITED;
38 : };
39 :
40 : } // namespace SkSL
41 :
42 : #endif
|