Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 Google LLC |
| 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_DSL_EXPRESSION |
| 9 | #define SKSL_DSL_EXPRESSION |
| 10 | |
Ethan Nicholas | d0f4d0d | 2021-06-23 13:51:55 -0400 | [diff] [blame] | 11 | #include "include/core/SkStringView.h" |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 12 | #include "include/core/SkTypes.h" |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 13 | #include "include/private/SkTArray.h" |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 14 | #include "include/sksl/DSLWrapper.h" |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 15 | #include "include/sksl/SkSLErrorReporter.h" |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 16 | |
| 17 | #include <cstdint> |
| 18 | #include <memory> |
| 19 | |
Ethan Nicholas | 5b1ae4b | 2021-09-16 10:08:20 -0400 | [diff] [blame] | 20 | #if defined(__has_cpp_attribute) && __has_cpp_attribute(clang::reinitializes) |
| 21 | #define SK_CLANG_REINITIALIZES [[clang::reinitializes]] |
| 22 | #else |
| 23 | #define SK_CLANG_REINITIALIZES |
| 24 | #endif |
| 25 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 26 | namespace SkSL { |
| 27 | |
| 28 | class Expression; |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 29 | class Type; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 30 | |
| 31 | namespace dsl { |
| 32 | |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 33 | class DSLPossibleExpression; |
Ethan Nicholas | cfefec0 | 2021-02-09 15:22:57 -0500 | [diff] [blame] | 34 | class DSLStatement; |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 35 | class DSLType; |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 36 | class DSLVarBase; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * Represents an expression such as 'cos(x)' or 'a + b'. |
| 40 | */ |
| 41 | class DSLExpression { |
| 42 | public: |
| 43 | DSLExpression(const DSLExpression&) = delete; |
| 44 | |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 45 | DSLExpression(DSLExpression&&); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 46 | |
| 47 | DSLExpression(); |
| 48 | |
| 49 | /** |
| 50 | * Creates an expression representing a literal float. |
| 51 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 52 | DSLExpression(float value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * Creates an expression representing a literal float. |
| 56 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 57 | DSLExpression(double value, PositionInfo pos = PositionInfo::Capture()) |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 58 | : DSLExpression((float) value) {} |
| 59 | |
| 60 | /** |
| 61 | * Creates an expression representing a literal int. |
| 62 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 63 | DSLExpression(int value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 64 | |
| 65 | /** |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 66 | * Creates an expression representing a literal int. |
| 67 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 68 | DSLExpression(int64_t value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 69 | |
| 70 | /** |
Ethan Nicholas | b83199e | 2021-05-03 14:25:35 -0400 | [diff] [blame] | 71 | * Creates an expression representing a literal uint. |
| 72 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 73 | DSLExpression(unsigned int value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b83199e | 2021-05-03 14:25:35 -0400 | [diff] [blame] | 74 | |
| 75 | /** |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 76 | * Creates an expression representing a literal bool. |
| 77 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 78 | DSLExpression(bool value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 79 | |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 80 | /** |
| 81 | * Creates an expression representing a variable reference. |
| 82 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 83 | DSLExpression(DSLVarBase& var, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 707d315 | 2021-03-25 17:49:08 -0400 | [diff] [blame] | 84 | |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 85 | DSLExpression(DSLVarBase&& var, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 86 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 87 | DSLExpression(DSLPossibleExpression expr, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 88 | |
Ethan Nicholas | b4f8b7a | 2021-06-23 10:27:09 -0400 | [diff] [blame] | 89 | explicit DSLExpression(std::unique_ptr<SkSL::Expression> expression); |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 90 | |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 91 | static DSLExpression Poison(PositionInfo pos = PositionInfo::Capture()); |
| 92 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 93 | ~DSLExpression(); |
| 94 | |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 95 | DSLType type(); |
| 96 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 97 | /** |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 98 | * Overloads the '=' operator to create an SkSL assignment statement. |
| 99 | */ |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 100 | DSLPossibleExpression operator=(DSLExpression other); |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 101 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 102 | DSLExpression x(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 103 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 104 | DSLExpression y(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 105 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 106 | DSLExpression z(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 107 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 108 | DSLExpression w(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 109 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 110 | DSLExpression r(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 111 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 112 | DSLExpression g(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 113 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 114 | DSLExpression b(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 115 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 116 | DSLExpression a(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 117 | |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 118 | /** |
Ethan Nicholas | bf79dff | 2021-02-11 15:18:31 -0500 | [diff] [blame] | 119 | * Creates an SkSL struct field access expression. |
| 120 | */ |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 121 | DSLExpression field(skstd::string_view name, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | bf79dff | 2021-02-11 15:18:31 -0500 | [diff] [blame] | 122 | |
| 123 | /** |
Ethan Nicholas | 04be339 | 2021-01-26 10:07:01 -0500 | [diff] [blame] | 124 | * Creates an SkSL array index expression. |
| 125 | */ |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 126 | DSLPossibleExpression operator[](DSLExpression index); |
Ethan Nicholas | 04be339 | 2021-01-26 10:07:01 -0500 | [diff] [blame] | 127 | |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 128 | DSLPossibleExpression operator()(SkTArray<DSLWrapper<DSLExpression>> args, |
| 129 | PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 130 | |
Ethan Nicholas | 9a1f92e | 2021-09-09 15:03:22 -0400 | [diff] [blame] | 131 | DSLPossibleExpression operator()(ExpressionArray args, |
| 132 | PositionInfo pos = PositionInfo::Capture()); |
| 133 | |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 134 | /** |
| 135 | * Returns true if this object contains an expression. DSLExpressions which were created with |
Ethan Nicholas | 51b4b86 | 2021-08-31 16:12:40 -0400 | [diff] [blame] | 136 | * the empty constructor or which have already been release()ed do not have a value. |
| 137 | * DSLExpressions created with errors are still considered to have a value (but contain poison). |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 138 | */ |
Ethan Nicholas | 51b4b86 | 2021-08-31 16:12:40 -0400 | [diff] [blame] | 139 | bool hasValue() const { |
Ethan Nicholas | b4f8b7a | 2021-06-23 10:27:09 -0400 | [diff] [blame] | 140 | return fExpression != nullptr; |
| 141 | } |
| 142 | |
Ethan Nicholas | 51b4b86 | 2021-08-31 16:12:40 -0400 | [diff] [blame] | 143 | /** |
| 144 | * Returns true if this object contains an expression which is not poison. |
| 145 | */ |
| 146 | bool isValid() const; |
| 147 | |
Ethan Nicholas | 5b1ae4b | 2021-09-16 10:08:20 -0400 | [diff] [blame] | 148 | SK_CLANG_REINITIALIZES void swap(DSLExpression& other); |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 149 | |
Ethan Nicholas | 04be339 | 2021-01-26 10:07:01 -0500 | [diff] [blame] | 150 | /** |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 151 | * Invalidates this object and returns the SkSL expression it represents. It is an error to call |
| 152 | * this on an invalid DSLExpression. |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 153 | */ |
| 154 | std::unique_ptr<SkSL::Expression> release(); |
| 155 | |
| 156 | private: |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 157 | /** |
Ethan Nicholas | 51b4b86 | 2021-08-31 16:12:40 -0400 | [diff] [blame] | 158 | * Calls release if this expression has a value, otherwise returns null. |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 159 | */ |
Ethan Nicholas | 51b4b86 | 2021-08-31 16:12:40 -0400 | [diff] [blame] | 160 | std::unique_ptr<SkSL::Expression> releaseIfPossible(); |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 161 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 162 | std::unique_ptr<SkSL::Expression> fExpression; |
| 163 | |
Ethan Nicholas | 840f581 | 2021-02-16 13:02:57 -0500 | [diff] [blame] | 164 | friend DSLExpression SampleChild(int index, DSLExpression coords); |
| 165 | |
Ethan Nicholas | d6b6f3e | 2021-01-22 15:18:25 -0500 | [diff] [blame] | 166 | friend class DSLCore; |
Ethan Nicholas | 63f75fc | 2021-02-23 12:05:49 -0500 | [diff] [blame] | 167 | friend class DSLFunction; |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 168 | friend class DSLPossibleExpression; |
John Stiles | 1a2cef7 | 2021-10-04 12:43:11 -0400 | [diff] [blame] | 169 | friend class DSLType; |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 170 | friend class DSLVarBase; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 171 | friend class DSLWriter; |
Ethan Nicholas | a1a0b92 | 2021-05-04 12:22:02 -0400 | [diff] [blame] | 172 | template<typename T> friend class DSLWrapper; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 173 | }; |
| 174 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 175 | DSLPossibleExpression operator+(DSLExpression left, DSLExpression right); |
Ethan Nicholas | b14b636 | 2021-03-08 17:07:58 -0500 | [diff] [blame] | 176 | DSLPossibleExpression operator+(DSLExpression expr); |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 177 | DSLPossibleExpression operator+=(DSLExpression left, DSLExpression right); |
| 178 | DSLPossibleExpression operator-(DSLExpression left, DSLExpression right); |
Ethan Nicholas | b14b636 | 2021-03-08 17:07:58 -0500 | [diff] [blame] | 179 | DSLPossibleExpression operator-(DSLExpression expr); |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 180 | DSLPossibleExpression operator-=(DSLExpression left, DSLExpression right); |
| 181 | DSLPossibleExpression operator*(DSLExpression left, DSLExpression right); |
| 182 | DSLPossibleExpression operator*=(DSLExpression left, DSLExpression right); |
| 183 | DSLPossibleExpression operator/(DSLExpression left, DSLExpression right); |
| 184 | DSLPossibleExpression operator/=(DSLExpression left, DSLExpression right); |
| 185 | DSLPossibleExpression operator%(DSLExpression left, DSLExpression right); |
| 186 | DSLPossibleExpression operator%=(DSLExpression left, DSLExpression right); |
| 187 | DSLPossibleExpression operator<<(DSLExpression left, DSLExpression right); |
| 188 | DSLPossibleExpression operator<<=(DSLExpression left, DSLExpression right); |
| 189 | DSLPossibleExpression operator>>(DSLExpression left, DSLExpression right); |
| 190 | DSLPossibleExpression operator>>=(DSLExpression left, DSLExpression right); |
| 191 | DSLPossibleExpression operator&&(DSLExpression left, DSLExpression right); |
| 192 | DSLPossibleExpression operator||(DSLExpression left, DSLExpression right); |
| 193 | DSLPossibleExpression operator&(DSLExpression left, DSLExpression right); |
| 194 | DSLPossibleExpression operator&=(DSLExpression left, DSLExpression right); |
| 195 | DSLPossibleExpression operator|(DSLExpression left, DSLExpression right); |
| 196 | DSLPossibleExpression operator|=(DSLExpression left, DSLExpression right); |
| 197 | DSLPossibleExpression operator^(DSLExpression left, DSLExpression right); |
| 198 | DSLPossibleExpression operator^=(DSLExpression left, DSLExpression right); |
Ethan Nicholas | 2ab47c9 | 2021-07-19 12:30:37 -0400 | [diff] [blame] | 199 | DSLPossibleExpression LogicalXor(DSLExpression left, DSLExpression right); |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 200 | DSLPossibleExpression operator,(DSLExpression left, DSLExpression right); |
Ethan Nicholas | db2326b | 2021-04-19 10:55:18 -0400 | [diff] [blame] | 201 | DSLPossibleExpression operator,(DSLPossibleExpression left, DSLExpression right); |
| 202 | DSLPossibleExpression operator,(DSLExpression left, DSLPossibleExpression right); |
| 203 | DSLPossibleExpression operator,(DSLPossibleExpression left, DSLPossibleExpression right); |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 204 | DSLPossibleExpression operator==(DSLExpression left, DSLExpression right); |
| 205 | DSLPossibleExpression operator!=(DSLExpression left, DSLExpression right); |
| 206 | DSLPossibleExpression operator>(DSLExpression left, DSLExpression right); |
| 207 | DSLPossibleExpression operator<(DSLExpression left, DSLExpression right); |
| 208 | DSLPossibleExpression operator>=(DSLExpression left, DSLExpression right); |
| 209 | DSLPossibleExpression operator<=(DSLExpression left, DSLExpression right); |
| 210 | DSLPossibleExpression operator!(DSLExpression expr); |
| 211 | DSLPossibleExpression operator~(DSLExpression expr); |
| 212 | DSLPossibleExpression operator++(DSLExpression expr); |
| 213 | DSLPossibleExpression operator++(DSLExpression expr, int); |
| 214 | DSLPossibleExpression operator--(DSLExpression expr); |
| 215 | DSLPossibleExpression operator--(DSLExpression expr, int); |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 216 | |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 217 | /** |
| 218 | * Represents an Expression which may have failed and/or have pending errors to report. Converting a |
| 219 | * PossibleExpression into an Expression requires PositionInfo so that any pending errors can be |
| 220 | * reported at the correct position. |
| 221 | * |
| 222 | * PossibleExpression is used instead of Expression in situations where it is not possible to |
| 223 | * capture the PositionInfo at the time of Expression construction (notably in operator overloads, |
| 224 | * where we cannot add default parameters). |
| 225 | */ |
| 226 | class DSLPossibleExpression { |
| 227 | public: |
| 228 | DSLPossibleExpression(std::unique_ptr<SkSL::Expression> expression); |
| 229 | |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 230 | DSLPossibleExpression(DSLPossibleExpression&& other); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 231 | |
| 232 | ~DSLPossibleExpression(); |
| 233 | |
Ethan Nicholas | b4f8b7a | 2021-06-23 10:27:09 -0400 | [diff] [blame] | 234 | bool valid() const { |
| 235 | return fExpression != nullptr; |
| 236 | } |
| 237 | |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 238 | /** |
| 239 | * Reports any pending errors at the specified position. |
| 240 | */ |
| 241 | void reportErrors(PositionInfo pos); |
| 242 | |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 243 | DSLType type(); |
| 244 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 245 | DSLExpression x(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 246 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 247 | DSLExpression y(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 248 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 249 | DSLExpression z(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 250 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 251 | DSLExpression w(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 252 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 253 | DSLExpression r(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 254 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 255 | DSLExpression g(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 256 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 257 | DSLExpression b(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 258 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 259 | DSLExpression a(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 260 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 261 | DSLExpression field(skstd::string_view name, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 262 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 263 | DSLPossibleExpression operator=(DSLExpression expr); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 264 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 265 | DSLPossibleExpression operator=(int expr); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 266 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 267 | DSLPossibleExpression operator=(float expr); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 268 | |
Ethan Nicholas | a60cc3e | 2021-04-23 16:15:11 -0400 | [diff] [blame] | 269 | DSLPossibleExpression operator=(double expr); |
| 270 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 271 | DSLPossibleExpression operator[](DSLExpression index); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 272 | |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame] | 273 | DSLPossibleExpression operator()(SkTArray<DSLWrapper<DSLExpression>> args, |
| 274 | PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 275 | |
Ethan Nicholas | 9a1f92e | 2021-09-09 15:03:22 -0400 | [diff] [blame] | 276 | DSLPossibleExpression operator()(ExpressionArray args, |
| 277 | PositionInfo pos = PositionInfo::Capture()); |
| 278 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 279 | DSLPossibleExpression operator++(); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 280 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 281 | DSLPossibleExpression operator++(int); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 282 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 283 | DSLPossibleExpression operator--(); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 284 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 285 | DSLPossibleExpression operator--(int); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 286 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 287 | std::unique_ptr<SkSL::Expression> release(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 288 | |
| 289 | private: |
| 290 | std::unique_ptr<SkSL::Expression> fExpression; |
| 291 | |
| 292 | friend class DSLExpression; |
| 293 | }; |
| 294 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 295 | } // namespace dsl |
| 296 | |
| 297 | } // namespace SkSL |
| 298 | |
| 299 | #endif |