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_PROGRAMELEMENT 9 #define SKSL_PROGRAMELEMENT 10 11 #include "include/private/SkSLIRNode.h" 12 13 #include <memory> 14 15 namespace SkSL { 16 17 /** 18 * Represents a top-level element (e.g. function or global variable) in a program. 19 */ 20 class ProgramElement : public IRNode { 21 public: 22 using Kind = ProgramElementKind; 23 ProgramElement(Position pos,Kind kind)24 ProgramElement(Position pos, Kind kind) 25 : INHERITED(pos, (int) kind) { 26 SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast); 27 } 28 kind()29 Kind kind() const { 30 return (Kind) fKind; 31 } 32 33 virtual std::unique_ptr<ProgramElement> clone() const = 0; 34 35 private: 36 using INHERITED = IRNode; 37 }; 38 39 } // namespace SkSL 40 41 #endif 42