SkSLField.h 1.1 KB

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