OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SKSL_FIELD | 8 #ifndef SKSL_FIELD |
9 #define SKSL_FIELD | 9 #define SKSL_FIELD |
10 | 10 |
11 #include "SkSLModifiers.h" | 11 #include "SkSLModifiers.h" |
12 #include "SkSLPosition.h" | 12 #include "SkSLPosition.h" |
13 #include "SkSLSymbol.h" | 13 #include "SkSLSymbol.h" |
14 #include "SkSLType.h" | 14 #include "SkSLType.h" |
15 | 15 |
16 namespace SkSL { | 16 namespace SkSL { |
17 | 17 |
18 /** | 18 /** |
19 * A symbol which should be interpreted as a field access. Fields are added to t
he symboltable | 19 * A symbol which should be interpreted as a field access. Fields are added to t
he symboltable |
20 * whenever a bare reference to an identifier should refer to a struct field; in
GLSL, this is the | 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. | 21 * result of declaring anonymous interface blocks. |
22 */ | 22 */ |
23 struct Field : public Symbol { | 23 struct Field : public Symbol { |
24 Field(Position position, std::shared_ptr<Variable> owner, int fieldIndex) | 24 Field(Position position, const Variable& owner, int fieldIndex) |
25 : INHERITED(position, kField_Kind, owner->fType->fields()[fieldIndex].fName) | 25 : INHERITED(position, kField_Kind, owner.fType.fields()[fieldIndex].fName) |
26 , fOwner(owner) | 26 , fOwner(owner) |
27 , fFieldIndex(fieldIndex) {} | 27 , fFieldIndex(fieldIndex) {} |
28 | 28 |
29 virtual std::string description() const override { | 29 virtual std::string description() const override { |
30 return fOwner->description() + "." + fOwner->fType->fields()[fFieldIndex
].fName; | 30 return fOwner.description() + "." + fOwner.fType.fields()[fFieldIndex].f
Name; |
31 } | 31 } |
32 | 32 |
33 const std::shared_ptr<Variable> fOwner; | 33 const Variable& fOwner; |
34 const int fFieldIndex; | 34 const int fFieldIndex; |
35 | 35 |
36 typedef Symbol INHERITED; | 36 typedef Symbol INHERITED; |
37 }; | 37 }; |
38 | 38 |
39 } // namespace SkSL | 39 } // namespace SkSL |
40 | 40 |
41 #endif | 41 #endif |
OLD | NEW |