SkSLTypeReference.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_TYPEREFERENCE
  8. #define SKSL_TYPEREFERENCE
  9. #include "src/sksl/SkSLContext.h"
  10. #include "src/sksl/ir/SkSLExpression.h"
  11. namespace SkSL {
  12. /**
  13. * Represents an identifier referring to a type. This is an intermediate value: TypeReferences are
  14. * always eventually replaced by Constructors in valid programs.
  15. */
  16. struct TypeReference : public Expression {
  17. TypeReference(const Context& context, int offset, const Type& value)
  18. : INHERITED(offset, kTypeReference_Kind, *context.fInvalid_Type)
  19. , fValue(value) {}
  20. bool hasSideEffects() const override {
  21. return false;
  22. }
  23. String description() const override {
  24. return String(fValue.fName);
  25. }
  26. std::unique_ptr<Expression> clone() const override {
  27. return std::unique_ptr<Expression>(new TypeReference(fOffset, fValue, &fType));
  28. }
  29. const Type& fValue;
  30. typedef Expression INHERITED;
  31. private:
  32. TypeReference(int offset, const Type& value, const Type* type)
  33. : INHERITED(offset, kTypeReference_Kind, *type)
  34. , fValue(value) {}
  35. };
  36. } // namespace
  37. #endif