SkSLFunctionReference.h 1.4 KB

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